scvi.model.CondSCVI

class scvi.model.CondSCVI(adata, n_hidden=128, n_latent=5, n_layers=2, dropout_rate=0.1, weight_obs=False, **module_kwargs)[source]

Conditional version of single-cell Variational Inference, used for multi-resolution deconvolution of spatial transcriptomics data [Lopez21].

Parameters
adata : AnnDataAnnData

AnnData object that has been registered via setup_anndata().

n_hidden : intint (default: 128)

Number of nodes per hidden layer.

n_latent : intint (default: 5)

Dimensionality of the latent space.

n_layers : intint (default: 2)

Number of hidden layers used for encoder and decoder NNs.

dropout_rate : floatfloat (default: 0.1)

Dropout rate for the encoder neural networks.

weight_obs : boolbool (default: False)

Whether to reweight observations by their inverse proportion (useful for lowly abundant cell types)

**module_kwargs

Keyword args for VAEC

Examples

>>> adata = anndata.read_h5ad(path_to_anndata)
>>> scvi.data.setup_anndata(adata, batch_key="batch")
>>> vae = scvi.external.CondSCVI(adata)
>>> vae.train()
>>> adata.obsm["X_CondSCVI"] = vae.get_latent_representation()

Attributes

device

history

Returns computed metrics during training.

is_trained

test_indices

train_indices

validation_indices

Methods

differential_expression([adata, groupby, …])

A unified method for differential expression analysis.

get_elbo([adata, indices, batch_size])

Return the ELBO for the data.

get_feature_correlation_matrix([adata, …])

Generate gene-gene correlation matrix using scvi uncertainty and expression.

get_latent_library_size([adata, indices, …])

Returns the latent library size for each cell.

get_latent_representation([adata, indices, …])

Return the latent representation for each cell.

get_likelihood_parameters([adata, indices, …])

Estimates for the parameters of the likelihood \(p(x \mid z)\)

get_marginal_ll([adata, indices, …])

Return the marginal LL for the data.

get_normalized_expression([adata, indices, …])

Returns the normalized (decoded) gene expression.

get_reconstruction_error([adata, indices, …])

Return the reconstruction error for the data.

get_vamp_prior([adata, p])

Return an empirical prior over the cell-type specific latent space (vamp prior) that may be used for deconvolution.

load(dir_path[, adata, use_gpu])

Instantiate a model from the saved output.

posterior_predictive_sample([adata, …])

Generate observation samples from the posterior predictive distribution.

save(dir_path[, overwrite, save_anndata])

Save the state of the model.

to_device(device)

Move model to device.

train([max_epochs, lr, use_gpu, train_size, …])

Trains the model using MAP inference.