>
DESeq2 Tutorial: RNA-Seq Differential Expression Analysis in R

DESeq2 Tutorial: RNA-Seq Differential Expression Analysis in R

Last updated: March 13, 2026

📖 RNA-Seq Data Analysis Workflow — check it out for an overview.

What is DESeq2?

Performing RNA-Seq analysis with a next-generation sequencer yields expression levels for each gene. By comparing these expression levels across multiple samples, you can detect statistically significant differentially expressed genes (DEGs).

DESeq2 is a widely used software package for detecting differentially expressed genes, and is one of the most popular tools in this field along with edgeR.

In this article, we walk through how to install DESeq2 and how to use it for a basic analysis.

For an overview of the entire RNA-Seq data analysis workflow, see the RNA-Seq analysis workflow guide.

Installing DESeq2

First, if you do not already have R installed, you will need to install it. (The example below uses Homebrew.)

$ brew install r

Start R and run the following commands to install BiocManager and DESeq2.

> if (!requireNamespace("BiocManager", quietly=TRUE)) > install.packages("BiocManager") > BiocManager::install("DESeq2")

Run the command below to load the package. If no errors appear, the installation was successful.

> library(DESeq2)

Preparing Your Data

Use a quantification tool such as featureCounts, StringTie, or RSEM to obtain gene expression counts.

Organize the results into a comma-separated (CSV) file like the one shown below. Note that DESeq2 requires raw read counts as input, not normalized values such as FPKM/RPKM or TPM.

Example count matrix for DESeq2

Running DESeq2

> counts <- read.csv("counts.csv", sep=",", row.names=1) > coldata <- data.frame(condition = factor(c("A", "A", "A", "A", "B", "B", "B", "B"))) > dds <- DESeqDataSetFromMatrix(countData = counts, colData = coldata, design = ~ condition) > dds <- DESeq(dds) estimating size factors estimating dispersions gene-wise dispersion estimates mean-dispersion relationship final dispersion estimates fitting model and testing

Here we pass the count data along with sample information to the DESeqDataSetFromMatrix function. Since we want to perform a two-group comparison between samples 1 through 4 and samples 5 through 8, we assign them to groups A and B respectively.

The results can be viewed with the following command.

> res <- results(dds) > res log2 fold change (MLE): condition B vs A Wald test p-value: condition B vs A DataFrame with 62696 rows and 8 columns baseMean log2FoldChange lfcSE stat pvalue padj <numeric> <numeric> <numeric> <numeric> <numeric> <numeric> ENSG00000290825.1 0.0000 NA NA NA NA NA ENSG00000223972.6 0.0000 NA NA NA NA NA ENSG00000227232.5 11.4438 -0.619619 0.758925 -0.816443 0.414247 NA ENSG00000278267.1 1.6048 -0.826152 1.974423 -0.418427 0.675635 NA ENSG00000243485.5 0.0000 NA NA NA NA NA ... ... ... ... ... ... ... ENSG00000198695.2 0 NA NA NA NA NA ENSG00000210194.1 0 NA NA NA NA NA ENSG00000198727.2 0 NA NA NA NA NA ENSG00000210195.2 0 NA NA NA NA NA ENSG00000210196.2 0 NA NA NA NA NA

RNA-Seq Data Analysis Software

This is an RNA-Seq Data Analysis Software recommended for those who:

✔︎ Seeking to avoid outsourcing or collaboration for RNA-Seq data analysis.

✔︎ Lacking time to learn RNA-Seq data analysis.

✔︎ Frustrated by the complexity of existing tools.

overview

Users can perform gene expression quantification, identification of differentially expressed genes, gene ontology(GO) analysis, pathway analysis, as well as drawing volcano plots, MA plots, and heatmaps.

BxINFO LLC logo

BxINFO LLC

A research support company specializing in bioinformatics.

We provide tools and information to support life science research, with a focus on RNA-Seq analysis.

→ Learn more