immuneML.reports package

Subpackages

Submodules

immuneML.reports.PlotlyUtil module

class immuneML.reports.PlotlyUtil.PlotlyUtil[source]

Bases: object

static add_single_axis_labels(figure, x_label, y_label, x_label_position, y_label_position)[source]

Takes a multi-facet plotly figure and replaces the repetitive x and y axis labels with single axis labels in the form of annotations.

Parameters
  • figure – a plotly figure

  • x_label – the x label text

  • y_label – the y label text

  • x_label_position – the position of the new axis labels relative to the respective axes

  • y_label_position – the position of the new axis labels relative to the respective axes

Returns

an updated plotly figure

immuneML.reports.Report module

class immuneML.reports.Report.Report(name: Optional[str] = None)[source]

Bases: object

This class defines what report classes should look like: they all have to inherit this class and implement the abstract methods: build_object() from parameters and generate() the report once all properties are set (in immuneML this will be taken care of by the instructions). If there are any prerequisites needed to run the report (e.g., check if all parameter values are properly set), the check_prerequisites function should be overwritten to reflect that and determine if everything is set before generate() is run. See specific functions for more details.

abstract classmethod build_object(**kwargs)[source]

Creates the object of the subclass of the Report class from the parameters so that it can be used in the analysis. Depending on the type of the report, the parameters provided here will be provided in parsing time, while the other necessary parameters (e.g., subset of the data from which the report should be created) will be provided at runtime. For more details, see specific direct subclasses of this class, describing different types of reports.

Parameters

**kwargs – keyword arguments that will be provided by users in the specification (if immuneML is used as a command line tool) or in the dictionary when calling the method from the code, and which should be used to create the report object

Returns

the object of the appropriate report class

check_prerequisites() → bool[source]

Checks prerequisites for the generation of the report of specific class (e.g., if the class of the MLMethod instance is the one required by the report, if the data has been encoded to make a report of encoded dataset). In the instructions in immuneML, this function is used to determine whether to call generate_report() in the specific situation. Each report subclass has its own set of prerequisites. If the report cannot be run, the information on this will be logged and the report skipped in the specific situation. No error will be raised. See subclasses of the class Instruction for more information on how the reports are executed.

Returns

boolean value True if the prerequisites are o.k., and False otherwise.

generate_report()immuneML.reports.ReportResult.ReportResult[source]

Generates a report of the given class if the prerequisites are satisfied. It handles all exceptions so that if there is an error while generating a report, the execution of the rest of the code (e.g., more time-expensive parts, like instructions) is not influenced.

Returns

ReportResult object which encapsulates all outputs (figure, table, and text files) so that they can be conveniently linked to in the final output of instructions

set_context(context: dict)[source]

Context is a dictionary with information that is accessible from the level of instruction and can be used to precompute certain values that can be later reused to speed up the generation of the subsequent reports of the same time. For instance, if one should compute the distance between all repertoires based on the sequence content, it is possible to store the full dataset in the context, compute the distances on the full dataset and then only extract the distances need for the current dataset in the later calls (e.g., when training dataset is passed as input). Only some reports will need this functionality.

Warning: It is very important to be careful when using the context to avoid leaking the information between training and test datasets.

Parameters

context (dict) – a dictionary where the values are variables that are typically only available on the top-level of the instruction, and which are used to precompute results in order to speed up subsequent generation of the same report on subsets of those values.

Returns

self - so that it can be chained with the other function calls

immuneML.reports.ReportOutput module

class immuneML.reports.ReportOutput.ReportOutput(path: pathlib.Path, name: str = None)[source]

Bases: object

immuneML.reports.ReportResult module

class immuneML.reports.ReportResult.ReportResult(name: str = None, output_figures: List[immuneML.reports.ReportOutput.ReportOutput] = <factory>, output_tables: List[immuneML.reports.ReportOutput.ReportOutput] = <factory>, output_text: List[immuneML.reports.ReportOutput.ReportOutput] = <factory>)[source]

Bases: object

name: str = None
output_figures: List[immuneML.reports.ReportOutput.ReportOutput]
output_tables: List[immuneML.reports.ReportOutput.ReportOutput]
output_text: List[immuneML.reports.ReportOutput.ReportOutput]

immuneML.reports.ReportUtil module

class immuneML.reports.ReportUtil.ReportUtil[source]

Bases: object

static run_ML_reports(train_dataset: immuneML.data_model.dataset.Dataset.Dataset, test_dataset: immuneML.data_model.dataset.Dataset.Dataset, method: immuneML.ml_methods.MLMethod.MLMethod, reports: List[immuneML.reports.ml_reports.MLReport.MLReport], path: pathlib.Path, hp_setting: immuneML.hyperparameter_optimization.HPSetting.HPSetting, label: str, context: Optional[dict] = None) → List[immuneML.reports.ReportResult.ReportResult][source]
static run_data_reports(dataset: immuneML.data_model.dataset.Dataset.Dataset, reports: List[immuneML.reports.data_reports.DataReport.DataReport], path: pathlib.Path, context: Optional[dict] = None)[source]
static run_encoding_reports(dataset: immuneML.data_model.dataset.Dataset.Dataset, reports: List[immuneML.reports.encoding_reports.EncodingReport.EncodingReport], path: pathlib.Path, context: Optional[dict] = None) → List[immuneML.reports.ReportResult.ReportResult][source]

Module contents