scranpy.analyze package#

Submodules#

scranpy.analyze.AnalyzeOptions module#

class scranpy.analyze.AnalyzeOptions.AnalyzeOptions(per_cell_rna_qc_metrics_options=<factory>, suggest_rna_qc_filters_options=<factory>, create_rna_qc_filter_options=<factory>, per_cell_adt_qc_metrics_options=<factory>, suggest_adt_qc_filters_options=<factory>, create_adt_qc_filter_options=<factory>, per_cell_crispr_qc_metrics_options=<factory>, suggest_crispr_qc_filters_options=<factory>, create_crispr_qc_filter_options=<factory>, filter_cells_options=<factory>, rna_log_norm_counts_options=<factory>, grouped_size_factors_options=<factory>, adt_log_norm_counts_options=<factory>, crispr_log_norm_counts_options=<factory>, choose_hvgs_options=<factory>, model_gene_variances_options=<factory>, rna_run_pca_options=<factory>, adt_run_pca_options=<factory>, crispr_run_pca_options=<factory>, combine_embeddings_options=<factory>, mnn_correct_options=<factory>, build_neighbor_index_options=<factory>, run_tsne_options=<factory>, run_umap_options=<factory>, find_nearest_neighbors_options=<factory>, build_snn_graph_options=<factory>, rna_score_markers_options=<factory>, adt_score_markers_options=<factory>, crispr_score_markers_options=<factory>, miscellaneous_options=<factory>)[source]#

Bases: object

Optional parameters for all analyze() steps.

Optional parameters for each function are named after the function with the _options suffix. In most cases, these can be modified directly to refine the behavior of the analyze() function. However, for a few options, it usually makes more sense to set them across multiple parameter objects simultaneously; check out the setter methods of this class for more details.

per_cell_rna_qc_metrics_options#

Options to pass to per_cell_rna_qc_metrics().

suggest_rna_qc_filters_options#

Options to pass to suggest_rna_qc_filters().

create_rna_qc_filter_options#

Options to pass to create_rna_qc_filter().

per_cell_adt_qc_metrics_options#

Options to pass to per_cell_adt_qc_metrics().

suggest_adt_qc_filters_options#

Options to pass to suggest_adt_qc_filters().

create_adt_qc_filter_options#

Options to pass to create_adt_qc_filter().

per_cell_crispr_qc_metrics_options#

Options to pass to per_cell_crispr_qc_metrics().

suggest_crispr_qc_filters_options#

Options to pass to suggest_crispr_qc_filters().

create_crispr_qc_filter_options#

Options to pass to create_crispr_qc_filter().

filter_cells_options#

Options to pass to filter_cells().

rna_log_norm_counts_options#

Options to pass to log_norm_counts() for the RNA count matrix.

grouped_size_factors_options#

Options to pass to grouped_size_factors() to compute ADT size factors.

adt_log_norm_counts_options#

Options to pass to log_norm_counts() for the ADT count matrix.

crispr_log_norm_counts_options#

Options to pass to log_norm_counts() for the CRISPR count matrix.

choose_hvgs_options#

Options to pass to choose_hvgs() to choose highly variable genes for the RNA data.

model_gene_variances_options#

Options to pass to model_gene_variances() to model per-gene variances for the RNA data.

rna_run_pca_options#

Options to pass to run_pca() for the RNA log-expression matrix.

adt_run_pca_options#

Options to pass to run_pca() for the ADT log-expression matrix.

crispr_run_pca_options#

Options to pass to run_pca() for the CRISPR log-expression matrix.

mnn_correct_options#

Options to pass to mnn_correct().

build_neighbor_index_options#

Options to pass to build_neighbor_index().

find_nearest_neighbors_options#

Options to pass to find_nearest_neighbors().

run_tsne_options#

Options to pass to run_tsne().

run_umap_options#

Options to pass to run_umap().

build_snn_graph_options#

Options to pass to build_snn_graph().

rna_score_markers_options#

Options to pass to score_markers() for the RNA log-expression values.

adt_score_markers_options#

Options to pass to score_markers() for the ADT log-abundances.

crispr_score_markers_options#

Options to pass to score_markers() for the CRISPR log-abundances.

miscellaneous_options#

Further options that are not associated with any single function call.

