LSMA

LONDON SCHOOL OF MULTIOMICS & AI

Free course

Free course

0 of 25 lessons

Lesson 3 of 4

Module 4 · RNA-seq analysis

Volcano plot and interpretation

Volcano plot and interpretation

Volcano plot and interpretation

Turn the results into the figures a paper needs, put gene names on them, and move from a list of genes to a biological story you can defend.

⏱ 17 min readModule 4 · RNA-seq analysisFree
Lesson at a glance4 steps · about 17 min
  1. Prepare the table and add gene names
  2. The volcano plot
  3. Heatmap of the top genes, and one gene up close
  4. From genes to biology

Prepare the table and add gene names

Results use Ensembl IDs such as ENSG00000000003. The org.Hs.eg.db package maps them to familiar symbols. Genes are labelled up or down using |log2 fold change| > 1 and padj < 0.05.

An Ensembl ID is a stable identifier from the Ensembl genome database: ENSG marks a human gene, followed by a number. IDs like this are unambiguous, which is why analysis tools use them, but nobody recognises them on a plot. A gene symbol is the short official name, such as FKBP5, that people use in papers. The vertical bars in |log2 fold change| mean "absolute value", the size of the number ignoring its sign, so |log2 fold change| > 1 covers both a doubling and a halving or more.

The two cut-offs answer different questions. padj < 0.05 asks whether there is good evidence of any change at all; |log2 fold change| > 1 asks whether the change is large enough to care about. Neither number is a law of nature. A cut-off of 1 is a common convention, and some studies use 0.58 (a 1.5-fold change) or none at all. What matters is that you choose the thresholds before looking at the results, apply them the same way to every gene, and report them. Choosing a threshold afterwards because it gives a tidier list is the same mistake as trying tests until one gives p < 0.05, which Comparing two groups warned against.

Because df is built from res_shrunk, the fold-change cut-off is applied to the shrunken values. That is deliberate: a low-count gene whose raw fold change was inflated by noise is less likely to cross the line. Remember from Differential expression with DESeq2, though, that filtering on fold change after a test of "any change" is not the same as testing for a change larger than a doubling; the lfcThreshold option described there does that.

This lesson uses res_shrunk from Differential expression with DESeq2, and dds, vsd and coldata from RNA-seq counts and exploration. If you start a fresh R session, run the code in both lessons again first.

R
library(org.Hs.eg.db)
library(ggrepel)

df <- as.data.frame(res_shrunk)
df <- df[!is.na(df$padj), ]

df$status <- "Not significant"
df$status[df$log2FoldChange >  1 & df$padj < 0.05] <- "Up"
df$status[df$log2FoldChange < -1 & df$padj < 0.05] <- "Down"
table(df$status)

df$symbol <- mapIds(org.Hs.eg.db, keys = rownames(df),
                    keytype = "ENSEMBL", column = "SYMBOL")

What this does, line by line

  • The two library() calls load the gene annotation database and ggrepel, for labels.
  • as.data.frame(res_shrunk) turns the shrunken results from Differential expression with DESeq2 into an ordinary data frame, df, with one row per gene and Ensembl IDs as row names.
  • df[!is.na(df$padj), ] keeps only rows whose padj is not missing. The ! means "not", so !is.na() is TRUE for genes that were tested. The genes removed are those set aside by independent filtering in Differential expression with DESeq2.
  • The three status lines work as in Omics figures: every gene starts as "Not significant", and genes passing both the fold-change and the padj cut-off are relabelled "Up" or "Down". Here the fold changes are the shrunken ones, so noisy genes are less likely to pass. table() prints the count of each label.
  • mapIds(org.Hs.eg.db, keys = rownames(df), keytype = "ENSEMBL", column = "SYMBOL") looks up each Ensembl ID (the keys, of type ENSEMBL) and returns the matching gene symbol. Where one ID matches several symbols it returns the first (R prints a short message about how the IDs matched); where an ID has no symbol, the result is NA. The symbols are stored in a new column, symbol.

