Inferensys

Glossary

DESeq2

A widely adopted R/Bioconductor software package that uses a negative binomial distribution and empirical Bayes shrinkage to estimate dispersion and fold changes for differential gene expression analysis from raw count data.
Data scientist building training data pipeline on laptop, data preprocessing visible, technical workspace.
DIFFERENTIAL EXPRESSION ANALYSIS

What is DESeq2?

DESeq2 is an R/Bioconductor software package that uses a negative binomial distribution and empirical Bayes shrinkage to estimate dispersion and fold changes for differential gene expression analysis from raw RNA-seq count data.

DESeq2 is a widely adopted R/Bioconductor package that performs differential gene expression analysis on raw read count data. It models counts using a negative binomial distribution to account for overdispersion, then applies empirical Bayes shrinkage to stabilize dispersion and log2 fold change estimates, particularly for genes with low counts or high variability.

The workflow involves estimating size factors for normalization, estimating gene-wise dispersion, fitting a generalized linear model using a design matrix, and performing Wald tests for coefficient significance. DESeq2 provides built-in functions for variance stabilizing transformation and rlog transformation, enabling downstream visualization via PCA plots, heatmaps, and MA plots.

CORE METHODOLOGY

Key Features of DESeq2

DESeq2 provides a robust statistical framework for differential expression analysis from raw RNA-seq count data, centered on its unique approach to dispersion estimation and fold change shrinkage.

01

Negative Binomial Modeling

DESeq2 models raw read counts using a negative binomial distribution, which naturally accounts for the overdispersion inherent in RNA-seq data. Unlike a Poisson distribution, which assumes variance equals the mean, the negative binomial allows variance to exceed the mean, capturing both technical shot noise and biological variability. The model parameterizes the variance as a function of the mean with a gene-specific dispersion parameter, enabling accurate hypothesis testing even for genes with low counts.

02

Empirical Bayes Dispersion Shrinkage

A defining innovation of DESeq2 is its use of empirical Bayes shrinkage for dispersion estimation. Raw dispersion estimates are highly unstable for genes with few counts. DESeq2 addresses this by:

  • Fitting a parametric curve to the observed dispersion-mean relationship across all genes
  • Shrinking individual gene dispersions toward this fitted trend
  • Applying stronger shrinkage when counts are low and weaker shrinkage when counts are high This information-borrowing strategy stabilizes variance estimates and dramatically reduces false positives.
03

Log2 Fold Change Shrinkage

DESeq2 applies adaptive shrinkage to log2 fold change estimates, a step distinct from dispersion shrinkage. Using a zero-centered Normal prior whose width is estimated from the data, the algorithm shrinks large fold changes from genes with high dispersion or low counts toward zero. This produces conservative, reproducible effect size estimates that are directly suitable for ranking genes by biological significance rather than statistical significance alone. The lfcShrink() function implements this with options for the apeglm and ashr shrinkage estimators.

04

Hypothesis Testing with Wald Test

DESeq2 employs the Wald test to assess whether estimated log2 fold changes differ significantly from zero. For each gene, the test computes:

  • The maximum likelihood estimate of the coefficient
  • Its standard error from the model's information matrix
  • A z-statistic and corresponding p-value For multi-factor designs, DESeq2 also supports likelihood ratio tests (LRT), which compare full and reduced model fits to identify genes that respond to any level of a categorical variable, making it ideal for time-series or multi-condition experiments.
05

Automatic Independent Filtering

DESeq2 integrates independent filtering to increase detection power. Before multiple testing correction, genes with very low mean normalized counts are filtered out, as they provide insufficient evidence for differential expression. This filtering is performed independently of the test statistic under the null hypothesis, so it does not inflate the type I error rate. By reducing the number of tests requiring correction, the Benjamini-Hochberg procedure operates on a smaller set, yielding more significant adjusted p-values for genes with sufficient signal.

06

Variance Stabilizing Transformation

DESeq2 provides a variance stabilizing transformation (VST) and a regularized log transformation (rlog) for downstream visualization. These transformations produce data where the variance is approximately independent of the mean, making them suitable for:

  • Principal component analysis (PCA) to visualize sample clustering
  • Heatmaps of gene expression patterns
  • Machine learning inputs requiring homoskedastic data The VST is faster than rlog for large datasets and is the recommended default for exploratory analysis.
DESeq2 CLARIFIED

Frequently Asked Questions

Concise answers to the most common technical questions about the DESeq2 differential expression workflow, from core statistical concepts to practical implementation details.

DESeq2 is an R/Bioconductor software package that performs differential gene expression analysis on raw RNA-seq count data. It works by modeling read counts using a negative binomial distribution and applying empirical Bayes shrinkage to stabilize estimates of dispersion and log2 fold change. The core workflow involves: (1) normalizing raw counts using a median-of-ratios method to estimate size factors, (2) estimating gene-wise dispersion parameters, (3) fitting a generalized linear model (GLM) for each gene, and (4) performing a Wald test or likelihood ratio test to identify genes with statistically significant expression changes between conditions. The shrinkage step is critical—it borrows information across all genes to prevent low-count, high-variance genes from dominating the list of false positives, making DESeq2 particularly robust for experiments with small sample sizes.

METHOD COMPARISON

DESeq2 vs. edgeR vs. limma-voom

A technical comparison of the three dominant R/Bioconductor packages for differential gene expression analysis from RNA-seq count data.

FeatureDESeq2edgeRlimma-voom

Statistical Model

Negative Binomial GLM

Negative Binomial GLM

Linear model on precision-weighted log-CPM

Dispersion Estimation

Empirical Bayes shrinkage (gene-wise)

Empirical Bayes shrinkage (tagwise)

Estimates mean-variance trend via voom

Normalization Method

Median of ratios (size factors)

Trimmed Mean of M-values (TMM)

TMM normalization (via edgeR)

Hypothesis Test

Wald test or LRT

Exact test or quasi-likelihood F-test

Moderated t-statistic (empirical Bayes)

Handles Complex Designs

Single-Cell Compatibility

Pseudobulk aggregation

Pseudobulk aggregation

Pseudobulk aggregation

Outlier Robustness

Cook's distance filtering

Moderate via quasi-likelihood

High via precision weights

Speed (Typical Dataset)

< 30 sec

< 20 sec

< 45 sec

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.