immuneML.reports.clustering_reports package

Submodules

immuneML.reports.clustering_reports.ClusteringReport module

class immuneML.reports.clustering_reports.ClusteringReport.ClusteringReport(name: str = None, result_path: Path = None, number_of_processes: int = 1, state: ClusteringState = None)[source]

Bases: Report

DOCS_TITLE = 'Clustering Instruction Reports'
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

immuneML.reports.clustering_reports.ClusteringStabilityReport module

class immuneML.reports.clustering_reports.ClusteringStabilityReport.ClusteringStabilityReport(similarity_metric: str, name: str = None, state: ClusteringState = None, result_path: Path = None, number_of_processes: int = 1)[source]

Bases: ClusteringReport

Report that analyzes clustering stability by comparing results between discovery and validation datasets. The comparison uses a classifier-based approach where: 1. A classifier is trained on discovery data using cluster assignments as labels 2. Cluster assignments are predicted for validation data 3. Predictions are compared with actual validation clustering results using the specified similarity metric

This report can be used with the Clustering instruction under ‘reports’.

Specification arguments:

  • metric (str): Name of any clustering evaluation metric from sklearn.metrics that compares two sets of labels (e.g., adjusted_rand_score, jaccard_score, adjusted_mutual_info_score, normalized_mutual_info_score). If an invalid metric name is provided, defaults to adjusted_rand_score.

YAML specification:

my_clustering_instruction:
    type: Clustering
    reports:
        my_stability_report:
            ClusteringStabilityReport:
                metric: jaccard_score
DEFAULT_METRIC = 'adjusted_rand_score'
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()[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.

immuneML.reports.clustering_reports.ClusteringVisualization module

class immuneML.reports.clustering_reports.ClusteringVisualization.ClusteringVisualization(dim_red_method: DimRedMethod = None, name: str = None, result_path: Path = None, number_of_processes: int = 1, state: ClusteringState = None)[source]

Bases: ClusteringReport

A report that creates low-dimensional visualizations of clustering results using the specified dimensionality reduction method. For each dataset and clustering configuration, it creates a scatter plot where points are colored by their cluster assignments.

Specification arguments:

dim_red_method (dict): specification of which dimensionality reduction to perform; valid options are presented under Dimensionality reduction methods and should be specified with the name of the method and its parameters, see the example below

YAML specification:

reports:
    my_report_with_pca:
        ClusteringVisualization:
            dim_red_method:
                PCA:
                    n_components: 2
    my_report_with_tsne:
        ClusteringVisualization:
            dim_red_method:
                TSNE:
                    n_components: 2
                    init: pca
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

immuneML.reports.clustering_reports.ExternalLabelClusterSummary module

class immuneML.reports.clustering_reports.ExternalLabelClusterSummary.ExternalLabelClusterSummary(external_labels: List[str], name: str = None, state: ClusteringState = None, result_path: Path = None, number_of_processes: int = 1)[source]

Bases: ClusteringReport

This report summarizes the number of examples in a cluster with different values of external labels. For each external label, it creates: 1. A contingency table showing the count of examples for each combination of cluster and label value 2. A heatmap visualization of these counts

It can be used in combination with Clustering instruction.

Specification arguments:

  • external_labels (list): the list of metadata columns in the dataset that should be compared against cluster assignment

YAML specification:

reports:
    my_external_label_cluster_summary:
        ExternalLabelClusterSummary:
            external_labels: [disease, HLA]
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()[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.

immuneML.reports.clustering_reports.ExternalLabelMetricHeatmap module

class immuneML.reports.clustering_reports.ExternalLabelMetricHeatmap.ExternalLabelMetricHeatmap(name: str = None, state: ClusteringState = None, result_path: Path = None, number_of_processes: int = 1)[source]

Bases: ClusteringReport

This report creates heatmaps comparing clustering methods against external labels for each metric. For each external label and metric combination, it creates:

  1. A table showing the metric values for each combination of clustering method and external label

  2. A heatmap visualization of these values

The external labels and metrics are automatically determined from the clustering instruction specification.

YAML specification:

reports:
    my_external_label_metric_heatmap: ExternalLabelMetricHeatmap
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()[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.

Module contents