sccoda.util.cell_composition_data.from_scanpy

sccoda.util.cell_composition_data.from_scanpy(adata, cell_type_identifier, sample_identifier, covariate_key=None, covariate_df=None)

Creates a compositional analysis dataset from a single anndata object, as it is produced by e.g. scanpy.

The anndata object needs to have a column in adata.obs that contains the cell type assignment, and one column that specifies the grouping into samples. Covariates can either be specified via a key in adata.uns, or as a separate DataFrame.

NOTE: The order of samples in the returned dataset is determined by the first occurence of cells from each sample in adata

Parameters
adata : AnnDataAnnData

list of scanpy data sets

cell_type_identifier : strstr

column name in adata.obs that specifies the cell types

sample_identifier : strstr

column name in adata.obs that specifies the sample

covariate_key : str, NoneOptional[str] (default: None)

key for adata.uns, where covariate values are stored

covariate_df : DataFrame, NoneOptional[DataFrame] (default: None)

DataFrame with covariates

Return type

AnnDataAnnData

Returns

  • A compositional analysis data set

  • data – A compositional analysis data set