A common slip: some Ensembl IDs carry a version suffix, such as ENSG00000000003.14. The database expects the ID without the dot and number, so a file with versions gives NA for every gene until the suffix is removed. The airway IDs have no suffix, so this does not arise here.

Go deeper: when IDs and symbols do not match one to one

The mapping from Ensembl IDs to symbols is not perfectly one to one. Some IDs have no symbol and return NA. A few map to several symbols, and mapIds() keeps the first unless you ask otherwise with its multiVals argument, for example multiVals = "list". In the other direction, two Ensembl IDs can share one symbol, so the symbol column can contain duplicates.

That matters as soon as a symbol becomes a key. Row names must be unique and not missing, so rownames(df) <- df$symbol stops with an error, and a join by symbol can quietly double rows. Check with sum(is.na(df$symbol)) and sum(duplicated(na.omit(df$symbol))). Keep the Ensembl ID as the identifier throughout and use the symbol only as a label, as this lesson does. Mappings change between releases, so record the version of org.Hs.eg.db.

The volcano plot

R
top <- head(df[order(df$padj), ], 10)

ggplot(df, aes(x = log2FoldChange, y = -log10(padj), colour = status)) +
  geom_point(size = 1.2, alpha = 0.6) +
  geom_vline(xintercept = c(-1, 1), linetype = "dashed", colour = "grey50") +
  geom_hline(yintercept = -log10(0.05), linetype = "dashed", colour = "grey50") +
  geom_text_repel(data = top, aes(label = symbol), colour = "#0F1B33", size = 3.2) +
  scale_colour_manual(values = c(Up = "#D55E00", Down = "#0072B2",
                                 "Not significant" = "grey75")) +
  labs(x = "log2 fold change (dexamethasone vs untreated)",
       y = "-log10 adjusted p-value", colour = NULL) +
  theme_minimal(base_size = 13) + theme(legend.position = "top")

ggsave("airway_volcano.png", width = 7, height = 6, dpi = 300)

What this does

  • top holds the 10 genes with the smallest adjusted p-values: the table is sorted by padj and head(..., 10) keeps the first 10 rows.
  • The points, dashed threshold lines and axes are built exactly as in Omics figures: fold change across, −log10 padj up, coloured by status.
  • geom_text_repel(data = top, aes(label = symbol), ...) adds labels for those 10 genes only, using their symbols. ggrepel nudges labels away from each other and from the points, and draws a thin line back to the point when a label has to move far. size = 3.2 is in millimetres, ggplot2's unit for text inside the plot, which is roughly 9-point text.
  • scale_colour_manual() sets the Okabe–Ito vermilion for up, Okabe–Ito blue for down and light grey for the rest, the same colour-blind-safe pair as in Omics figures. Vermilion and blue differ in lightness as well as hue, so up and down stay distinct for readers with red–green colour blindness and in greyscale.
  • ggsave() without a plot argument saves the plot drawn most recently. Width and height are in inches here, the default unit, so the file is 7 × 300 = 2,100 by 6 × 300 = 1,800 pixels.
036912-4-2024log2 fold change−log10 adjusted pUp in tumourDown in tumour
Right means higher after treatment; higher up means stronger evidence. Illustrative data.

Reading the plot by region: the top-right corner holds genes that rose strongly with strong evidence; the top-left, genes that fell strongly with strong evidence. Points high up but near the centre changed only a little, though very reliably. Points far to the side but low down changed a lot on paper, with too little evidence to trust. If a labelled gene shows as NA, its ID had no symbol in the database; label it with its Ensembl ID instead.