__annotations__ = {'adt_log_norm_counts_options': <class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>, 'adt_run_pca_options': <class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>, 'adt_score_markers_options': <class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>, 'build_neighbor_index_options': <class 'scranpy.nearest_neighbors.build_neighbor_index.BuildNeighborIndexOptions'>, 'build_snn_graph_options': <class 'scranpy.clustering.build_snn_graph.BuildSnnGraphOptions'>, 'choose_hvgs_options': <class 'scranpy.feature_selection.choose_hvgs.ChooseHvgsOptions'>, 'combine_embeddings_options': <class 'scranpy.dimensionality_reduction.combine_embeddings.CombineEmbeddingsOptions'>, 'create_adt_qc_filter_options': <class 'scranpy.quality_control.create_adt_qc_filter.CreateAdtQcFilterOptions'>, 'create_crispr_qc_filter_options': <class 'scranpy.quality_control.create_crispr_qc_filter.CreateCrisprQcFilterOptions'>, 'create_rna_qc_filter_options': <class 'scranpy.quality_control.create_rna_qc_filter.CreateRnaQcFilterOptions'>, 'crispr_log_norm_counts_options': <class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>, 'crispr_run_pca_options': <class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>, 'crispr_score_markers_options': <class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>, 'filter_cells_options': <class 'scranpy.quality_control.filter_cells.FilterCellsOptions'>, 'find_nearest_neighbors_options': <class 'scranpy.nearest_neighbors.find_nearest_neighbors.FindNearestNeighborsOptions'>, 'grouped_size_factors_options': <class 'scranpy.normalization.grouped_size_factors.GroupedSizeFactorsOptions'>, 'miscellaneous_options': <class 'scranpy.analyze.AnalyzeOptions.MiscellaneousOptions'>, 'mnn_correct_options': <class 'scranpy.batch_correction.mnn_correct.MnnCorrectOptions'>, 'model_gene_variances_options': <class 'scranpy.feature_selection.model_gene_variances.ModelGeneVariancesOptions'>, 'per_cell_adt_qc_metrics_options': <class 'scranpy.quality_control.per_cell_adt_qc_metrics.PerCellAdtQcMetricsOptions'>, 'per_cell_crispr_qc_metrics_options': <class 'scranpy.quality_control.per_cell_crispr_qc_metrics.PerCellCrisprQcMetricsOptions'>, 'per_cell_rna_qc_metrics_options': <class 'scranpy.quality_control.per_cell_rna_qc_metrics.PerCellRnaQcMetricsOptions'>, 'rna_log_norm_counts_options': <class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>, 'rna_run_pca_options': <class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>, 'rna_score_markers_options': <class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>, 'run_tsne_options': <class 'scranpy.dimensionality_reduction.run_tsne.RunTsneOptions'>, 'run_umap_options': <class 'scranpy.dimensionality_reduction.run_umap.RunUmapOptions'>, 'suggest_adt_qc_filters_options': <class 'scranpy.quality_control.suggest_adt_qc_filters.SuggestAdtQcFiltersOptions'>, 'suggest_crispr_qc_filters_options': <class 'scranpy.quality_control.suggest_crispr_qc_filters.SuggestCrisprQcFiltersOptions'>, 'suggest_rna_qc_filters_options': <class 'scranpy.quality_control.suggest_rna_qc_filters.SuggestRnaQcFiltersOptions'>}#
__dataclass_fields__ = {'adt_log_norm_counts_options': Field(name='adt_log_norm_counts_options',type=<class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_run_pca_options': Field(name='adt_run_pca_options',type=<class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_score_markers_options': Field(name='adt_score_markers_options',type=<class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'build_neighbor_index_options': Field(name='build_neighbor_index_options',type=<class 'scranpy.nearest_neighbors.build_neighbor_index.BuildNeighborIndexOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.nearest_neighbors.build_neighbor_index.BuildNeighborIndexOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'build_snn_graph_options': Field(name='build_snn_graph_options',type=<class 'scranpy.clustering.build_snn_graph.BuildSnnGraphOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.clustering.build_snn_graph.BuildSnnGraphOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'choose_hvgs_options': Field(name='choose_hvgs_options',type=<class 'scranpy.feature_selection.choose_hvgs.ChooseHvgsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.feature_selection.choose_hvgs.ChooseHvgsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'combine_embeddings_options': Field(name='combine_embeddings_options',type=<class 'scranpy.dimensionality_reduction.combine_embeddings.CombineEmbeddingsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.dimensionality_reduction.combine_embeddings.CombineEmbeddingsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'create_adt_qc_filter_options': Field(name='create_adt_qc_filter_options',type=<class 'scranpy.quality_control.create_adt_qc_filter.CreateAdtQcFilterOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.create_adt_qc_filter.CreateAdtQcFilterOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'create_crispr_qc_filter_options': Field(name='create_crispr_qc_filter_options',type=<class 'scranpy.quality_control.create_crispr_qc_filter.CreateCrisprQcFilterOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.create_crispr_qc_filter.CreateCrisprQcFilterOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'create_rna_qc_filter_options': Field(name='create_rna_qc_filter_options',type=<class 'scranpy.quality_control.create_rna_qc_filter.CreateRnaQcFilterOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.create_rna_qc_filter.CreateRnaQcFilterOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_log_norm_counts_options': Field(name='crispr_log_norm_counts_options',type=<class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_run_pca_options': Field(name='crispr_run_pca_options',type=<class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_score_markers_options': Field(name='crispr_score_markers_options',type=<class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'filter_cells_options': Field(name='filter_cells_options',type=<class 'scranpy.quality_control.filter_cells.FilterCellsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.filter_cells.FilterCellsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'find_nearest_neighbors_options': Field(name='find_nearest_neighbors_options',type=<class 'scranpy.nearest_neighbors.find_nearest_neighbors.FindNearestNeighborsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.nearest_neighbors.find_nearest_neighbors.FindNearestNeighborsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'grouped_size_factors_options': Field(name='grouped_size_factors_options',type=<class 'scranpy.normalization.grouped_size_factors.GroupedSizeFactorsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.normalization.grouped_size_factors.GroupedSizeFactorsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'miscellaneous_options': Field(name='miscellaneous_options',type=<class 'scranpy.analyze.AnalyzeOptions.MiscellaneousOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.analyze.AnalyzeOptions.MiscellaneousOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'mnn_correct_options': Field(name='mnn_correct_options',type=<class 'scranpy.batch_correction.mnn_correct.MnnCorrectOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.batch_correction.mnn_correct.MnnCorrectOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'model_gene_variances_options': Field(name='model_gene_variances_options',type=<class 'scranpy.feature_selection.model_gene_variances.ModelGeneVariancesOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.feature_selection.model_gene_variances.ModelGeneVariancesOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'per_cell_adt_qc_metrics_options': Field(name='per_cell_adt_qc_metrics_options',type=<class 'scranpy.quality_control.per_cell_adt_qc_metrics.PerCellAdtQcMetricsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.per_cell_adt_qc_metrics.PerCellAdtQcMetricsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'per_cell_crispr_qc_metrics_options': Field(name='per_cell_crispr_qc_metrics_options',type=<class 'scranpy.quality_control.per_cell_crispr_qc_metrics.PerCellCrisprQcMetricsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.per_cell_crispr_qc_metrics.PerCellCrisprQcMetricsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'per_cell_rna_qc_metrics_options': Field(name='per_cell_rna_qc_metrics_options',type=<class 'scranpy.quality_control.per_cell_rna_qc_metrics.PerCellRnaQcMetricsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.per_cell_rna_qc_metrics.PerCellRnaQcMetricsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_log_norm_counts_options': Field(name='rna_log_norm_counts_options',type=<class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.normalization.log_norm_counts.LogNormCountsOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_run_pca_options': Field(name='rna_run_pca_options',type=<class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.dimensionality_reduction.run_pca.RunPcaOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_score_markers_options': Field(name='rna_score_markers_options',type=<class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.marker_detection.score_markers.ScoreMarkersOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'run_tsne_options': Field(name='run_tsne_options',type=<class 'scranpy.dimensionality_reduction.run_tsne.RunTsneOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.dimensionality_reduction.run_tsne.RunTsneOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'run_umap_options': Field(name='run_umap_options',type=<class 'scranpy.dimensionality_reduction.run_umap.RunUmapOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.dimensionality_reduction.run_umap.RunUmapOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'suggest_adt_qc_filters_options': Field(name='suggest_adt_qc_filters_options',type=<class 'scranpy.quality_control.suggest_adt_qc_filters.SuggestAdtQcFiltersOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.suggest_adt_qc_filters.SuggestAdtQcFiltersOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'suggest_crispr_qc_filters_options': Field(name='suggest_crispr_qc_filters_options',type=<class 'scranpy.quality_control.suggest_crispr_qc_filters.SuggestCrisprQcFiltersOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.suggest_crispr_qc_filters.SuggestCrisprQcFiltersOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'suggest_rna_qc_filters_options': Field(name='suggest_rna_qc_filters_options',type=<class 'scranpy.quality_control.suggest_rna_qc_filters.SuggestRnaQcFiltersOptions'>,default=<dataclasses._MISSING_TYPE object>,default_factory=<class 'scranpy.quality_control.suggest_rna_qc_filters.SuggestRnaQcFiltersOptions'>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)#
__eq__(other)#

Return self==value.

__hash__ = None#
__repr__()#

Return repr(self).

adt_log_norm_counts_options: LogNormCountsOptions#
adt_run_pca_options: RunPcaOptions#
adt_score_markers_options: ScoreMarkersOptions#
build_neighbor_index_options: BuildNeighborIndexOptions#
build_snn_graph_options: BuildSnnGraphOptions#
choose_hvgs_options: ChooseHvgsOptions#
combine_embeddings_options: CombineEmbeddingsOptions#
create_adt_qc_filter_options: CreateAdtQcFilterOptions#
create_crispr_qc_filter_options: CreateCrisprQcFilterOptions#
create_rna_qc_filter_options: CreateRnaQcFilterOptions#
crispr_log_norm_counts_options: LogNormCountsOptions#
crispr_run_pca_options: RunPcaOptions#
crispr_score_markers_options: ScoreMarkersOptions#
filter_cells_options: FilterCellsOptions#
find_nearest_neighbors_options: FindNearestNeighborsOptions#
grouped_size_factors_options: GroupedSizeFactorsOptions#
miscellaneous_options: MiscellaneousOptions#
mnn_correct_options: MnnCorrectOptions#
model_gene_variances_options: ModelGeneVariancesOptions#
per_cell_adt_qc_metrics_options: PerCellAdtQcMetricsOptions#
per_cell_crispr_qc_metrics_options: PerCellCrisprQcMetricsOptions#
per_cell_rna_qc_metrics_options: PerCellRnaQcMetricsOptions#
rna_log_norm_counts_options: LogNormCountsOptions#
rna_run_pca_options: RunPcaOptions#
rna_score_markers_options: ScoreMarkersOptions#
run_tsne_options: RunTsneOptions#
run_umap_options: RunUmapOptions#
set_seed(seed=42)[source]#

Set seed for RNG. This calls the method of the same name for run_pca(), run_tsne(), run_umap().

Parameters:

seed (int) – Seed for random number generation.

set_threads(num_threads=1)[source]#

Set number of threads to use. This calls the method of the same name for per_cell_rna_qc_metrics(), (), model_gene_variances(), run_pca(), find_nearest_neighbors().

The number of threads provided to find_nearest_neighbors() is also used in run_neighbor_suite(), which determines the thread allocation to subsequent steps like run_tsne() and score_markers(). In all cases, thread utilization will not exceed the limit specified here in num_threads.

Parameters:

num_threads (int) – Number of threads. Defaults to 1.

suggest_adt_qc_filters_options: SuggestAdtQcFiltersOptions#
suggest_crispr_qc_filters_options: SuggestCrisprQcFiltersOptions#
suggest_rna_qc_filters_options: SuggestRnaQcFiltersOptions#
class scranpy.analyze.AnalyzeOptions.MiscellaneousOptions(cell_names=None, rna_feature_names=None, adt_feature_names=None, crispr_feature_names=None, filter_on_rna_qc=True, filter_on_adt_qc=True, filter_on_crispr_qc=True, snn_graph_multilevel_resolution=1, block=None)[source]#

Bases: object

Miscellaneous options for analyze().

cell_names#

Names for all cells in the dataset, to be added to any per-cell data frames. This should have the same length as the number of columns in each data matrix.

rna_feature_names#

Names for all features in the RNA data. This should have the same length as the number of rows in the RNA count matrix.

adt_feature_names#

Names for all tags in the ADT data. This should have the same length as the number of rows in the ADT count matrix.

crispr_feature_names#

Names for all guides in the CRISPR data. This should have the same length as the number of rows in the CRISPR count matrix.

filter_on_rna_qc#

Whether to filter cells on the RNA-based quality control metrics, when RNA data is available.

filter_on_adt_qc#

Whether to filter cells on the ADT-based quality control metrics, when ADT data is available.

filter_on_crispr_qc#

Whether to filter cells on the CRISPR-based quality control metrics, when CRISPR data is available.

snn_graph_multilevel_resolution#

Resolution to use for multi-level clustering of the SNN graph.

block#

Block assignment for each cell. This should have length equal to the total number of cells in the dataset, before any quality control is applied.

__annotations__ = {'adt_feature_names': typing.Optional[typing.Sequence[str]], 'block': typing.Optional[typing.Sequence], 'cell_names': typing.Optional[typing.Sequence[str]], 'crispr_feature_names': typing.Optional[typing.Sequence[str]], 'filter_on_adt_qc': <class 'bool'>, 'filter_on_crispr_qc': <class 'bool'>, 'filter_on_rna_qc': <class 'bool'>, 'rna_feature_names': typing.Optional[typing.Sequence[str]], 'snn_graph_multilevel_resolution': <class 'int'>}#
__dataclass_fields__ = {'adt_feature_names': Field(name='adt_feature_names',type=typing.Optional[typing.Sequence[str]],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'block': Field(name='block',type=typing.Optional[typing.Sequence],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'cell_names': Field(name='cell_names',type=typing.Optional[typing.Sequence[str]],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_feature_names': Field(name='crispr_feature_names',type=typing.Optional[typing.Sequence[str]],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'filter_on_adt_qc': Field(name='filter_on_adt_qc',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'filter_on_crispr_qc': Field(name='filter_on_crispr_qc',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'filter_on_rna_qc': Field(name='filter_on_rna_qc',type=<class 'bool'>,default=True,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_feature_names': Field(name='rna_feature_names',type=typing.Optional[typing.Sequence[str]],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'snn_graph_multilevel_resolution': Field(name='snn_graph_multilevel_resolution',type=<class 'int'>,default=1,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)#
__eq__(other)#

Return self==value.

__hash__ = None#
__repr__()#

Return repr(self).

adt_feature_names: Optional[Sequence[str]] = None#
block: Optional[Sequence] = None#
cell_names: Optional[Sequence[str]] = None#
crispr_feature_names: Optional[Sequence[str]] = None#
filter_on_adt_qc: bool = True#
filter_on_crispr_qc: bool = True#
filter_on_rna_qc: bool = True#
rna_feature_names: Optional[Sequence[str]] = None#
snn_graph_multilevel_resolution: int = 1#

scranpy.analyze.AnalyzeResults module#

class scranpy.analyze.AnalyzeResults.AnalyzeResults(rna_quality_control_metrics=None, rna_quality_control_thresholds=None, rna_quality_control_filter=None, adt_quality_control_metrics=None, adt_quality_control_thresholds=None, adt_quality_control_filter=None, crispr_quality_control_metrics=None, crispr_quality_control_thresholds=None, crispr_quality_control_filter=None, quality_control_retained=None, rna_size_factors=None, adt_size_factors=None, crispr_size_factors=None, gene_variances=None, hvgs=None, rna_pca=None, adt_pca=None, crispr_pca=None, combined_pcs=None, mnn=None, tsne=None, umap=None, snn_graph=None, clusters=None, rna_markers=None, adt_markers=None, crispr_markers=None)[source]#

Bases: object

Results across all analyis steps from analyze().

rna_quality_control_metrics#

Output of per_cell_rna_qc_metrics().

rna_quality_control_thresholds#

Output of suggest_rna_qc_filters().

rna_quality_control_filter#

Output of create_rna_qc_filter().

adt_quality_control_metrics#

Output of per_cell_adt_qc_metrics().

adt_quality_control_thresholds#

Output of suggest_adt_qc_filters().

adt_quality_control_filter#

Output of create_adt_qc_filter().

crispr_quality_control_metrics#

Output of per_cell_crispr_qc_metrics().

crispr_quality_control_thresholds#

Output of suggest_crispr_qc_filters().

crispr_quality_control_filter#

Output of create_crispr_qc_filter().

quality_control_retained#

Array of length equal to the number of cells in the dataset before quality filtering, indicating whether each cell should be retained.

rna_size_factors#

Array of length equal to the number of cells in the dataset after quality filtering, containing the size factor from the RNA data for each cell.

adt_size_factors#

Array of length equal to the number of cells in the dataset after quality filtering, containing the size factor from the ADT data for each cell.

crispr_size_factors#

Array of length equal to the number of cells in the dataset after quality filtering, containing the size factor from the CRISPR data for each cell.

gene_variances#

Output of model_gene_variances().

hvgs#

Output of choose_hvgs().

rna_pca#

Output of run_pca() on the RNA data.

adt_pca#

Output of run_pca() on the ADT data.

crispr_pca#

Output of run_pca() on the CRISPR data.

combined_pcs#

Output of combine_embeddings() on the principal components for multiple modalities.

mnn#

Output of mnn_correct().

tsne#

Output of run_tsne().

umap#

Output of run_umap().

snn_graph#

Output of build_snn_graph().

clusters#

List of length equal to the number of cells in the (filtered) dataset, containing the cluster assignment for each cell.

rna_markers#

Output of score_markers() on the RNA data.

adt_markers#

Output of score_markers() on the ADT data.

crispr_markers#

Output of score_markers() on the CRISPR data.

__annotations__ = {'adt_markers': typing.Optional[typing.Mapping], 'adt_pca': typing.Optional[scranpy.dimensionality_reduction.run_pca.PcaResult], 'adt_quality_control_filter': typing.Optional[numpy.ndarray], 'adt_quality_control_metrics': typing.Optional[biocframe.BiocFrame.BiocFrame], 'adt_quality_control_thresholds': typing.Optional[biocframe.BiocFrame.BiocFrame], 'adt_size_factors': typing.Optional[numpy.ndarray], 'clusters': typing.Optional[list], 'combined_pcs': typing.Optional[numpy.ndarray], 'crispr_markers': typing.Optional[typing.Mapping], 'crispr_pca': typing.Optional[scranpy.dimensionality_reduction.run_pca.PcaResult], 'crispr_quality_control_filter': typing.Optional[numpy.ndarray], 'crispr_quality_control_metrics': typing.Optional[biocframe.BiocFrame.BiocFrame], 'crispr_quality_control_thresholds': typing.Optional[biocframe.BiocFrame.BiocFrame], 'crispr_size_factors': typing.Optional[numpy.ndarray], 'gene_variances': typing.Optional[biocframe.BiocFrame.BiocFrame], 'hvgs': typing.Optional[numpy.ndarray], 'mnn': typing.Optional[scranpy.batch_correction.mnn_correct.MnnCorrectResult], 'quality_control_retained': typing.Optional[numpy.ndarray], 'rna_markers': typing.Optional[typing.Mapping], 'rna_pca': typing.Optional[scranpy.dimensionality_reduction.run_pca.PcaResult], 'rna_quality_control_filter': typing.Optional[numpy.ndarray], 'rna_quality_control_metrics': typing.Optional[biocframe.BiocFrame.BiocFrame], 'rna_quality_control_thresholds': typing.Optional[biocframe.BiocFrame.BiocFrame], 'rna_size_factors': typing.Optional[numpy.ndarray], 'snn_graph': typing.Optional[igraph.Graph], 'tsne': typing.Optional[scranpy.dimensionality_reduction.run_tsne.TsneEmbedding], 'umap': typing.Optional[scranpy.dimensionality_reduction.run_umap.UmapEmbedding]}#
__dataclass_fields__ = {'adt_markers': Field(name='adt_markers',type=typing.Optional[typing.Mapping],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_pca': Field(name='adt_pca',type=typing.Optional[scranpy.dimensionality_reduction.run_pca.PcaResult],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_quality_control_filter': Field(name='adt_quality_control_filter',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_quality_control_metrics': Field(name='adt_quality_control_metrics',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_quality_control_thresholds': Field(name='adt_quality_control_thresholds',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'adt_size_factors': Field(name='adt_size_factors',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'clusters': Field(name='clusters',type=typing.Optional[list],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'combined_pcs': Field(name='combined_pcs',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_markers': Field(name='crispr_markers',type=typing.Optional[typing.Mapping],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_pca': Field(name='crispr_pca',type=typing.Optional[scranpy.dimensionality_reduction.run_pca.PcaResult],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_quality_control_filter': Field(name='crispr_quality_control_filter',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_quality_control_metrics': Field(name='crispr_quality_control_metrics',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_quality_control_thresholds': Field(name='crispr_quality_control_thresholds',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'crispr_size_factors': Field(name='crispr_size_factors',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'gene_variances': Field(name='gene_variances',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'hvgs': Field(name='hvgs',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'mnn': Field(name='mnn',type=typing.Optional[scranpy.batch_correction.mnn_correct.MnnCorrectResult],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'quality_control_retained': Field(name='quality_control_retained',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_markers': Field(name='rna_markers',type=typing.Optional[typing.Mapping],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_pca': Field(name='rna_pca',type=typing.Optional[scranpy.dimensionality_reduction.run_pca.PcaResult],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_quality_control_filter': Field(name='rna_quality_control_filter',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_quality_control_metrics': Field(name='rna_quality_control_metrics',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_quality_control_thresholds': Field(name='rna_quality_control_thresholds',type=typing.Optional[biocframe.BiocFrame.BiocFrame],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'rna_size_factors': Field(name='rna_size_factors',type=typing.Optional[numpy.ndarray],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'snn_graph': Field(name='snn_graph',type=typing.Optional[igraph.Graph],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'tsne': Field(name='tsne',type=typing.Optional[scranpy.dimensionality_reduction.run_tsne.TsneEmbedding],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'umap': Field(name='umap',type=typing.Optional[scranpy.dimensionality_reduction.run_umap.UmapEmbedding],default=None,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}#
__dataclass_params__ = _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False)#
__eq__(other)#

Return self==value.

__hash__ = None#
__repr__()#

Return repr(self).

adt_markers: Optional[Mapping] = None#
adt_pca: Optional[PcaResult] = None#
adt_quality_control_filter: Optional[ndarray] = None#
adt_quality_control_metrics: Optional[BiocFrame] = None#
adt_quality_control_thresholds: Optional[BiocFrame] = None#
adt_size_factors: Optional[ndarray] = None#
clusters: Optional[list] = None#
combined_pcs: Optional[ndarray] = None#
crispr_markers: Optional[Mapping] = None#
crispr_pca: Optional[PcaResult] = None#
crispr_quality_control_filter: Optional[ndarray] = None#
crispr_quality_control_metrics: Optional[BiocFrame] = None#
crispr_quality_control_thresholds: Optional[BiocFrame] = None#
crispr_size_factors: Optional[ndarray] = None#
gene_variances: Optional[BiocFrame] = None#
hvgs: Optional[ndarray] = None#
mnn: Optional[MnnCorrectResult] = None#
quality_control_retained: Optional[ndarray] = None#
rna_markers: Optional[Mapping] = None#
rna_pca: Optional[PcaResult] = None#
rna_quality_control_filter: Optional[ndarray] = None#
rna_quality_control_metrics: Optional[BiocFrame] = None#
rna_quality_control_thresholds: Optional[BiocFrame] = None#
rna_size_factors: Optional[ndarray] = None#
snn_graph: Optional[Graph] = None#
to_sce(rna_matrix, rna_features, adt_matrix=None, adt_features=None, crispr_matrix=None, crispr_features=None)[source]#

Save results as a singlecellexperiment.SingleCellExperiment.

Parameters:
  • x – Input object. usually a matrix of raw counts.

  • assay – Assay name for the matrix. Defaults to “counts”.

Return type:

SingleCellExperiment

Returns:

An SCE with the results.

tsne: Optional[TsneEmbedding] = None#
umap: Optional[UmapEmbedding] = None#

scranpy.analyze.analyze module#

scranpy.analyze.analyze.analyze(rna_matrix, adt_matrix=None, crispr_matrix=None, options=AnalyzeOptions(per_cell_rna_qc_metrics_options=PerCellRnaQcMetricsOptions(subsets=None, assay_type=0, cell_names=None, num_threads=1), suggest_rna_qc_filters_options=SuggestRnaQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_rna_qc_filter_options=CreateRnaQcFilterOptions(block=None), per_cell_adt_qc_metrics_options=PerCellAdtQcMetricsOptions(subsets=None, assay_type=0, cell_names=None, num_threads=1), suggest_adt_qc_filters_options=SuggestAdtQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_adt_qc_filter_options=CreateAdtQcFilterOptions(block=None), per_cell_crispr_qc_metrics_options=PerCellCrisprQcMetricsOptions(assay_type=0, cell_names=None, num_threads=1), suggest_crispr_qc_filters_options=SuggestCrisprQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_crispr_qc_filter_options=CreateCrisprQcFilterOptions(block=None), filter_cells_options=FilterCellsOptions(discard=True, intersect=False, with_retain_vector=False, delayed=True), rna_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), grouped_size_factors_options=GroupedSizeFactorsOptions(rank=25, groups=None, block=None, initial_factors=None, assay_type=0, num_threads=1), adt_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), crispr_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), choose_hvgs_options=ChooseHvgsOptions(number=2500), model_gene_variances_options=ModelGeneVariancesOptions(block=None, span=0.3, assay_type='logcounts', feature_names=None, num_threads=1), rna_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), adt_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), crispr_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), combine_embeddings_options=CombineEmbeddingsOptions(neighbors=20, approximate=True, weights=None, num_threads=True), mnn_correct_options=MnnCorrectOptions(k=15, approximate=True, order=None, reference_policy='max-rss', num_mads=3, mass_cap=-1, num_threads=1), build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), run_tsne_options=RunTsneOptions(max_iterations=500, initialize_tsne=InitializeTsneOptions(perplexity=30, seed=42, num_threads=1)), run_umap_options=RunUmapOptions(initialize_umap=InitializeUmapOptions(min_dist=0.1, num_neighbors=15, num_epochs=500, seed=42, num_threads=1)), find_nearest_neighbors_options=FindNearestNeighborsOptions(num_threads=1), build_snn_graph_options=BuildSnnGraphOptions(num_neighbors=15, weight_scheme='ranked', build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), num_threads=1), rna_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), adt_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), crispr_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), miscellaneous_options=MiscellaneousOptions(cell_names=None, rna_feature_names=None, adt_feature_names=None, crispr_feature_names=None, filter_on_rna_qc=True, filter_on_adt_qc=True, filter_on_crispr_qc=True, snn_graph_multilevel_resolution=1, block=None)), dry_run=False)[source]#

Run a routine analysis workflow for single-cell datasets. This supports RNA-seq, ADT and CRISPR modalities for the same cells. Steps include:

  • Removal of low-quality cells

  • Normalization and log-transformation

  • Variance modelling across genes

  • PCA on highly variable genes

  • Combined embeddings across modalities

  • Batch correction with MNN

  • Graph-based clustering

  • Dimensionality reductions for visualization

  • Marker detection for each cluster

Parameters:
  • rna_matrix – Count matrix for RNA data. Alternatively None if no RNA data is available.

  • adt_matrix – Count matrix for the ADT data. Alternatively None if no ADT data is available.

  • crispr_matrix – Count matrix for the CRISPR data. Alternatively None if no CRISPR data is available.

  • options (AnalyzeOptions) – Optional analysis parameters.

  • dry_run (bool) – Whether to perform a dry run.

Raises:

NotImplementedError – If matrix is not an expected type.

Return type:

Union[AnalyzeResults, str]

Returns:

If dry_run = False, a AnalyzeResults object is returned containing… well, the analysis results, obviously.

If dry_run = True, a string is returned containing all the steps required to perform the analysis.

scranpy.analyze.analyze.analyze_sce(sce, rna_exp='', adt_exp=None, crispr_exp=None, assay_type='counts', options=AnalyzeOptions(per_cell_rna_qc_metrics_options=PerCellRnaQcMetricsOptions(subsets=None, assay_type=0, cell_names=None, num_threads=1), suggest_rna_qc_filters_options=SuggestRnaQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_rna_qc_filter_options=CreateRnaQcFilterOptions(block=None), per_cell_adt_qc_metrics_options=PerCellAdtQcMetricsOptions(subsets=None, assay_type=0, cell_names=None, num_threads=1), suggest_adt_qc_filters_options=SuggestAdtQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_adt_qc_filter_options=CreateAdtQcFilterOptions(block=None), per_cell_crispr_qc_metrics_options=PerCellCrisprQcMetricsOptions(assay_type=0, cell_names=None, num_threads=1), suggest_crispr_qc_filters_options=SuggestCrisprQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_crispr_qc_filter_options=CreateCrisprQcFilterOptions(block=None), filter_cells_options=FilterCellsOptions(discard=True, intersect=False, with_retain_vector=False, delayed=True), rna_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), grouped_size_factors_options=GroupedSizeFactorsOptions(rank=25, groups=None, block=None, initial_factors=None, assay_type=0, num_threads=1), adt_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), crispr_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), choose_hvgs_options=ChooseHvgsOptions(number=2500), model_gene_variances_options=ModelGeneVariancesOptions(block=None, span=0.3, assay_type='logcounts', feature_names=None, num_threads=1), rna_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), adt_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), crispr_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), combine_embeddings_options=CombineEmbeddingsOptions(neighbors=20, approximate=True, weights=None, num_threads=True), mnn_correct_options=MnnCorrectOptions(k=15, approximate=True, order=None, reference_policy='max-rss', num_mads=3, mass_cap=-1, num_threads=1), build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), run_tsne_options=RunTsneOptions(max_iterations=500, initialize_tsne=InitializeTsneOptions(perplexity=30, seed=42, num_threads=1)), run_umap_options=RunUmapOptions(initialize_umap=InitializeUmapOptions(min_dist=0.1, num_neighbors=15, num_epochs=500, seed=42, num_threads=1)), find_nearest_neighbors_options=FindNearestNeighborsOptions(num_threads=1), build_snn_graph_options=BuildSnnGraphOptions(num_neighbors=15, weight_scheme='ranked', build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), num_threads=1), rna_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), adt_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), crispr_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), miscellaneous_options=MiscellaneousOptions(cell_names=None, rna_feature_names=None, adt_feature_names=None, crispr_feature_names=None, filter_on_rna_qc=True, filter_on_adt_qc=True, filter_on_crispr_qc=True, snn_graph_multilevel_resolution=1, block=None)), dry_run=False)[source]#

Convenience wrapper around analyze() for SingleCellExperiment inputs.

Parameters:
  • sce (SingleCellExperiment) – A singlecellexperiment.SingleCellExperiment object, possibly with data from other modalities in its alternative experiments.

  • rna_exp (Union[str, int, None]) – String or index specifying the alternative experiment containing the RNA data. An empty string is assumed to refer to the main experiment. If None, we assume that no RNA data is available.

  • adt_exp (Union[str, int, None]) – String or index specifying the alternative experiment containing the ADT data. An empty string is assumed to refer to the main experiment. If None, we assume that no RNA data is available.

  • crispr_exp (Union[str, int, None]) – String or index specifying the alternative experiment containing the CRISPR data. An empty string is assumed to refer to the main experiment. If None, we assume that no RNA data is available.

  • assay_type (str) – Assay containing the count data in each SummarizedExperiment.

  • options (AnalyzeOptions) – Optional analysis parameters.

  • dry_run (bool) – Whether to perform a dry run.

Raises:

ValueError – If SCE does not contain a assay matrix.

Return type:

Union[AnalyzeResults, str]

Returns:

If dry_run = False, a AnalyzeResults object is returned containing… well, the analysis results, obviously.

If dry_run = True, a string is returned containing all the steps required to perform the analysis.

scranpy.analyze.analyze.analyze_se(rna_se, adt_se=None, crispr_se=None, assay_type=0, options=AnalyzeOptions(per_cell_rna_qc_metrics_options=PerCellRnaQcMetricsOptions(subsets=None, assay_type=0, cell_names=None, num_threads=1), suggest_rna_qc_filters_options=SuggestRnaQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_rna_qc_filter_options=CreateRnaQcFilterOptions(block=None), per_cell_adt_qc_metrics_options=PerCellAdtQcMetricsOptions(subsets=None, assay_type=0, cell_names=None, num_threads=1), suggest_adt_qc_filters_options=SuggestAdtQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_adt_qc_filter_options=CreateAdtQcFilterOptions(block=None), per_cell_crispr_qc_metrics_options=PerCellCrisprQcMetricsOptions(assay_type=0, cell_names=None, num_threads=1), suggest_crispr_qc_filters_options=SuggestCrisprQcFiltersOptions(block=None, num_mads=3, custom_thresholds=None), create_crispr_qc_filter_options=CreateCrisprQcFilterOptions(block=None), filter_cells_options=FilterCellsOptions(discard=True, intersect=False, with_retain_vector=False, delayed=True), rna_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), grouped_size_factors_options=GroupedSizeFactorsOptions(rank=25, groups=None, block=None, initial_factors=None, assay_type=0, num_threads=1), adt_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), crispr_log_norm_counts_options=LogNormCountsOptions(block=None, size_factors=None, center=True, center_size_factors_options=CenterSizeFactorsOptions(block=None, in_place=False, allow_zeros=False, allow_non_finite=False), delayed=True, with_size_factors=False, assay_type=0, num_threads=1), choose_hvgs_options=ChooseHvgsOptions(number=2500), model_gene_variances_options=ModelGeneVariancesOptions(block=None, span=0.3, assay_type='logcounts', feature_names=None, num_threads=1), rna_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), adt_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), crispr_run_pca_options=RunPcaOptions(rank=25, subset=None, block=None, scale=False, block_method='project', block_weights=True, num_threads=1, assay_type='logcounts'), combine_embeddings_options=CombineEmbeddingsOptions(neighbors=20, approximate=True, weights=None, num_threads=True), mnn_correct_options=MnnCorrectOptions(k=15, approximate=True, order=None, reference_policy='max-rss', num_mads=3, mass_cap=-1, num_threads=1), build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), run_tsne_options=RunTsneOptions(max_iterations=500, initialize_tsne=InitializeTsneOptions(perplexity=30, seed=42, num_threads=1)), run_umap_options=RunUmapOptions(initialize_umap=InitializeUmapOptions(min_dist=0.1, num_neighbors=15, num_epochs=500, seed=42, num_threads=1)), find_nearest_neighbors_options=FindNearestNeighborsOptions(num_threads=1), build_snn_graph_options=BuildSnnGraphOptions(num_neighbors=15, weight_scheme='ranked', build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), num_threads=1), rna_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), adt_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), crispr_score_markers_options=ScoreMarkersOptions(block=None, threshold=0, compute_auc=True, assay_type='logcounts', feature_names=None, num_threads=1), miscellaneous_options=MiscellaneousOptions(cell_names=None, rna_feature_names=None, adt_feature_names=None, crispr_feature_names=None, filter_on_rna_qc=True, filter_on_adt_qc=True, filter_on_crispr_qc=True, snn_graph_multilevel_resolution=1, block=None)), dry_run=False)[source]#

Convenience wrapper around analyze() for SummarizedExperiment inputs.

Parameters:
  • rna_se (Optional[SummarizedExperiment]) – SummarizedExperiment containing RNA data. Alternatively None if no RNA data is available.

  • adt_se (Optional[SummarizedExperiment]) – SummarizedExperiment containing ADT data. Alternatively None if no ADT data is available.

  • crispr_se (Optional[SummarizedExperiment]) – SummarizedExperiment containing CRISPR data. Alternatively None if no CRISPR data is available.

  • assay_type (Union[str, int]) – Assay containing the count data in each SummarizedExperiment.

  • options (AnalyzeOptions) – Optional analysis parameters.

  • dry_run (bool) – Whether to perform a dry run.

Raises:

NotImplementedError – If matrix is not an expected type.

Return type:

Union[AnalyzeResults, str]

Returns:

If dry_run = False, a AnalyzeResults object is returned containing… well, the analysis results, obviously.

If dry_run = True, a string is returned containing all the steps required to perform the analysis.

scranpy.analyze.dry_analyze module#

scranpy.analyze.dry_analyze.dry_analyze(rna_matrix, adt_matrix, crispr_matrix, options)[source]#
Return type:

str

scranpy.analyze.live_analyze module#

scranpy.analyze.live_analyze.live_analyze(rna_matrix, adt_matrix, crispr_matrix, options)[source]#

scranpy.analyze.run_neighbor_suite module#

scranpy.analyze.run_neighbor_suite.run_neighbor_suite(principal_components, build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), find_nearest_neighbors_options=FindNearestNeighborsOptions(num_threads=1), run_umap_options=RunUmapOptions(initialize_umap=InitializeUmapOptions(min_dist=0.1, num_neighbors=15, num_epochs=500, seed=42, num_threads=1)), run_tsne_options=RunTsneOptions(max_iterations=500, initialize_tsne=InitializeTsneOptions(perplexity=30, seed=42, num_threads=1)), build_snn_graph_options=BuildSnnGraphOptions(num_neighbors=15, weight_scheme='ranked', build_neighbor_index_options=BuildNeighborIndexOptions(approximate=True), num_threads=1), num_threads=1)[source]#

Run the suite of nearest neighbor methods together. This builds the index once and re-uses it for all methods. Given enough threads, it also runs all post-neighbor-detection functions in parallel, as none of them depend on each other.

Parameters:
Returns:

  • A function that takes no arguments and returns a tuple containing the t-SNE and UMAP coordinates.

  • The shared nearest neighbor graph from build_snn_graph().

  • The number of remaining threads.

The idea is that the number of remaining threads can be used to perform tasks on the main thread (e.g., clustering, marker detection) while the t-SNE and UMAP are still being computed; once all tasks on the main thread have completed, the first function can be called to obtain the coordinates.

Return type:

A tuple containing, in order

scranpy.analyze.update module#

scranpy.analyze.update.update(options, **kwargs)[source]#

Convenience function to update the settings on an *Options object.

Parameters:
  • options – Any of the *Options object.

  • kwargs – Key-value pairs of settings to replace.

Results:

A copy of options with replaced settings. Note that the input options itself is unchanged.

Module contents#