SCANVI¶
-
class
scvi.models.
SCANVI
(n_input, n_batch=0, n_labels=0, n_hidden=128, n_latent=10, n_layers=1, dropout_rate=0.1, dispersion='gene', log_variational=True, reconstruction_loss='zinb', y_prior=None, labels_groups=None, use_labels_groups=False, classifier_parameters={})[source]¶ Bases:
scvi.models.vae.VAE
Single-cell annotation using variational inference.
This is an implementation of the scANVI model descibed in [Xu19], inspired from M1 + M2 model, as described in (https://arxiv.org/pdf/1406.5298.pdf).
- Parameters
n_layers (
int
int
) – Number of hidden layers used for encoder and decoder NNsdropout_rate (
float
float
) – Dropout rate for neural networksOne 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
log_variational (
bool
bool
) – Log(data+1) prior to encoding for numerical stability. Not normalization.reconstruction_loss (
str
str
) –One of
'nb'
- Negative binomial distribution'zinb'
- Zero-inflated negative binomial distribution
y_prior – If None, initialized to uniform probability over cell types
labels_groups (
Sequence
[int
],None
Optional
[Sequence
[int
]]) – Label group designationsuse_labels_groups (
bool
bool
) – Whether to use the label groups
- Returns
Examples
>>> gene_dataset = CortexDataset() >>> scanvi = SCANVI(gene_dataset.nb_genes, n_batch=gene_dataset.n_batches * False, ... n_labels=gene_dataset.n_labels)
>>> gene_dataset = SyntheticDataset(n_labels=3) >>> scanvi = SCANVI(gene_dataset.nb_genes, n_batch=gene_dataset.n_batches * False, ... n_labels=3, y_prior=torch.tensor([[0.1,0.5,0.4]]), labels_groups=[0,0,1])
Methods Summary
classify
(x)forward
(x, local_l_mean, local_l_var[, …])Returns the reconstruction loss and the KL divergences
get_latents
(x[, y])Returns the result of
sample_from_posterior_z
inside a listMethods Documentation
-
forward
(x, local_l_mean, local_l_var, batch_index=None, y=None)[source]¶ Returns the reconstruction loss and the KL divergences
- Parameters
x – tensor of values with shape (batch_size, n_input)
local_l_mean – tensor of means of the prior distribution of latent variable l with shape (batch_size, 1)
local_l_var – tensor of variancess of the prior distribution of latent variable l with shape (batch_size, 1)
batch_index – array that indicates which batch the cells belong to with shape
batch_size
(Default value = None)y – tensor of cell-types labels with shape (batch_size, n_labels) (Default value = None)
- Returns
type the reconstruction loss and the Kullback divergences