Why −log10? Adjusted p-values for the strongest genes can be extremely small, such as 10−50, and on an ordinary axis they would all sit squashed against zero. Taking −log10 turns 0.05 into about 1.3, 10−5 into 5 and 10−50 into 50, so each step up the axis is ten times stronger evidence. It also flips the axis, so the best-supported genes rise to the top. One practical pitfall: if a padj is so small that R stores it as exactly 0, then -log10(0) is infinite and ggplot2 drops that point with a warning. Check with sum(df$padj == 0); if any are 0, say so in the caption rather than letting your most significant genes vanish.

The dashed lines are your thresholds drawn on the plot, not boundaries in the biology. A gene just inside the vertical line, at a log2 fold change of 0.95, is not meaningfully different from one at 1.05. Treat genes near the lines as borderline, and do not build a story on which side of a line a single gene fell.

The plot also separates statistical significance from biological significance. Statistical significance says the change is unlikely to be chance; it depends on the number of samples, the read depth and the noise, as well as on the size of the change. Biological significance asks whether the change matters to the cell: a 10% rise in a very abundant gene may be highly significant yet have no effect, while a twofold change in a transcription factor, a protein that controls other genes, may matter a great deal. The volcano plot cannot settle that question, but by showing effect size and evidence side by side it stops you from mistaking one for the other.

Heatmap of the top genes, and one gene up close

R
# the 20 strongest genes, each centred on its own mean
top20 <- rownames(df)[order(df$padj)][1:20]
mat <- assay(vsd)[top20, ]
mat <- mat - rowMeans(mat)
lim <- max(abs(mat))                    # symmetric limits around 0
pheatmap(mat, annotation_col = coldata[, c("dex", "cell")],
         annotation_colors = list(dex = c(untrt = "#0072B2", trt = "#E69F00")),
         labels_row = df[top20, "symbol"],
         color = colorRampPalette(c("#2166AC", "white", "#B2182B"))(100),
         breaks = seq(-lim, lim, length.out = 101))

# one gene: each donor's untreated and treated values, joined by a line
gene <- top20[1]
d <- plotCounts(dds, gene = gene, intgroup = c("dex", "cell"), returnData = TRUE)
ggplot(d, aes(x = dex, y = count)) +
  geom_boxplot(width = 0.4, outlier.shape = NA) +
  geom_line(aes(group = cell, colour = cell)) +
  geom_point(aes(colour = cell), size = 3) +
  scale_y_log10() +
  labs(x = NULL, y = "Normalised count (log scale)", title = df[gene, "symbol"]) +
  theme_minimal(base_size = 13)

What this does, block by block

  • Choosing genes. rownames(df)[order(df$padj)][1:20] sorts the gene IDs by adjusted p-value and keeps the first 20.
  • Values. assay(vsd)[top20, ] takes those 20 rows from the variance-stabilised data of RNA-seq counts and exploration, which are on a roughly log2 scale and suited to heatmaps.
  • Centring. mat - rowMeans(mat) subtracts each gene's own mean from its values. R matches the vector of 20 means to the 20 rows, so every row now averages 0. Unlike the z-scores of Module 3, the values are not divided by the standard deviation, so a difference of 1 still means roughly a doubling.
  • Heatmap. pheatmap() draws the matrix with treatment and donor bars above the columns, and labels_row replaces the Ensembl IDs with gene symbols. Because each row is centred on its own mean, 0 means "this gene's average" and the values run both ways, so the colours follow Colour that works for everyone: a diverging blue–white–red palette, with breaks from -lim to lim so that white sits exactly at 0 and equal changes up and down get equally strong colours. lim is the largest absolute value in mat, so no cell falls outside the scale. annotation_colors gives the treatment bar the Okabe–Ito blue and orange; the donor bar keeps pheatmap's default colours.
  • One gene. gene is the single gene with the smallest padj. plotCounts(..., returnData = TRUE) returns its normalised count in each sample, with the treatment and donor attached, as a data frame d.
  • Paired plot. The box plot summarises each treatment group. geom_line(aes(group = cell, ...)) joins the two samples from the same donor with one line, and the points are coloured by donor. scale_y_log10() uses a log axis, so equal fold changes look equally steep. The title is the gene's symbol.

