L07 — Functional Analysis: Turning DE Lists into Biology

Bill Cresko

Where this lecture fits

Goals of this lecture

  • Read a DE table and ask “what biological themes are enriched here?”
  • Distinguish over-representation analysis (ORA) from gene-set enrichment analysis (GSEA) and know when to use each
  • Pick the right ontology / database — GO BP, GO MF, Reactome, KEGG, MSigDB Hallmark
  • Read enrichment plots — bar plot, dot plot, GSEA running enrichment, compareCluster cross-cell-type plot
  • Avoid the most common pitfalls (background-set mistakes, multiple-testing burden, redundant terms)

Note

Mental model.

  • Pseudobulk DE (Lec 06) gave you a long list of genes that change between conditions, per cell type.
  • Functional analysis is the next zoom-out: instead of asking “which genes?”, you ask “which biological processes?”
  • Collapsing thousands of genes into dozens of interpretable themes.

Why functional analysis (FA) — gene regulation in context

Mechanisms overview — raster reference
  • DE gives a list of genes; FA asks which biological mechanisms link them
  • Gene regulation operates across multiple layers: TFs, chromatin, signalling, post-transcriptional control
  • Pathway databases collapse these layers into named gene sets we can test

ORA vs. GSEA

Method Question Input
Over-Representation Analysis (ORA) Among my significant genes, are any biological terms over-represented relative to a background? A list (set) of significant gene IDs + a “universe”
Gene-Set Enrichment Analysis (GSEA) When my genes are ranked by direction-and-strength of change, do any term’s genes cluster at the top or bottom? A ranked vector of all tested genes
  • Both methods exist for the same reason:
  • To take ~thousands of genes and ask “what do they have in common, biologically?”

Tip

Decision rule.

  • If you have a clean cutoff (e.g. padj < 0.05 & |log2FC| > 1) and the list is moderate-sized (50–500), start with ORA. - If your effect is broad-but-modest (the entire ISG family slightly up, no single super-significant gene), GSEA is more sensitive.
  • Run both when you can.

ORA — the hypergeometric test

For each gene set \(S\), count:

  • \(k\) = number of genes in both my significant list AND \(S\)
  • \(n\) = number in \(S\) ∩ universe
  • \(K\) = number in my significant list
  • \(N\) = number in universe

Compute \(P(X \ge k)\) under the hypergeometric null, then adjust for multiple sets with BH.

ORA — the hypergeometric test

  • The IFN-related terms dominate (because the contrast is IFN-β stimulation).
  • Cell-cycle and housekeeping show modest enrichment but at much lower significance.

GSEA — using the whole ranking

  • The peak running ES is the ES for that set
  • Its statistical significance comes from a permutation test, with NES (Normalized ES) reported alongside.

When each wins

Scenario ORA GSEA
Strong, well-separated effect (a few hits with log2FC > 4)
Coordinated, modest effect across a whole pathway (e.g. ISGs slightly up) weak
Threshold sensitivity matters (results jump when you change the FDR cutoff)
Your list of “significant” genes is short (<20)
You want a “the X genes are enriched in Y” headline

Part 2 — Picking a database

The catalog

Database Strength When to start here
GO BP (biological process) Comprehensive, hierarchical, well-curated Always run as a baseline
GO MF / CC (molecular function / cellular component) Function & localization When BP is dominated by generic terms
Reactome Curated signaling pathways; modern Immune / signaling biology
KEGG Classic metabolic + signaling Metabolism; legacy comparison
MSigDB Hallmark 50 well-known, broad biological states Headline figures, low-noise summaries
WikiPathways Community-curated, fast updates Niche pathways missing elsewhere
Cell Ontology / Cell Marker DB Cell-type marker enrichment When testing “is this an X-type cell?”

The redundancy problem

GO BP has ~30,000 terms; many overlap heavily. After ORA you’ll see 50 hits like:

response to virus / type I interferon signaling pathway / cellular response to type I interferon / regulation of type I interferon signaling pathway / response to interferon-beta / …

These are the same biology described eight ways.

Three fixes

  • Use a smaller, curated database for the headline (MSigDB Hallmark — only 50 sets), then GO BP for the mechanistic detail
  • Cluster similar terms with enrichplot::pairwise_termsim() + treeplot() — collapse the tree into themes
  • Apply a stricter cutoff (pvalueCutoff = 0.01, qvalueCutoff = 0.05) so the top 5 terms aren’t 50 redundant ones

Run multiple databases — find the consensus

  • Cross-database agreement is your strongest signal that a finding is real biology rather than a database artifact.

Part 3 — Cross-cell-type comparison

The dot plot is your (informative) friend

The dot plot is your (informative) friend

Reading rules:

  • Color = strength of enrichment (more saturated = more significant)
  • Size = how many genes from the cell type’s DE list overlap that term
  • A row that lights up across every cell type → the shared core response (here: type I IFN signaling)
  • A row that lights up in only some cell types → cell-type-specific biology (here: antigen presentation in monocytes + B cells, T-cell activation in T cells only)

Tip

  • The compareCluster plot is a very informative figure in cross-cell-type functional analysis.
  • Lead with this in your manuscript figures; the per-cell-type bar plots are supplementary.

Part 4 — Common pitfalls

The five mistakes that bite

  1. Wrong universe. Default = “all annotated genes in the genome”.
  • Correct = “all genes you tested in DESeq2” (after low-count filter).
  • The wrong universe inflates “common term” p-values.
  1. Treating all enriched terms as biology.
  • Many GO terms are technical artifacts (mitochondrial, ribosomal, cell-cycle).
  • If they top your list and you didn’t expect them, suspect QC.
  1. No multiple-testing correction across databases.
  • ORA across 4 databases × 30,000 terms = 120,000 tests.
  • BH correction inside each database; don’t forget to mention the database in your reported p-value.
  1. Reporting raw p-values.
  • Always report p.adjust (BH) or q-value.
  1. Ignoring direction in ORA.
  • ORA on “all DE genes” doesn’t distinguish up-regulated from down-regulated.
  • Run separately on each side, or use GSEA which handles this naturally.

Part 5 — A workable workflow

Tools we use

  • clusterProfiler (R) — the workshop default. Handles ORA + GSEA + Reactome + KEGG + MSigDB in one API.
  • enrichplot — the visualization companion to clusterProfiler. dotplot, cnetplot, emapplot, treeplot, gseaplot2.
  • fgsea — extremely fast pure-GSEA implementation; useful when clusterProfiler is too slow.
  • gprofiler2 (R / Python) — alternative web API; multi-organism support out of the box.

Recap & what’s next

What to remember from Lecture 07

  • ORA asks “which terms are over-represented in my significant list?”; GSEA asks “where do the term’s genes sit in my full ranking?”
  • Always run multiple databases and look for consensus
  • Always pass a correct universe to ORA — your tested genes, not the whole genome
  • The compareCluster dot plot across cell types is the single best summary figure
  • ORA + GSEA + a compareCluster plot, on three databases, with a careful read of top hits — that’s the full functional-analysis pipeline

Coming up next

Further reading