scvi.module.LDVAE#
- class scvi.module.LDVAE(n_input, n_batch=0, n_labels=0, n_hidden=128, n_latent=10, n_layers_encoder=1, dropout_rate=0.1, dispersion='gene', log_variational=True, gene_likelihood='nb', use_batch_norm=True, bias=False, latent_distribution='normal', **vae_kwargs)[source]#
Bases:
scvi.module._vae.VAE
Linear-decoded Variational auto-encoder model.
Implementation of [Svensson20].
This model uses a linear decoder, directly mapping the latent representation to gene expression levels. It still uses a deep neural network to encode the latent representation.
Compared to standard VAE, this model is less powerful, but can be used to inspect which genes contribute to variation in the dataset. It may also be used for all scVI tasks, like differential expression, batch correction, imputation, etc. However, batch correction may be less powerful as it assumes a linear model.
- Parameters
- n_input :
int
Number of input genes
- n_batch :
int
(default:0
) Number of batches
- n_labels :
int
(default:0
) Number of labels
- n_hidden :
int
(default:128
) Number of nodes per hidden layer (for encoder)
- n_latent :
int
(default:10
) Dimensionality of the latent space
- n_layers_encoder :
int
(default:1
) Number of hidden layers used for encoder NNs
- dropout_rate :
float
(default:0.1
) Dropout rate for neural networks
- dispersion :
str
(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
- log_variational :
bool
(default:True
) Log(data+1) prior to encoding for numerical stability. Not normalization.
- gene_likelihood :
str
(default:'nb'
) One of
'nb'
- Negative binomial distribution'zinb'
- Zero-inflated negative binomial distribution
- use_batch_norm :
bool
(default:True
) Bool whether to use batch norm in decoder
- bias :
bool
(default:False
) Bool whether to have bias term in linear decoder
- n_input :
Attributes table#
Methods table#
Extract per-gene weights (for each Z, shape is genes by dim(Z)) in the linear decoder. |
Attributes#
T_destination#
- LDVAE.T_destination#
alias of TypeVar(‘T_destination’, bound=
Mapping
[str
,torch.Tensor
])
alias of TypeVar(‘T_destination’, bound=Mapping
[str
, torch.Tensor
])
.. autoattribute:: LDVAE.T_destination
device
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- LDVAE.device#
dump_patches#
- LDVAE.dump_patches: bool = False#
This allows better BC support for
load_state_dict()
. Instate_dict()
, the version number will be saved as in the attribute _metadata of the returned state dict, and thus pickled. _metadata is a dictionary with keys that follow the naming convention of state dict. See_load_from_state_dict
on how to use this information in loading.If new parameters/buffers are added/removed from a module, this number shall be bumped, and the module’s _load_from_state_dict method can compare the version number and do appropriate changes if the state dict is from before the change.