SCVI.get_normalized_expression(adata=None, indices=None, transform_batch=None, gene_list=None, library_size=1, n_samples=1, n_samples_overall=None, batch_size=None, return_mean=True, return_numpy=None)

Returns the normalized (decoded) gene expression.

This is denoted as \(\rho_n\) in the scVI paper.

adata : AnnData | NoneOptional[AnnData] (default: None)

AnnData object with equivalent structure to initial AnnData. If None, defaults to the AnnData object used to initialize the model.

indices : Sequence[int] | NoneOptional[Sequence[int]] (default: None)

Indices of cells in adata to use. If None, all cells are used.

transform_batch : Sequence[Union[int, float, str]] | NoneOptional[Sequence[Union[int, float, str]]] (default: None)

Batch to condition on. If transform_batch is:

  • None, then real observed batch is used.

  • int, then batch transform_batch is used.

gene_list : Sequence[str] | NoneOptional[Sequence[str]] (default: None)

Return frequencies of expression for a subset of genes. This can save memory when working with large datasets and few genes are of interest.

library_size : float | {‘latent’}Union[float, Literal[‘latent’]] (default: 1)

Scale the expression frequencies to a common library size. This allows gene expression levels to be interpreted on a common scale of relevant magnitude. If set to “latent”, use the latent libary size.

n_samples : intint (default: 1)

Number of posterior samples to use for estimation.

batch_size : int | NoneOptional[int] (default: None)

Minibatch size for data loading into model. Defaults to scvi.settings.batch_size.

return_mean : boolbool (default: True)

Whether to return the mean of the samples.

return_numpy : bool | NoneOptional[bool] (default: None)

Return a ndarray instead of a DataFrame. DataFrame includes gene names as columns. If either n_samples=1 or return_mean=True, defaults to False. Otherwise, it defaults to True.

Return type

ndarray | DataFrameUnion[ndarray, DataFrame]


If n_samples > 1 and return_mean is False, then the shape is (samples, cells, genes). Otherwise, shape is (cells, genes). In this case, return type is DataFrame unless return_numpy is True.