scvi.external.resolvi.RESOLVAE#

class scvi.external.resolvi.RESOLVAE(n_input, n_obs, n_neighbors, expression_anntorchdata, n_batch=0, n_hidden=32, n_hidden_encoder=128, n_latent=10, mixture_k=30, n_layers=2, n_cats_per_cov=None, n_labels=None, dropout_rate=0.05, dispersion='gene', gene_likelihood='nb', semisupervised=False, encode_covariates=False, deeply_inject_covariates=True, use_batch_norm='none', use_layer_norm='both', var_activation=None, classifier_parameters=None, prior_true_amount=1.0, prior_diffusion_amount=0.3, sparsity_diffusion=3.0, background_ratio=0.1, prior_proportions_rate=10.0, median_distance=1.0, downsample_counts_mean=None, downsample_counts_std=1.0, diffusion_eps=0.01, latent_distribution=None)[source]#

Bases: PyroBaseModuleClass

Implementation of resolVI.

Parameters:
  • n_input (int) – Number of input genes

  • n_obs (int) – Number of total input cells

  • n_neighbors (int) – Number of spatial neighbors to consider for diffusion.

  • expression_anntorchdata (AnnTorchDataset) – AnnTorchDataset with expression data.

  • n_batch (int (default: 0)) – Number of batches, if 0, no batch correction is performed.

  • n_hidden (int (default: 32)) – Number of nodes per hidden layer in the decoder

  • n_hidden_encoder (int (default: 128)) – Number of nodes per hidden layer in the encoder

  • n_latent (int (default: 10)) – Dimensionality of the latent space

  • mixture_k (int (default: 30)) – Number of components in the Mixture-of-Gaussian prior

  • n_layers (int (default: 2)) – Number of hidden layers used for encoder and decoder NNs

  • n_cats_per_cov (Iterable[int] | None (default: None)) – Number of categories for each extra categorical covariate

  • n_labels (Iterable[int] | None (default: None)) – Number of cell-type labels in the dataset

  • dropout_rate (float (default: 0.05)) – Dropout rate for neural networks

  • dispersion (Literal['gene', 'gene-batch'] (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_likelihood (Literal['nb', 'poisson'] (default: 'nb')) – One of * 'nb' - Negative binomial distribution * 'poisson' - Poisson distribution

  • semi_supervised – Whether to use a semi-supervised model

  • encode_covariates (bool (default: False)) – Whether to concatenate covariates to expression in encoder

  • deeply_inject_covariates (bool (default: True)) – Whether to concatenate covariates into output of hidden layers in encoder/decoder. This option only applies when n_layers > 1. The covariates are concatenated to the input of subsequent hidden layers.

  • use_batch_norm (Literal['encoder', 'decoder', 'none', 'both'] (default: 'none')) – Whether to use batch norm in layers

  • use_layer_norm (Literal['encoder', 'decoder', 'none', 'both'] (default: 'both')) – Whether to use layer norm in layers

  • var_activation (Callable | None (default: None)) – Callable used to ensure positivity of the variational distributions’ variance. When None, defaults to torch.exp.

  • classifier_parameters (dict | None (default: None)) – Parameters for the classifier

  • prior_true_amount (float (default: 1.0)) – Prior for true_proportion. Equals Gamma(prior_proportions_rate, prior_proportions_rate/prior_true_amount) Default is 1.0

  • prior_diffusion_amount (float (default: 0.3)) – Prior for diffusion_proportion. Equals Gamma(prior_proportions_rate, prior_proportions_rate/prior_diffusion_amount) Default is 0.3

  • sparsity_diffusion (float (default: 3.0)) – Prior for sparsity_diffusion. Controls the concentration of the Dirichlet distribution. Equals Gamma(prior_proportions_rate, prior_proportions_rate/sparsity_diffusion) Default is 3.0

  • background_ratio (float (default: 0.1)) –

    Prior for background_proportion Equals Gamma(prior_proportions_rate,

    prior_proportions_rate/(10*background_ratio*prior_true_amount))

    Default is 0.1

  • prior_proportions_rate (float (default: 10.0)) – Rate parameter for the prior proportions.

  • median_distance (float (default: 1.0)) – Kernel size in the RBF kernel to estimate distances between cells and neighbors.

  • downsample_counts_mean (float | None (default: None)) – Mean of the log-normal distribution used to downsample counts.

  • downsample_counts_std (float (default: 1.0)) – Standard deviation of the log-normal distribution used to downsample counts.

  • diffusion_eps (float (default: 0.01)) – Epsilon value for diffusion. Creates an offset to stabilize training.

  • encode_covariates – Whether to concatenate covariates to expression in encoder

  • latent_distribution (str | None (default: None)) – Placeholder for compatibility with other models.

Attributes table#

Methods table#

Attributes#

RESOLVAE.guide[source]#
RESOLVAE.guide_simplified[source]#
RESOLVAE.list_obs_plate_vars[source]#

Simplified plates adopted from Cell2location.

  1. “name” - the name of observation/minibatch plate;

  2. “event_dim” - the number of event dimensions.

RESOLVAE.model[source]#
RESOLVAE.model_corrected[source]#
RESOLVAE.model_residuals[source]#
RESOLVAE.model_simplified[source]#
RESOLVAE.model_unconditioned[source]#
RESOLVAE.training: bool#

Methods#