Pathway Enrichment Workflow

GO and Reactome over-representation analysis with clusterProfiler

What it does

This workflow demonstrates pathway enrichment analysis with clusterProfiler, combining Gene Ontology over-representation testing with Reactome pathway analysis and several standard visualization patterns. The committed materials include a README, an R Markdown tutorial, and a rendered HTML example based on an example gene list.

When to use it

Use this workflow when you already have a gene list and want a lab reference for quickly running GO Biological Process and Reactome enrichment in R, then visualizing the results with bar plots, dot plots, gene-concept networks, and enrichment maps. It works best as a downstream interpretation branch rather than as a standalone preprocessing workflow.

Prerequisites

Steps

Load the enrichment packages and map symbols to Entrez IDs

The tutorial begins by loading the package stack, defining an example gene-symbol vector, and converting those symbols to Entrez IDs with bitr(). It also loads geneList from DOSE as the background universe for the example.

library(tidyverse)
library(clusterProfiler)
library(ggplot2)
library(org.Hs.eg.db)
example_gene_mapping <- bitr(
  example_gene_list,
  fromType = "SYMBOL",
  toType = "ENTREZID",
  OrgDb = "org.Hs.eg.db"
)

example_gene_id <- example_gene_mapping$ENTREZID
data(geneList, package = "DOSE")

The README frames this as a general enrichment pattern, but the committed example is specifically configured around human annotation and the DOSE example background list.

Run GO Biological Process over-representation analysis

The first enrichment branch uses enrichGO() to test Biological Process terms with Benjamini-Hochberg correction and matching pvalueCutoff and qvalueCutoff thresholds of 0.05.

gobp_result <- enrichGO(
  gene = example_gene_id,
  universe = names(geneList),
  OrgDb = org.Hs.eg.db,
  ont = "BP",
  pAdjustMethod = "BH",
  pvalueCutoff = 0.05,
  qvalueCutoff = 0.05,
  readable = TRUE
)
head(gobp_result)

The README also notes that the ontology can be switched among BP, MF, and CC depending on the interpretation goal.

Run Reactome pathway enrichment on the same gene set

The second branch uses ReactomePA::enrichPathway() on the same Entrez ID set, creating a complementary pathway-focused result object alongside the GO terms.

library(ReactomePA)
reactome_result <- enrichPathway(
  gene = example_gene_id,
  pvalueCutoff = 0.05,
  readable = TRUE
)
head(reactome_result)

This makes the workflow a good fit for situations where both ontology-style interpretation and curated pathway interpretation are useful.

Visualize enriched terms with bar plots and dot plots

The committed tutorial’s first visualization stage creates a GO bar plot based on -log10(adjusted p-value) and a Reactome dot plot showing up to 30 categories.

mutate(gobp_result, qscore = -log(p.adjust, base = 10)) %>%
  barplot(x = "qscore")
dotplot(reactome_result, showCategory = 30) +
  ggtitle("dotplot for result")

These are the simplest reusable summaries in the folder and are usually the best first check before moving to network visualizations.

Explore gene-concept networks and enrichment maps

The later sections use cnetplot() to show category-gene relationships and emapplot() after pairwise_termsim() to organize related enriched pathways into a similarity map.

p1 <- cnetplot(reactome_result, node_label = "category", cex_label_category = 1.2)
p2 <- cnetplot(reactome_result, node_label = "gene", cex_label_gene = 0.8)
cowplot::plot_grid(p1, p2, ncol = 2, labels = LETTERS[1:2])
library(enrichplot)
edo <- pairwise_termsim(reactome_result)
emapplot(edo, layout = "kk")

The committed HTML output in the folder preserves one rendered version of this example analysis, but the site page keeps execution disabled and reuses only the committed code and prose.

Gotchas / notes

  • This workflow is centered on a toy/example gene list rather than a committed experiment-specific dataset.
  • The example uses org.Hs.eg.db, so users working on another species need to adapt the annotation database and ID mapping strategy.
  • The folder contains a committed rendered HTML example, but the Quarto site does not re-execute the R Markdown.
  • The R Markdown leaves a few empty trailing chunks, which do not add extra analysis content.

📄 View source on GitHub