The lines in the second plot make the paired design visible: if every donor's line slopes the same way, the effect is consistent across people.

Look at the heights too. If one donor's line sits well above the others but slopes the same way, that donor expresses more of this gene at baseline. That is the donor effect that cell in the design removes. A line sloping the opposite way would be worth a closer look before you trust the gene.

One caution about the heatmap. The 20 genes were chosen because they differ most clearly between treated and untreated samples, so of course the columns cluster by treatment. That clustering is a picture of the result, not further evidence for it. Choosing genes by a test and then showing that they separate the groups is circular. The unbiased check was the PCA of RNA-seq counts and exploration, which used the most variable genes without knowing the labels. Centring each row also hides how highly each gene is expressed; a gene with a baseMean of 50 and one with 50,000 can look identical, so check baseMean in df before comparing them.

From genes to biology

Look up your top genes in a resource such as GeneCards or NCBI Gene. You should find well-known glucocorticoid-response genes, such as FKBP5, KLF15, DUSP1 and ZBTB16, among the genes higher after treatment. Finding expected biology is good evidence that the analysis worked.

Two of these show why such genes respond. FKBP5 makes a protein that binds the glucocorticoid receptor complex and makes it less sensitive, so its induction is part of a feedback loop that limits the response. DUSP1 makes a phosphatase, an enzyme that removes phosphate groups, which switches off signalling pathways involved in inflammation; its induction is one route by which glucocorticoids damp inflammation. A result that recovers genes like these is behaving as decades of earlier work predict. If none appeared, you would check the sample labels before anything else.

Recovering known genes is a check, not a discovery. The interesting genes are often those further down the list that nobody has linked to glucocorticoids before. A result from a study of four donors is a hypothesis for those genes, which needs an independent experiment, such as measuring the RNA by quantitative PCR in new samples, before anyone should rely on it. The published airway study followed up CRISPLD2, the gene named in its title, with further laboratory experiments.

Gene Ontology enrichment asks a broader question: are genes with a particular function over-represented among your significant genes, more than chance would give? It turns a list of hundreds of genes into a handful of processes.

The Gene Ontology (GO) is a shared vocabulary of terms describing what genes do, with each gene annotated to the terms that apply to it. Terms are grouped into three domains: biological process (such as "response to glucocorticoid"), molecular function (such as "DNA binding") and cellular component (where in the cell the product acts).

Worked example · what enrichment means

genes tested: 20,000 · of which in “response to glucocorticoid”: 200 (1%)
significant genes: 500 → expected by chance: 500 × 1% = 5
observed in the term: 25 → 5 times more than expected

Step by step. First the background share: 200 ÷ 20,000 = 0.01, or 1%. If the 500 significant genes were drawn at random from the 20,000, about 1% of them, 500 × 0.01 = 5, would belong to the term. The list actually contains 25, and 25 ÷ 5 = 5, a fivefold enrichment.

What the answer means. A fivefold excess is unlikely to be chance, so the term describes something the treatment really does. The usual test is the hypergeometric test, which gives the probability of drawing 25 or more term genes in a random sample of 500. Because thousands of terms are tested, those p-values are adjusted, as with genes.

Enrichment tests ask whether a difference like this is larger than chance, and adjust for testing thousands of terms. The numbers here are for illustration.

Volcano plot and interpretation · LSMA free course Two grids of 100 squares, each square standing for 5 of the 500 significant genes. In the expected grid, 1 square (5 genes) belongs to the term. In the observed grid, 5 squares (25 genes) belong to it, five times more than expected. 500 SIGNIFICANT GENES · EACH SQUARE = 5 GENES Expected by chance: 5 1% of 500 Observed: 25 5 times more than expected
Vermilion squares are genes in "response to glucocorticoid"; grey squares are the other significant genes. The numbers are the illustrative ones from the worked example. Schematic.
R · optional
BiocManager::install("clusterProfiler")     # once
library(clusterProfiler)

