static TOTALVI.setup_anndata(adata, protein_expression_obsm_key, protein_names_uns_key=None, batch_key=None, layer=None, categorical_covariate_keys=None, continuous_covariate_keys=None, copy=False)[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.

adata : AnnDataAnnData

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

protein_expression_obsm_key : strstr

key in adata.obsm for protein expression data.

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

key in adata.uns for protein names. If None, will use the column names of adata.obsm[protein_expression_obsm_key] if it is a DataFrame, else will assign sequential names to proteins.

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.

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.

copy : boolbool (default: False)

if True, a copy of adata is returned.

Return type

AnnData | NoneOptional[AnnData]


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


scvi setup dictionary


labels encoded as integers


batch encoded as integers