mypackage.MyModel.setup_anndata

classmethod MyModel.setup_anndata(adata, batch_key=None, labels_key=None, layer=None, categorical_covariate_keys=None, continuous_covariate_keys=None, **kwargs)[source]
Sets up the AnnData object for this model.

A mapping will be created between data fields used by this model to their respective locations in adata.

None of the data in adata are modified. Only adds fields to adata.

Parameters
adata : AnnData

AnnData object containing raw counts. Rows represent cells, columns represent features.

batch_key : str | NoneOptional[str] (default: None)

key in adata.obs for batch information. Categories will automatically be converted into integer categories and saved to adata.obs[‘_scvi_batch’]. If None, assigns the same batch to all the data.

labels_key : str | NoneOptional[str] (default: None)

key in adata.obs for label information. Categories will automatically be converted into integer categories and saved to adata.obs[‘_scvi_labels’]. If None, assigns the same label to all the data.

layer : str | NoneOptional[str] (default: None)

if not None, uses this as the key in adata.layers for raw count data.

categorical_covariate_keys : List[str] | NoneOptional[List[str]] (default: None)

keys in adata.obs that correspond to categorical data.

continuous_covariate_keys : List[str] | NoneOptional[List[str]] (default: None)

keys in adata.obs that correspond to continuous data.

Return type

AnnData | NoneOptional[AnnData]

Returns

If copy, will return AnnData. Adds the following fields to adata:

.uns[‘_scvi’]

scvi setup dictionary

.obs[‘_scvi_labels’]

labels encoded as integers

.obs[‘_scvi_batch’]

batch encoded as integers