scVI (single-cell Variational Inference) uses a variational autoencoder to learn a low-dimensional probabilistic latent representation of single-cell data that accounts for batch effects. SeuratWrappers providesDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/satijalab/seurat-wrappers/llms.txt
Use this file to discover all available pages before exploring further.
scVIIntegration(), which integrates with Seurat v5’s IntegrateLayers() framework and calls into the Python scvi-tools library via reticulate.
Installation
Workflow
Split layers and preprocess
Split the RNA assay by batch variable to create per-batch layers, then run standard preprocessing.
Integrate layers with scVIIntegration
Specify the path to your conda environment containing
scvi-tools. The integrated latent space is stored under new.reduction.SCTransform Integration
scVI also supports SCTransformed data. RunSCTransform() instead of NormalizeData() and specify the SCT assay:
Parameters
A merged Seurat v5 assay object containing the data to integrate. Passed internally by
IntegrateLayers().Features (genes) to include in the scVI model. If
NULL, all variable features are used.Layer(s) containing raw counts. scVI requires raw (unnormalized) count data. For standard Seurat workflows, this is
"counts".Path to the conda environment containing
scvi-tools. Passed to reticulate::use_condaenv(). Required for the function to locate the Python packages.Name under which the scVI latent space is stored as a
DimReduc object in the Seurat object.Dimensionality of the scVI latent space (
n_latent in scvi-tools). Controls the number of latent variables in the variational autoencoder.Number of hidden layers in the encoder and decoder neural networks (
n_layers in scvi-tools).Distribution used to model gene expression counts. Options:
"nb"— negative binomial (default, recommended for most scRNA-seq data)"zinb"— zero-inflated negative binomial"poisson"— Poisson
Maximum number of training epochs. When
NULL, scvi-tools uses its default heuristic based on dataset size.How It Works
Internally,scVIIntegration() performs the following steps:
- Identifies batch membership for each cell from the split layer structure (or SCT model identifiers for SCTransformed data)
- Joins count layers into a single matrix and constructs an
AnnDataobject in Python viareticulate - Calls
scvi.model.SCVI.setup_anndata()withbatch_key = "batch"to register batch labels - Initializes an
SCVImodel and trains it formax_epochsepochs - Extracts the latent representation with
model.get_latent_representation() - Returns a named list containing a
DimReducobject for use byIntegrateLayers()
The
scVIIntegration function has attr(x = scVIIntegration, which = 'Seurat.method') <- 'integration' set, which registers it as a valid integration method for IntegrateLayers().