up <- rownames(df)[df$status == "Up"]
ego <- enrichGO(gene = up, universe = rownames(df), OrgDb = org.Hs.eg.db,
                keyType = "ENSEMBL", ont = "BP")
head(as.data.frame(ego))
dotplot(ego, showCategory = 10)

What this does

  • The first two lines install (once) and load clusterProfiler, a Bioconductor package for enrichment analysis.
  • up is the list of Ensembl IDs of genes labelled "Up".
  • enrichGO() tests every GO term for over-representation among those genes. universe = rownames(df) sets the background: all genes that were tested, not all human genes. OrgDb and keyType tell it which database to use and that the IDs are Ensembl IDs. ont = "BP" restricts the test to biological process terms.
  • head(as.data.frame(ego)) shows the first rows of the result table, one row per enriched term with its description, the number of genes involved and adjusted p-values.
  • dotplot(ego, showCategory = 10) draws the top 10 terms, with dot size showing how many genes fall in each term and colour showing the adjusted p-value.

The background matters more than it looks. Genes not expressed in airway muscle cells could never appear in your list. If the background were the whole genome, any term full of muscle-expressed genes would look enriched only because those genes were the only ones that could be detected. Using the tested genes as the universe avoids that bias.

Testing up and down genes separately, as here with up, usually gives clearer answers than pooling them, because genes switched on and genes switched off by a treatment often do different jobs. Read the result with the same care as the gene list: a term supported by three or four genes is weak, however small its adjusted p-value, and a very general term such as "response to stimulus" says little. Look at which of your genes drive each term; as.data.frame(ego) lists them in its geneID column.

The Gene Ontology was introduced in Ashburner et al. 2000, "Gene Ontology: tool for the unification of biology" (Nature Genetics). clusterProfiler was first described in Yu et al. 2012 (OMICS) and has been updated since; citation("clusterProfiler") gives the papers its authors currently ask you to cite. GO annotations are revised continually, so enrichment results depend on the version of org.Hs.eg.db and of the GO data inside it. Report those versions, the background (universe) you used and the adjustment method. Related terms overlap heavily, so a top list often repeats one finding several times under different names; read it as themes, not as independent discoveries.

Template

Differential expression between dexamethasone-treated and untreated airway smooth muscle cells was tested with DESeq2 (version __), adjusting for donor. Genes with an adjusted p-value below 0.05 and an absolute log2 fold change above 1 were considered significant: __ genes were higher and __ lower after treatment (Figure 1). Known glucocorticoid-response genes, including __, were among the most strongly induced.

To fill the blanks: the version is the DESeq2 version installed when you ran the analysis, which R can report for any package; the two counts come from your table(df$status) output; and the genes are those you confirmed in GeneCards or NCBI Gene. Notice the template also names every choice a reader would need to repeat the work: the comparison, the adjustment for donor, and both cut-offs. For a methods section, add the filtering rule from RNA-seq counts and exploration and that fold changes were shrunk with apeglm.

The GO analysis in this lesson starts from a list cut at padj and fold-change thresholds. Two points take it further. The choice of background genes can change the answer, which is why the code passes every tested gene as universe. And gene set enrichment analysis (GSEA) avoids the cut-off by using the ranking of every gene; Subramanian and colleagues (2005), in the further reading, describe it.

Further reading · Module 4Love, Huber & Anders 2014: the method, and why it shrinks fold changes. · All reading for this course

Check your understanding

1. A point sits in the top-right corner of the volcano plot. What does it mean?

2. Why centre each gene on its own mean in the heatmap?

3. 1% of genes belong to a term and you have 400 significant genes. How many would you expect in the term by chance?

Up next

Project

Counts to results

Ask BioTutor

Create a free website with Framer, the website builder loved by startups, designers and agencies.