PeakVI¶
peakVI 1 (Python class PEAKVI
) is a generative model of scATACseq data that can subsequently
be used for many common downstream tasks.
The advantages of peakVI are:
Comprehensive in capabilities.
Scalable to very large datasets (>1 million cells).
The limitations of peakVI include:
Effectively requires a GPU for fast inference.
Latent space is not interpretable, unlike that of a linear method.
Tutorials:
Preliminaries¶
PeakVI takes as input a scATACseq accessibility matrix \(X\) with \(N\) cells and \(M\) genomic regions (peaks), which can be binary or have count data. Additionally, a design matrix \(S\) containing \(p\) observed covariates, such as batch, donor, etc, is an optional input. While \(S\) can include both categorical covariates and continuous covariates, in the following, we assume it contains only one categorical covariate with \(K\) categories, which represents the common case of having multiple batches of data.
Generative process¶
PeakVI posits that the observed value for cell \(i\) and region \(j\), \(x_{ij}\), is generated by the following process:
Briefly, detecting a region as accessible (\(x_{ij} > 0\)) is generated by a Bernoulli random variable which depends on a cellspecific latent variable \(z_i\), which captures biological heterogeneity, and two auxiliary scaling factors \(\ell_i, r_j\), which account for cellspecific and regionspecific technical effects, respectively.
The PeakVI generative process uses a single neural network:
which estimates the probability of accessibility.
The latent variables, along with their description are summarized in the following table:
Latent variable 
Description 
Code variable (if different) 

\(z_i \in \mathbb{R}^d\) 
Lowdimensional representation capturing the state of a cell 

\(y_i \in \left[0,1\right]^{M}\) 
Acessibility probability estimate 

\(\ell_i \in \left[0,1\right]\) 
Cellwise scaling factor 

\(r_j \in \left[0,1\right]\) 
Regionwise scaling factor 

Inference¶
PeakVI uses variational inference, specifically autoencoding variational Bayes (see Variational Inference) to learn both the model parameters (the neural network params, scaling factors, etc.) and an approximate posterior distribution with the following factorization:
Here \(\eta\) is a set of parameters corresponding to inference neural networks (encoders), which we do not describe in detail here. The underlying class used as the encoder for PeakVI is Encoder
.
It it important to note that by default, PeakVI only receives the accessibility data as input (i.e., not the observed celllevel covariates).
Empirically, we have not seen much of a difference by having the encoder take as input the concatenation of these items (i.e., \(q_\eta(z_i, \ell_i \mid x_i, s_i)\), but users can control it manually by passing
encode_covariates=True
to scvi.model.PEAKVI
.
Tasks¶
Here we provide an overview of some of the tasks that PeakVI can perform. Please see scvi.model.PEAKVI
for the full API reference.
Dimensionality reduction¶
For dimensionality reduction, the mean of the approximate posterior \(q_\eta(z_i \mid x_i)\) is returned by default. This is achieved using the method:
>>> adata.obsm["X_peakvi"] = model.get_latent_representation()
Users may also return samples from this distribution, as opposed to the mean, by passing the argument give_mean=False
.
The latent representation can be used to create a nearest neighbor graph with scanpy with:
>>> import scanpy as sc
>>> sc.pp.neighbors(adata, use_rep="X_scvi")
>>> adata.obsp["distances"]
Transfer learning¶
A PeakVI model can be pretrained on reference data and updated with query data using load_query_data()
, which then facilitates transfer of metadata like cell type annotations. See the Transfer learning guide for more information.
Estimation of accessibility¶
In get_accessibility_estimates()
PeakVI returns the expected value of \(y_i\) under the approximate posterior. For one cell \(i\), this can be written as:
As the expectation can be expensive to compute, by default, PeakVI uses the mean of \(z_i\) as a point estimate, but this behaviour can be changed by setting use_z_mean=False
argument.
Notably, this function also has the transform_batch
parameter that allows counterfactual prediction of accessibility in an unobserved batch. See the Counterfactual prediction guide.
Differential accessibility¶
Differential accessibility analysis is achieved with differential_accessibility()
. PeakVI tests differences in accessibility of \(g_z\left( z_i, s_i \right)\).