scvi.model.AUTOZI

class scvi.model.AUTOZI(adata, n_hidden=128, n_latent=10, n_layers=1, dropout_rate=0.1, dispersion='gene', latent_distribution='normal', alpha_prior=0.5, beta_prior=0.5, minimal_dropout=0.01, zero_inflation='gene', **model_kwargs)[source]

Automatic identification of ZI genes [Clivio19].

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: 10)

Dimensionality of the latent space

n_layers : intint (default: 1)

Number of hidden layers used for encoder NN

dropout_rate : floatfloat (default: 0.1)

Dropout rate for neural networks

dispersion : {‘gene’, ‘gene-batch’, ‘gene-label’, ‘gene-cell’}Literal[‘gene’, ‘gene-batch’, ‘gene-label’, ‘gene-cell’] (default: 'gene')

One of the following

  • 'gene' - dispersion parameter of NB is constant per gene across cells

  • 'gene-batch' - dispersion can differ between different batches

  • 'gene-label' - dispersion can differ between different labels

  • 'gene-cell' - dispersion can differ for every gene in every cell

latent_distribution : {‘normal’, ‘ln’}Literal[‘normal’, ‘ln’] (default: 'normal')

One of

  • 'normal' - Normal distribution

  • 'ln' - Logistic normal distribution (Normal(0, I) transformed by softmax)

alpha_prior : float | NoneOptional[float] (default: 0.5)

Float denoting the alpha parameter of the prior Beta distribution of the zero-inflation Bernoulli parameter. Should be between 0 and 1, not included. When set to ``None’’, will be set to 1 - beta_prior if beta_prior is not ``None’’, otherwise the prior Beta distribution will be learned on an Empirical Bayes fashion.

beta_prior : float | NoneOptional[float] (default: 0.5)

Float denoting the beta parameter of the prior Beta distribution of the zero-inflation Bernoulli parameter. Should be between 0 and 1, not included. When set to ``None’’, will be set to 1 - alpha_prior if alpha_prior is not ``None’’, otherwise the prior Beta distribution will be learned on an Empirical Bayes fashion.

minimal_dropout : floatfloat (default: 0.01)

Float denoting the lower bound of the cell-gene ZI rate in the ZINB component. Must be non-negative. Can be set to 0 but not recommended as this may make the mixture problem ill-defined.

zero_inflation : One of the following

  • 'gene' - zero-inflation Bernoulli parameter of AutoZI is constant per gene across cells

  • 'gene-batch' - zero-inflation Bernoulli parameter can differ between different batches

  • 'gene-label' - zero-inflation Bernoulli parameter can differ between different labels

  • 'gene-cell' - zero-inflation Bernoulli parameter can differ for every gene in every cell

**model_kwargs

Keyword args for AutoZIVAE

Examples

>>> adata = anndata.read_h5ad(path_to_anndata)
>>> scvi.data.setup_anndata(adata, batch_key="batch")
>>> vae = scvi.model.AutoZIVAE(adata)
>>> vae.train(n_epochs=400)

Notes

See further usage examples in the following tutorials:

  1. Identification of zero-inflated genes

Attributes

device

history

Returns computed metrics during training.

is_trained

test_indices

train_indices

validation_indices

Methods

get_alphas_betas([as_numpy])

Return parameters of Bernoulli Beta distributions in a dictionary.

get_elbo([adata, indices, batch_size])

Return the ELBO for the data.

get_latent_representation([adata, indices, …])

Return the latent representation for each cell.

get_marginal_ll([adata, indices, …])

Return the marginal LL for the data.

get_reconstruction_error([adata, indices, …])

Return the reconstruction error for the data.

load(dir_path[, adata, use_gpu])

Instantiate a model from the saved output.

save(dir_path[, overwrite, save_anndata])

Save the state of the model.

to_device(device)

Move model to device.

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

Train the model.