scvi-tools

repository·main·Indexed 23 days ago

https://github.com/scverse/scvi-tools

A Python package for the deep probabilistic modeling and analysis of single-cell, multi, and spatial omics data. Built on PyTorch and AnnData, it supports tasks such as dimensionality reduction, data integration, automated annotation, factor analysis, doublet detection, and spatial deconvolution. The library provides a high-level API compatible with Scanpy, includes various built-in models like SCVI, SCANVI, and TOTALVI, and offers building blocks for developers to create novel probabilistic models using PyTorch Lightning and Pyro.

Tokens
44.9K
Snippets
85
Records
281
Agent score
81%

What's inside scvi-tools

  1. What is CytoVI?

    main
    CytoVI is a generative model for cytometry data (Flow cytometry, Mass cytometry, CITE-seq, etc.) that uses deep probabilistic latent variable modeling. It is designed for denoising, imputation, integration, and differential analysis across different technologies and batches. It is scalable to very large datasets (>20 million cells) but effectively requires a GPU for fast inference.
  2. Overview of scvi-tools components

    main

    scvi-tools (single-cell variational inference tools) is a package for end-to-end analysis of single-cell omics data. It consists of two primary components:

    1. Model Interface: Provides an easy-to-use interface for a range of existing probabilistic models for single-cell omics, such as scVI, scANVI, and totalVI.
    2. Model Development Tools: Provides tools to build new probabilistic models, powered by PyTorch, PyTorch Lightning, and Pyro.
  3. What is totalVI?

    main

    totalVI (scvi.model.TOTALVI) is a probabilistic generative model designed for CITE-seq data, which contains paired RNA (scRNA-seq) and protein (CITE-seq) expression measurements. It is designed to be scalable to very large datasets (over 1 million cells) and can handle multiple batches and missing protein data.

    Key Capabilities:

    • Dimensionality reduction
    • RNA and protein normalization and denoising
    • Differential expression analysis
    • Data simulation

    Limitations:

    • Requires a GPU for efficient inference.
    • The balance between RNA and protein in the low-dimensional representation can be difficult to interpret.
  4. Overview of scvi-tools models and analysis tasks

    main

    scvi-tools provides a variety of probabilistic models tailored for different single-cell omics analysis tasks. These models are categorized by the type of data they process:

    scRNA-seq analysis

    • scVI: Dimensionality reduction, removal of unwanted variation, integration, differential expression, imputation, and normalization.
    • scANVI: scVI tasks with cell type transfer from reference and seed labeling.
    • LinearSCVI: scVI tasks with a linear decoder.
    • Autozi: Assessing gene-specific zero-inflation levels.
    • CellAssign: Marker-based automated annotation.
    • Solo: Doublet detection.
    • Scar: Ambient RNA removal.
    • ContrastiveVI: scVI tasks with contrastive analysis.
    • MRVI: Characterization of sample-level heterogeneity.
    • SysVI: Integrating datasets with substantial batch effects.
    • Decipher: Joint representation and visualization of derailed cell states.
    • Velovi: RNA velocity analysis via deep generative modeling.
    • DRVI: Unsupervised deep disentangled representation learning.
    • JointEmbeddingsCVI: Improving scVI for low-count cells via self-supervised augmentation.

    ATAC-seq analysis

    • PeakVI: Dimensionality reduction, integration, differential expression, and imputation.
    • scBasset: Representation learning and integration.
    • PoissonVI: Analysis using quantitative fragment counts.

    BS-seq analysis

    • MethylVI: Analysis of single-cell bisulfite data.
    • MethylANVI: MethylVI tasks with cell type label transfer.

    Cytometry analysis

    • CytoVI: Batch effect correction, integration, and downstream analysis.

    Multimodal analysis

    • CITE-seq:
      • TotalVI: Dimensionality reduction, integration, protein imputation, and normalization.
      • TotalANVI: Jointly infers protein expression and cell states using semi-supervised annotations.
    • Multiome:
      • MultiVI: Integration of paired/unpaired multiome data and missing modality imputation.
      • DiagVI: Diagonal integration of unpaired multiome data and cross-modality imputation.

    Spatial transcriptomics analysis

    • DestVI: Multi-resolution deconvolution and cell-type-specific gene expression imputation.
    • Stereoscope: Deconvolution.
    • GIMVI: Imputation of missing spatial genes.
    • Tangram: Deconvolution and single-cell spatial mapping.
    • ResolVI: Generative model of single-cell resolved spatial transcriptomics.
    • SCVIVA: Representation of cells and their environments.

    General purpose

    • AmortizedLDA: Topic modeling.
    • scvi-hub: Model-driven analysis using Hugging Face Hub.
  5. What is MultiVI?

    main

    MultiVI (scvi.model.MULTIVI) is a multimodal generative model designed to integrate multiome, scRNA-seq, and scATAC-seq data. It is scalable to very large datasets (over 1 million cells) and can be used for downstream tasks like dimensionality reduction, differential expression/accessibility, and the imputation of missing modalities (e.g., predicting gene expression from accessibility data or vice versa).

    Note: Fast inference effectively requires a GPU.

  6. Overview of scvi-tools capabilities

    main

    scvi-tools is a package for probabilistic modeling and analysis of single-cell, multi, and spatial omics data. It is built on top of PyTorch and AnnData.

    Key analysis tasks supported include:

    • Dimensionality reduction
    • Data integration
    • Automated annotation
    • Factor analysis
    • Doublet detection
    • Spatial deconvolution

    All model implementations provide a high-level API that interacts with Scanpy and includes standard features like save/load functions and GPU acceleration.

  7. Overview of MethylVI

    main

    MethylVI (scvi.external.METHYLVI) is a generative model designed for scBS-seq data. It is scalable to very large datasets (over 1 million cells) and is capable of performing various downstream tasks like dimensionality reduction and differential methylation analysis.

    Input Requirements: MethylVI requires two count matrices for each methylation context $C$ (e.g., CpG vs non-CpG):

    1. Methylated counts ($Y_{mc}$): The number of methylated cytosines in a region for a cell.
    2. Total coverage counts ($Y_{cov}$): The total number of cytosines profiled at a given region in a cell.

    An optional vector of categorical covariates $S$ (e.g., batch, donor) can also be provided.

    Limitations:

    • Effectively requires a GPU for fast inference.
    • The latent space is not interpretable in the same way as linear methods.
  8. Use ResolVI for spatial transcriptomics analysis

    main

    ResolVI is a generative model for single-cell resolved spatial transcriptomics designed to address noise and bias caused by segmentation errors, unspecific background, and limited spatial resolution. It is scalable to datasets exceeding 1 million cells.

    Requirements and Limitations:

    • GPU Required: Fast inference effectively requires a GPU.
    • Input Data: Requires spatially resolved RNA-seq count matrices downstream of cellular segmentation and molecule assignments (e.g., from sequencing or imaging).
    • Resolution: Assumes single cells are observed; it is not intended for low-resolution ST like Visium or Slide-Seq.
    • Interpretability: The latent space is not interpretable in the same way as linear methods.

    Note: Starting with scVI-Tools v1.5, this model is part of scVIVA-Tools and is no longer being maintained within the main scvi-tools repository.

  9. Use Tangram for mapping single-cell to spatial data

    main

    Tangram is a model used to map single-cell RNA-seq data to spatial data (e.g., Visium), allowing for the deconvolution of cell types in spatial observations. It learns a mapping matrix $M$ where each row sums to 1, representing a map from single cells to spatial observations.

    Note: Tangram is deprecated starting in scvi-tools v1.5. It has moved to scVIVA-Tools and is no longer maintained in scvi-tools.

    Key Features:

    • Maps single-cell transcriptomes to spatial observations via an interpretable mapping matrix.
    • Projects cell annotations (e.g., cell types) from single-cell data to spatial data.
    • Projects gene expression from single-cell references into spatial coordinates.
    • Supports both "cells" and "constrained" modes.

    Requirements & Limitations:

    • Requires matched genes between the single-cell and spatial modalities in the same order.
    • Training is not mini-batched; memory usage scales with the number of single-cell and spatial observations.
    • It is an optimization-based model, not a generative model with posterior sampling.
  10. Multimodal analysis workflows in scvi-tools

    main

    scvi-tools provides several specialized workflows for analyzing and integrating multimodal single-cell data. Key workflows include:

    • totalVI: Used for analyzing CITE-seq datasets, integrating CITE-seq and scRNA-seq datasets, and mapping query CITE-seq data to a trained reference model.
    • scArches: Used for mapping cells from a query dataset to the latent space of a reference dataset (transfer learning).
    • MultiVI: Used for joint analysis of paired and unpaired multi-omic data.
    • TotalANVI: A semi-supervised approach for CITE-seq data that leverages partial cell type annotations for label prediction, protein imputation, and differential abundance.
    • DiagVI: Used for integrating spatial proteomics with single-cell transcriptomics, or spatial transcriptomics with single-cell transcriptomics.
  11. Use the Decipher model for interpretable representation learning

    main

    Decipher is a probabilistic model for single-cell RNA-seq data that learns two distinct latent representations: a low-dimensional, interpretable space v (default dim_v=2) for visualization, and an intermediate space z (default dim_z=10) for detailed cell-state information.

    Current Limitations:

    • The implementation currently only registers the count matrix (and an optional raw-count layer) via setup_anndata. It does not yet expose condition covariates.
    • The implementation is still being aligned with the original method's full feature set.
    >>> Decipher.setup_anndata(adata, layer="counts")
    >>> model = Decipher(adata)
    >>> model.train()
  12. Use scANVI for semi-supervised cell type annotation

    main

    scANVI (scvi.model.SCANVI) is a semi-supervised model designed for single-cell transcriptomics. It extends the scVI model by leveraging partial cell type annotations to infer the states of unlabelled cells. This is particularly useful for annotating unlabelled datasets using manually annotated atlases.

    Key Characteristics

    • Scalability: Can handle very large datasets (>1 million cells).
    • Requirements: Effectively requires a GPU for fast inference.
    • Limitations: The latent space is not interpretable (unlike linear methods) and it may not scale well to a very large number of cell types.

    Inputs

    • Gene expression matrix: $X$ with $N$ cells and $G$ genes.
    • Cell type annotations: A vector $\mathbf{c}$ containing partially observed cell type annotations.
    • Covariates (Optional): A design matrix $S$ containing observed covariates (e.g., day, donor). While $S$ can include continuous covariates, the model typically assumes one categorical covariate representing batches.