scvi.module.MULTIVAE#

class scvi.module.MULTIVAE(n_input_regions=0, n_input_genes=0, n_input_proteins=0, modality_weights='equal', modality_penalty='Jeffreys', n_batch=0, n_obs=0, n_labels=0, gene_likelihood='zinb', gene_dispersion='gene', n_hidden=None, n_latent=None, n_layers_encoder=2, n_layers_decoder=2, n_continuous_cov=0, n_cats_per_cov=None, dropout_rate=0.1, region_factors=True, use_batch_norm='none', use_layer_norm='both', latent_distribution='normal', deeply_inject_covariates=False, encode_covariates=False, use_size_factor_key=False, protein_background_prior_mean=None, protein_background_prior_scale=None, protein_dispersion='protein', extra_payload_autotune=False)[source]#

Bases: BaseMinifiedModeModuleClass

Variational auto-encoder model for joint paired + unpaired RNA-seq and ATAC-seq data.

Parameters:
n_input_regions int (default: 0)

Number of input regions.

n_input_genes int (default: 0)

Number of input genes.

n_input_proteins int (default: 0)

Number of input proteins

modality_weights Literal['equal', 'cell', 'universal'] (default: 'equal')

Weighting scheme across modalities. One of the following: * "equal": Equal weight in each modality * "universal": Learn weights across modalities w_m. * "cell": Learn weights across modalities and cells. w_{m,c}

modality_penalty Literal['Jeffreys', 'MMD', 'None'] (default: 'Jeffreys')

Training Penalty across modalities. One of the following: * "Jeffreys": Jeffreys penalty to align modalities * "MMD": MMD penalty to align modalities * "None": No penalty

n_batch int (default: 0)

Number of batches, if 0, no batch correction is performed.

gene_likelihood Literal['zinb', 'nb', 'poisson'] (default: 'zinb')

The distribution to use for gene expression data. One of the following * 'zinb' - Zero-Inflated Negative Binomial * 'nb' - Negative Binomial * 'poisson' - Poisson

gene_dispersion 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

protein_dispersion str (default: 'protein')

One of the following:

  • 'protein' - protein_dispersion parameter is constant per protein across cells

  • 'protein-batch' - protein_dispersion can differ between different batches NOT TESTED

  • 'protein-label' - protein_dispersion can differ between different labels NOT TESTED

n_hidden int (default: None)

Number of nodes per hidden layer. If None, defaults to square root of number of regions.

n_latent int (default: None)

Dimensionality of the latent space. If None, defaults to square root of n_hidden.

n_layers_encoder int (default: 2)

Number of hidden layers used for encoder NN.

n_layers_decoder int (default: 2)

Number of hidden layers used for decoder NN.

dropout_rate float (default: 0.1)

Dropout rate for neural networks

region_factors bool (default: True)

Include region-specific factors in the model

use_batch_norm Literal['encoder', 'decoder', 'none', 'both'] (default: 'none')

One of the following * 'encoder' - use batch normalization in the encoder only * 'decoder' - use batch normalization in the decoder only * 'none' - do not use batch normalization * 'both' - use batch normalization in both the encoder and decoder

use_layer_norm Literal['encoder', 'decoder', 'none', 'both'] (default: 'both')

One of the following * 'encoder' - use layer normalization in the encoder only * 'decoder' - use layer normalization in the decoder only * 'none' - do not use layer normalization * 'both' - use layer normalization in both the encoder and decoder

latent_distribution Literal['normal', 'ln'] (default: 'normal')

which latent distribution to use, options are * 'normal' - Normal distribution * 'ln' - Logistic normal distribution (Normal(0, I) transformed by softmax)

deeply_inject_covariates bool (default: False)

Whether to deeply inject covariates into all layers of the decoder. If False, covariates will only be included in the input layer.

encode_covariates bool (default: False)

If True, include covariates in the input to the encoder.

use_size_factor_key bool (default: False)

Use size_factor AnnDataField defined by the user as scaling factor in mean of conditional RNA distribution.

protein_background_prior_mean ndarray | None (default: None)

Array of proteins by batches, the prior initialization for the protein background mean (log scale)

protein_background_prior_scale ndarray | None (default: None)

Array of proteins by batches, the prior initialization for the protein background scale (log scale)

protein_dispersion

One of the following

  • 'protein' - protein_dispersion parameter is constant per protein across cells

  • 'protein-batch' - protein_dispersion can differ between different batches NOT TESTED

  • 'protein-label' - protein_dispersion can differ between different labels NOT TESTED

extra_payload_autotune bool (default: False)

If True, will return extra matrices in the loss output to be used during autotune

Attributes table#

Methods table#

generative(z, qz_m, batch_index[, ...])

Runs the generative model.

get_reconstruction_loss_accessibility(x, p, d)

Computes the reconstruction loss for the accessibility data.

get_reconstruction_loss_expression(x, ...)

Computes the reconstruction loss for the expression data.

inference(x, y, batch_index, cont_covs, ...)

Run the inference model.

loss(tensors, inference_outputs, ...[, ...])

Computes the loss function for the model.

Attributes#

MULTIVAE.training: bool#

Methods#

MULTIVAE.generative(z, qz_m, batch_index, cont_covs=None, cat_covs=None, libsize_expr=None, use_z_mean=False, label=None, transform_batch=None)[source]#

Runs the generative model.

MULTIVAE.get_reconstruction_loss_accessibility(x, p, d)[source]#

Computes the reconstruction loss for the accessibility data.

MULTIVAE.get_reconstruction_loss_expression(x, px_rate, px_r, px_dropout)[source]#

Computes the reconstruction loss for the expression data.

MULTIVAE.inference(x, y, batch_index, cont_covs, cat_covs, label, cell_idx, size_factor, n_samples=1)[source]#

Run the inference model.

Return type:

dict[str, Tensor]

MULTIVAE.loss(tensors, inference_outputs, generative_outputs, kl_weight=1.0)[source]#

Computes the loss function for the model.