Inferensys

Glossary

Highly Variable Genes (HVG)

Genes exhibiting greater expression variance across cells than expected by technical noise, selected as informative features for downstream dimensionality reduction.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
FEATURE SELECTION

What is Highly Variable Genes (HVG)?

Highly Variable Genes (HVG) are genes that exhibit significantly greater expression variance across a population of single cells than is attributable to technical noise, and they are selected as the most informative features for downstream dimensionality reduction and clustering.

Highly Variable Genes (HVG) are identified by modeling the relationship between a gene's mean expression and its variance or dispersion. Genes whose observed variance substantially exceeds the expected technical variance at a given expression level are designated as HVGs. This selection step is critical in single-cell RNA-seq analysis because it filters out stochastically noisy or uniformly expressed genes, retaining those that capture the dominant axes of biological heterogeneity.

The typical workflow involves fitting a loess regression or gamma generalized linear model to the mean-variance trend, then ranking genes by their standardized residuals or dispersion z-scores. The top 2,000 to 5,000 HVGs are commonly used as input for Principal Component Analysis (PCA). By restricting analysis to HVGs, computational load is drastically reduced while preserving the biological signal necessary for accurate cell type annotation and trajectory inference.

FEATURE SELECTION

Key Characteristics of HVG Selection

Highly Variable Genes (HVGs) are selected based on their biological signal-to-noise ratio. The following characteristics define the computational heuristics used to distinguish meaningful variation from technical noise in single-cell data.

01

Mean-Variance Relationship

HVG selection explicitly models the dependency between gene expression mean and variance. In scRNA-seq, variance naturally increases with mean expression due to Poisson sampling noise. Algorithms fit a loess regression or gamma-Poisson GLM to the log(variance) vs log(mean) trend. Genes with positive residuals—variance significantly exceeding the fitted trend—are flagged as HVGs. This prevents the selection of highly expressed but uninformative housekeeping genes.

02

Standardized Variance Metrics

To rank genes, methods compute a standardized variance that corrects for the mean-dependence. Common approaches include:

  • vst (Variance Stabilizing Transformation): Applies a transformation to render variance independent of mean, then ranks by transformed variance.
  • dispersion (cv2): Uses the squared coefficient of variation, comparing observed dispersion to the expected sampling noise.
  • deviance: Calculates the deviance of a fitted null model, capturing excess variability beyond technical expectations.
03

Binning for Local Robustness

To avoid global trend distortions, genes are binned by average expression into equal-frequency groups. Within each bin, the median absolute deviation (MAD) or z-score of variance is calculated. This local normalization ensures that HVG selection is not biased toward high-expression regimes. A gene is selected if its variance exceeds a threshold (e.g., z-score > 0.5) relative to its local bin neighbors.

04

Top-N Selection Heuristic

Most workflows select a fixed number of top HVGs (e.g., top 2,000 or top 5,000) rather than using a strict statistical cutoff. This heuristic balances computational tractability with biological signal retention. Selecting too few genes risks missing rare cell-type markers; selecting too many introduces noise that degrades Principal Component Analysis (PCA) and graph-based clustering performance.

05

Batch-Aware Selection

In multi-sample studies, naive HVG selection can capture batch effects rather than biology. Advanced methods like scran or Seurat's SelectIntegrationFeatures identify genes that are highly variable consistently across batches. This involves ranking genes by variance within each batch independently, then selecting those with high median rank across all batches, ensuring the selected features represent robust biological heterogeneity.

06

Flavor Variants: Seurat vs. Scanpy

Different toolkits implement distinct HVG strategies:

  • Seurat v5: Defaults to vst, selecting 2,000 features by default. It fits a loess curve to log(variance) vs log(mean) and ranks by standardized variance.
  • Scanpy: Offers seurat, seurat_v3, and cell_ranger flavors. The seurat_v3 method uses a count-based gamma-Poisson model without log-transformation, directly estimating dispersion parameters.
  • scran: Models technical noise using spike-in RNA or by decomposing variance into biological and technical components via a mixed-effects model.
ESSENTIALS

Frequently Asked Questions

Clear, technical answers to the most common questions about Highly Variable Genes and their role in single-cell analysis.

Highly Variable Genes (HVG) are genes that exhibit significantly greater expression variance across individual cells than would be expected from technical noise alone. They are identified by modeling the relationship between the mean expression level and the variance (or coefficient of variation) for every gene in a count matrix. Genes whose observed variance substantially exceeds the predicted technical variance—often calculated using a loess regression or a negative binomial model—are selected. This feature selection step filters out stochastically noisy or uniformly expressed housekeeping genes, retaining the biologically informative features that drive cellular heterogeneity for downstream dimensionality reduction and clustering.

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.