Differential expression with DESeq2: which genes respond to a steroid?
Test every expressed gene of the airway experiment for a change with DESeq2 in RBAi, then read the answer in a volcano plot and an MA plot. In our run 4,030 genes changed at a false discovery rate of 5%: 2,208 went up and 1,822 went down.
In Lesson 2 the PCA showed that dexamethasone changes the airway cells more than anything else in the experiment. Now comes the question every RNA-seq study is built to answer: which genes change, in which direction, and how sure can you be? Finding them is called differential expression analysis. You will run it with DESeq2, the most widely used method for RNA-seq counts, on the same eight samples, and then read the answer in the two standard pictures of the field, a volcano plot and an MA plot.
Carry on in the same chat as Lesson 2: RBAi still has the counts table there. Every prompt goes into the RBAi main chat, except one change to a figure in step 3.
What you will make

Which genes respond to dexamethasone. Each point is one gene. Further right means more strongly up with the steroid, further left more strongly down, and higher means stronger evidence. Orange: the 2,208 genes up at a false discovery rate (FDR) below 0.05; teal: the 1,822 genes down; grey: the rest. The horizontal dashed line is FDR 0.05 and the vertical ones mark two-fold changes. Labelled: the ten most significant genes and CRISPLD2, the gene the original study followed up. GEO GSE52778, DESeq2 with apeglm-shrunken fold changes, drawn by RBAi.

