|
| 1 | +# DRVI |
| 2 | + |
| 3 | +**DRVI** {cite:p}`Moinfar2024` (Disentangled Representation Variational Inference, |
| 4 | +Python class {class}`~scvi.external.DRVI`) |
| 5 | +is an unsupervised deep generative model that learns an **interpretable, disentangled** |
| 6 | +latent representation of single-cell omics data. |
| 7 | + |
| 8 | +The advantages of DRVI are: |
| 9 | + |
| 10 | +- Disentanglement: DRVI disentangled cell identity, signaling pathways, stress responses, developmental trajectories, and perturbation effects into distinct factors. |
| 11 | +- Interpretability: Each factor (latent dimension) can be linked back to genes via the built-in interpretability analyses. |
| 12 | +- Built on scVI: {class}`~scvi.external.DRVI` subclasses {class}`~scvi.model.SCVI` and only swaps |
| 13 | + the decoder, so it inherits the full SCVI interface — covariates, batch embedding |
| 14 | + (`batch_representation="embedding"`), size factors, minified mode, scArches transfer learning, |
| 15 | + out-of-core training via a datamodule, and the standard likelihoods (plus DRVI's log-space `pnb`). |
| 16 | + |
| 17 | + |
| 18 | +```{topic} Tutorials: |
| 19 | +
|
| 20 | +- {doc}`/tutorials/notebooks/scrna/DRVI_pipeline` |
| 21 | +``` |
| 22 | + |
| 23 | + |
| 24 | +## Method background |
| 25 | + |
| 26 | +DRVI is a variational autoencoder (VAE): the integrated, disentangled representation corresponds to |
| 27 | +the latent-space embedding of the cells. It shares the encoder, prior (`N(0, I)`) and reconstruction |
| 28 | +likelihoods with {class}`~scvi.module.VAE`. Disentanglement is induced **in the decoder** rather |
| 29 | +than through the prior. |
| 30 | + |
| 31 | +### Disentanglement via an additive split decoder |
| 32 | + |
| 33 | +The latent vector of dimension `K` is mapped into `n_split_latent` independent groups ("splits"). |
| 34 | +Each split is decoded **independently** and the per-split outputs are aggregated to form the final |
| 35 | +reconstruction parameters. Because every split can only influence the output through this shared |
| 36 | +aggregation, the model is encouraged to allocate independent factors of variation to different |
| 37 | +latent dimensions. |
| 38 | + |
| 39 | +Two aggregations over the split dimension are available: |
| 40 | + |
| 41 | +- `logsumexp` (default): aggregation in log space, which makes the decoder additive in the rate. |
| 42 | +- `mean`: average of the per-split parameters. |
| 43 | + |
| 44 | +Two latent-to-split mappings are available (`n_latent` should be divisible by `n_split_latent`): |
| 45 | + |
| 46 | +- `split_map` (default): the latent is reshaped into `n_split_latent` chunks and each chunk is passed through a learned per-split linear projection. |
| 47 | +- `split_mask`: latent is split into chunks and padded with zeros so, each split `i` keeps only its own chunk. |
| 48 | + |
| 49 | + |
| 50 | +### Likelihoods modeled in log space |
| 51 | + |
| 52 | +DRVI models the generative parameters in **log space**, which is what makes the `logsumexp` |
| 53 | +aggregation a genuine additive decoder (summing the per-split contributions of the rate). In |
| 54 | +addition to scvi's `nb`, `zinb` and `poisson`, DRVI adds: |
| 55 | + |
| 56 | +- `pnb` — *parametrized negative binomial*: the same mean as `nb` (``library * softmax``) but |
| 57 | + parametrized and evaluated in log space via {class}`~scvi.external.drvi.LogNegativeBinomial`, |
| 58 | + which is numerically stable and composes the per-split log contributions directly. |
| 59 | +- `normal` / `normal_unit_var` — a Gaussian whose mean is modeled **directly** (no library/softmax), |
| 60 | + with the per-gene variance modeled in log space (fixed to one for `normal_unit_var`); intended for |
| 61 | + continuous, e.g. log-normalized, input. |
| 62 | + |
| 63 | +### Interpretability |
| 64 | + |
| 65 | +Because the decoder is additive over splits, the contribution of each split to the reconstructed |
| 66 | +expression of every gene can be measured directly. DRVI exposes per-split parameters in an |
| 67 | +inspection mode and provides methods to quantify these contributions both in-distribution (over the |
| 68 | +observed cells) and out-of-distribution (by traversing each latent dimension), and to extract the |
| 69 | +top genes per latent dimension. See {meth}`~scvi.external.DRVI.set_latent_dimension_stats`, |
| 70 | +{meth}`~scvi.external.DRVI.calculate_interpretability_scores` and |
| 71 | +{meth}`~scvi.external.DRVI.get_interpretability_scores`. |
| 72 | + |
| 73 | +## Scope: core model only |
| 74 | + |
| 75 | +Only the **core DRVI model** and its **core interpretability methods** are included in scvi-tools |
| 76 | +(the model, the additive decoder and log-sum-exp pooling, the log-space likelihoods, and the interpretability methods.). |
| 77 | + |
| 78 | +The **utility functions for latent-space visualization and analysis are not** part of scvi-tools. |
| 79 | +For those, install the full [`drvi-py`](https://github.com/theislab/drvi) package: |
| 80 | + |
| 81 | +```bash |
| 82 | +pip install drvi-py |
| 83 | +``` |
0 commit comments