Inferensys

Glossary

Scanpy

A scalable Python-based toolkit for analyzing single-cell gene expression data built on the AnnData data structure, enabling preprocessing, clustering, and trajectory inference.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
SINGLE-CELL ANALYSIS TOOLKIT

What is Scanpy?

Scanpy is a scalable, open-source Python toolkit for analyzing single-cell gene expression data, providing end-to-end workflows from preprocessing to visualization and trajectory inference.

Scanpy is a Python-based computational framework designed for the analysis of single-cell RNA sequencing (scRNA-seq) data. Built around the AnnData data structure, it provides efficient, scalable implementations of core algorithms for preprocessing, dimensionality reduction, graph-based clustering, and the identification of marker genes across large cell atlases.

The toolkit supports advanced analyses including pseudotime and trajectory inference via partition-based graph abstraction (PAGA), RNA velocity estimation, and data integration for batch effect correction. Its modular architecture and interoperability with the broader Python scientific ecosystem make it a foundational component in modern single-cell bioinformatics pipelines.

CORE CAPABILITIES

Key Features of Scanpy

Scanpy is a scalable Python-based toolkit for analyzing single-cell gene expression data. Built on the AnnData data structure, it provides a comprehensive framework for preprocessing, clustering, and trajectory inference.

02

Preprocessing & Quality Control

A robust pipeline for cleaning and normalizing raw count matrices. Scanpy provides highly optimized functions for:

  • Filtering low-quality cells based on total counts, gene counts, and mitochondrial read fraction
  • Normalization to library size with log-transformation
  • Highly Variable Gene (HVG) selection to identify informative features
  • Regression of technical covariates and cell cycle effects
  • Scaling to unit variance for downstream dimensionality reduction
03

Dimensionality Reduction & Visualization

Tools to embed high-dimensional single-cell data into interpretable 2D spaces. Scanpy wraps efficient implementations of:

  • PCA for linear dimensionality reduction on HVGs
  • t-SNE for non-linear embedding preserving local structure
  • UMAP for fast, scalable manifold learning that preserves global structure
  • Diffusion maps for trajectory-aware embeddings
  • Built-in plotting functions with automatic coloring by gene expression or metadata
04

Graph-Based Clustering

Unsupervised cell-type discovery using community detection on k-nearest neighbor graphs. The workflow includes:

  • Construction of a neighborhood graph in PCA space
  • Application of the Leiden algorithm for modularity optimization
  • Resolution parameter tuning to control cluster granularity
  • PAGA (Partition-based Graph Abstraction) for visualizing cluster connectivity at multiple resolutions
  • Differential expression testing to identify cluster-specific marker genes
05

Trajectory Inference & Pseudotime

Reconstruction of dynamic biological processes from static snapshot data. Scanpy integrates:

  • Diffusion Pseudotime (DPT) for ordering cells along branching trajectories
  • RNA Velocity analysis using spliced/unspliced read ratios to predict future cell states
  • PAGA for abstracting the connectivity structure of complex differentiation hierarchies
  • Visualization of gene expression trends along pseudotime with heatmaps and scatter plots
06

Data Integration & Batch Correction

Methods to align multiple datasets while preserving biological variation. Scanpy supports:

  • BBKNN for batch-aware neighborhood graph construction
  • Harmony integration via external wrapper
  • scVI probabilistic modeling for latent variable correction
  • Combat for location-scale adjustment of batch effects
  • Visualization of integrated embeddings colored by batch and cell type to assess mixing quality
SCANPY CLARIFIED

Frequently Asked Questions

Direct answers to the most common technical questions about Scanpy's architecture, performance characteristics, and analytical capabilities for single-cell genomics workflows.

Scanpy is a scalable Python-based toolkit for analyzing single-cell gene expression data built on the AnnData data structure. It works by providing a modular pipeline of functions that operate on a central AnnData object—a specialized matrix container storing the count matrix in adata.X, cell metadata in adata.obs, and gene annotations in adata.var. The toolkit implements over 200 functions spanning preprocessing (filtering, normalization, log-transformation), dimensionality reduction (PCA, t-SNE, UMAP), graph-based clustering (Louvain, Leiden), differential expression testing, and trajectory inference. Scanpy's architecture leverages sparse matrix operations and out-of-core computation to handle datasets exceeding one million cells on standard workstations. Its tight integration with the broader Python scientific ecosystem—NumPy, SciPy, pandas, scikit-learn—enables seamless interoperability with machine learning libraries and custom analysis extensions.

SINGLE-CELL ANALYSIS FRAMEWORKS

Scanpy vs. Seurat: Python and R Toolkits Compared

A technical comparison of the two dominant open-source frameworks for single-cell RNA-seq data analysis, highlighting language ecosystems, data structures, and analytical capabilities.

FeatureScanpySeurat

Primary Language

Python

R

Core Data Structure

AnnData

SeuratObject

Dimensionality Reduction

PCA, t-SNE, UMAP

PCA, t-SNE, UMAP

Graph-Based Clustering

Louvain Clustering

Leiden Clustering

RNA Velocity

Trajectory Inference (PAGA)

Data Integration (Harmony/CCA)

Spatial Transcriptomics Support

Multimodal Integration (CITE-seq)

Reference-Based Label Transfer

GPU Acceleration

Out-of-Core Processing

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.