The same result against how strongly each gene is expressed. Each point is one gene: further right means more reads, and up or down means a change with the steroid. Orange genes are up and teal genes down at FDR below 0.05; grey genes did not reach it. At the far left, genes with only a few reads have their fold changes pulled almost to zero, because so few reads cannot support a large change; among well-measured genes on the right, even small changes are detected. The dashed lines mark two-fold changes.
1. Test every gene for a change Main chat
Now run DESeq2 to find the genes that change with dexamethasone. Use the design ~ cell + dex, so that each donor's treated sample is compared with its own untreated sample, with untreated as the reference, and keep the genes with at least 10 counts in total. How many genes change at an adjusted p-value (FDR) below 0.05, and how many of those go up and how many go down? Also shrink the fold changes with apeglm. List the 10 most significant genes with their gene symbols, log2 fold changes and adjusted p-values, and save the full results table with gene symbols.
A few words first. The fold change of a gene is its expression with the steroid divided by its expression without it, and the log2 fold change is that ratio on a base-2 log scale: +1 means twice as much, +2 four times, −1 half and 0 no change. A p-value is the chance of seeing a difference at least this large if the steroid did nothing to the gene. DESeq2 calculates one for every gene. The design ~ cell + dex tells it that the samples differ by donor (cell) and by treatment (dex), so it measures the steroid's effect within each donor. The reference is the group the others are compared with, here the untreated cells.
What you should see: RBAi runs DESeq2 in R in its sandbox and reports 4,030 genes at FDR < 0.05: 2,208 up and 1,822 down, out of the 22,369 genes it tested. It took about two minutes in our run. RBAi saves the full table as a CSV file in the chat and opens it as a spreadsheet you can sort.
| Gene | Shrunken log2 fold change | Adjusted p-value |
|---|---|---|
| SPARCL1 | 4.56 | 7.1 × 10⁻¹³² |
| CACNB2 | 3.28 | 3.8 × 10⁻¹³¹ |
| DUSP1 | 2.94 | 1.7 × 10⁻¹²⁵ |
| SAMHD1 | 3.75 | 3.3 × 10⁻¹²⁵ |
| MAOA | 3.34 | 1.8 × 10⁻¹¹⁹ |
| GPX3 | 3.72 | 7.4 × 10⁻¹⁰⁸ |
| STEAP2 | 1.97 | 1.5 × 10⁻¹⁰² |
| NEXN | 2.03 | 3.4 × 10⁻⁹⁹ |
| MT2A | 2.20 | 3.5 × 10⁻⁹³ |
| ADAMTS1 | 2.34 | 3.9 × 10⁻⁸⁷ |
All ten go up. SPARCL1, at the top, rises 2^4.56, about 24-fold. The first gene that goes down is VCAM1, 15th on the list, at −3.67: about 13 times less with the steroid. VCAM1 helps white blood cells stick to tissue during inflammation, so less of it fits a drug that calms inflammation.
Reproduce it exactly (optional). The same analysis as RBAi's R code, written for your own R session with the airway, DESeq2 and apeglm packages installed:
library(DESeq2); library(airway); data(airway)
dds <- DESeqDataSet(airway, design = ~ cell + dex)
dds$dex <- relevel(dds$dex, ref = "untrt")
dds <- dds[rowSums(counts(dds)) >= 10, ]
dds <- DESeq(dds)
res <- results(dds, contrast = c("dex", "trt", "untrt"), alpha = 0.05)
shr <- lfcShrink(dds, coef = "dex_trt_vs_untrt", type = "apeglm")
2. Draw a volcano plot Main chat
Make a volcano plot of these results: the apeglm-shrunken log2 fold change on the x-axis and minus log10 of the adjusted p-value on the y-axis. Colour the genes with FDR below 0.05 orange (#E8710A) if they go up and teal (#00A5B5) if they go down, and every other gene light grey. Label the 10 most significant genes and CRISPLD2, the gene the original paper followed up, by symbol in navy (#0B3D91) without overlapping labels. Draw a dashed line at FDR 0.05, put the number of up and down genes in the legend, use a white background and make it about 16 cm wide. Then tell me CRISPLD2's fold change and adjusted p-value, and how many of the FDR 0.05 genes also change more than two-fold.
A volcano plot puts the size of each gene's change on the x-axis and the strength of the evidence on the y-axis. Minus log10 turns tiny p-values into large numbers: 0.05 becomes 1.3, and 10⁻¹⁰⁰ becomes 100. The colours here are hex codes, the six-character colour names that design programs use. Giving them keeps every figure in this module in the same palette.
What you should see: the volcano plot above, before the change in step 3. CRISPLD2 goes up by 2.61 (about six-fold) with an adjusted p-value of 7.5 × 10⁻⁴⁶. It is 56th on the list, not in the top ten: the original study chose it for its biology, not its rank. 803 of the 4,030 genes change more than two-fold, 443 up and 360 down. The lone point far to the right, at +11, is ALOX15B: about 2,000 times more with the steroid, from almost nothing.
3. Finish the volcano Edit with AI
Click Edit with AI on the volcano plot and type:
Connect every gene label to its point with a thin grey line, add dashed vertical lines at log2 fold changes of -1 and +1 (two-fold), and remove the top and right borders.
What you should see: "I connected each gene label to its plotted point with a thin grey line, added dashed reference lines at log2 fold changes of −1 and +1, and removed the top and right borders." That is the first figure of this lesson. The two-fold lines show at a glance how many significant genes change only a little.
4. Draw an MA plot Main chat
Now make an MA plot from the same results: each gene's mean of normalised counts on a log10 x-axis and its apeglm-shrunken log2 fold change on the y-axis, with the same colours as the volcano plot, a solid grey line at zero, dashed lines at -1 and +1, and the same 11 genes labelled with thin grey lines to their points. White background, no top or right border, about 16 cm wide.
An MA plot shows each gene's change (M, the log ratio) against its average expression (A). The mean of normalised counts, DESeq2's baseMean, is a gene's average read count across all eight samples after correcting for library size.
What you should see: a plot with the right axes and colours, but labels that are hard to read. In our run RBAi spent several steps nudging labels apart. Two genes that go up were labelled down among the teal points, and the grey lines crossed each other.
5. Redraw it as one program Main chat
We first asked Edit with AI to tidy the labels, and the edit stopped with "The model could not edit the plot just now; please try again." The code behind that figure was only RBAi's last small fix, which moved labels on a plot drawn in earlier steps. So we asked in the main chat instead:
Redraw the MA plot as one complete program that reads the saved results table, so the figure can be edited later. Put all 11 labels in the empty space above the orange points, in the same left-to-right order as their genes, each joined to its own point by a short straight grey line, with no lines crossing. Keep everything else the same.
What you should see: the second figure of this lesson, with the labels in one row above the points, in the same order as their genes. RBAi also saves the program as a file in the chat. Two things are still not perfect: the SPARCL1 and MAOA lines cross once, and the redraw dropped the legend. Fixing them with Edit with AI, one change at a time, is a good exercise.
The ideas behind the picture
- Why a statistical model? Counts vary even between identical samples: by chance in which fragments get read, and because donors differ. DESeq2 models each gene's counts with a negative binomial distribution, a model for counts that are more variable than pure chance would give. It learns how variable a gene is between replicates (its dispersion) and borrows strength across all genes, which matters when there are only four donors.
- Normalisation is built in. DESeq2 gives each sample a size factor, so a two-fold difference in library size (Lesson 2) is not read as a two-fold change in every gene.
- Pairing removes the donor. With
~ cell + dex, each treated sample is compared with its own donor's untreated sample. The donor differences you saw on PC2 then stop counting as noise. - Thousands of tests need a correction. At p < 0.05, about 1 in 20 tests passes by chance. Across 22,369 genes that would be about 1,100 genes even if the steroid did nothing; here 5,690 genes have p below 0.05. The adjusted p-value (the Benjamini–Hochberg method) controls the false discovery rate, the expected share of false hits among the genes you call. FDR 0.05 means that, on average, no more than 5% of the 4,030 genes, about 200, are expected to be false hits.
- Some genes get no adjusted p-value. DESeq2 leaves out genes with so few reads that they could never reach significance, which makes the correction less severe for the rest. Here 5,204 of the 22,369 genes have no adjusted p-value.
- Shrinkage keeps small numbers honest. A gene with a handful of reads can show a huge fold change by luck. apeglm pulls each fold change towards zero in proportion to how uncertain it is. Here 415 genes whose raw estimate was more than four-fold were shrunk below 1.4-fold. That is why the MA plot narrows at low counts.
- Two plots, two questions. The volcano asks "how big is the change, and how sure am I?" The MA plot asks "does the answer depend on how much the gene is expressed?" A good analysis looks at both.
What the result shows, and what it doesn't
- What it shows: dexamethasone changes thousands of genes in these cells, consistently across four donors: 4,030 at FDR 0.05, and 803 of them more than two-fold. The genes the original authors called well-known steroid responders are near the top: DUSP1 3rd, PER1 14th and KLF15 16th, all up. TSC22D3 is up too, more than eight-fold. CRISPLD2, which they followed up, is up about six-fold (Himes and colleagues, 2014).
- The count depends on the method. Himes and colleagues reported 316 genes at the same 0.05 cut-off with a different analysis. Methods, filters and designs change how many genes pass. The strongest responders are much more stable than the total.
- Significant is not the same as important. With deep sequencing, a small change in a busy gene can be highly significant and biologically trivial. Here the smallest change that passes FDR 0.05 is about 13% (a log2 fold change of 0.18). Look at the size of the change as well as the p-value.
- What it cannot tell you: whether the proteins change too, what the changes do to the cell, or whether the same happens in a patient's airway. These are cultured cells from four donors, treated in a dish with 1 µM dexamethasone for 18 hours.
Your turn
Test how much the donor pairing matters. Before you ask, write down whether you expect more or fewer genes at FDR 0.05 if DESeq2 ignores the donors, and why. Then, in the same chat:
Run DESeq2 again with the design ~ dex only, ignoring the donor, and tell me how many genes reach FDR 0.05 and how many of the 4,030 from the paired analysis are among them.
Write three sentences: which design found more genes, why, and which result you would report in a paper. Bonus: ask for FKBP5, a classic target of the receptor that dexamethasone switches on, in both analyses, and compare its adjusted p-values.
Try it
Open RBAi and continue your Lesson 2 chat with the first prompt above. If you start a new chat, paste Lesson 2's first prompt first so RBAi loads the counts. Keep this chat: Lesson 4 turns the strongest responders into a heatmap.
Carry on in the same chat as Lesson 2, then paste the lesson’s first prompt:
Now run DESeq2 to find the genes that change with dexamethasone. Use the design ~ cell + dex, so that each donor's treated sample is compared with its own untreated sample, with untreated as the reference, and keep the genes with at least 10 counts in total. How many genes change at an adjusted p-value (FDR) below 0.05, and how many of those go up and how many go down? Also shrink the fold changes with apeglm. List the 10 most significant genes with their gene symbols, log2 fold changes and adjusted p-values, and save the full results table with gene symbols.