This skill turns an enrichment result object (an enrichResult from ORA, a gseaResult from GSEA, or a compareClusterResult) into a figure with the enrichplot package. The central decision is not which plotting function to call but how to handle gene-set REDUNDANCY: a default top-20 GO dotplot is usually one biological theme drawn twenty times, because the GO DAG and nested pathway databases guarantee that a real signal surfaces as a cluster of near-identical overlapping terms. The figure either SHOWS that redundancy as structure (emapplot/treeplot via pairwise_termsim, or EnrichmentMap) or DELETES it (simplify/REVIGO). The skill also covers keeping the NES sign for GSEA, distinguishing GeneRatio from fold enrichment, and admitting that showCategory truncates.
if (!require('BiocManager', quietly = TRUE))
install.packages('BiocManager')
BiocManager::install(c('clusterProfiler', 'enrichplot', 'org.Hs.eg.db'))
BiocManager::install(c('GOSemSim', 'ggplot2'))
install.packages(c('ggridges', 'ggarchery')) # ridgeplot needs ggridges; goplot needs ggarchery (enrichplot Suggests-only)
Conceptual prerequisites and notes:
- The input is an enrichResult / gseaResult / compareClusterResult produced by the sibling skills (go-enrichment, gsea, kegg-pathways, reactome-pathways, wikipathways), not a raw gene list.
- ridgeplot() and goplot() depend on packages enrichplot only Suggests (ggridges and ggarchery); a stock install errors with the package ... is required until they are installed (above).
- enrichplot 1.25.5+ moved cnetplot/emapplot/goplot to the ggtangle backend and removed several arguments (circular, colorEdge, cex_label_gene, cex_label_category, group_category). Introspect with ?cnetplot / ?emapplot and adapt; do not copy pre-2024 tutorial arguments verbatim.
- emapplot and treeplot read the @termsim slot and do NOT compute it - run pairwise_termsim() first, every time.
- There is no barplot method for gseaResult by design; GSEA results are signed and a bar cannot carry a sign.
- The plots are offline once the objects exist; building KEGG/WikiPathways objects upstream needs internet (see those skills).
Tell your AI agent what you want to do: - "Make a dotplot of my GO enrichment, collapsing redundant terms first" - "Show the redundant terms as clusters with an enrichment map" - "Plot my GSEA results keeping the direction (activated vs suppressed)" - "Show a GSEA running-score plot for my top pathway"
"My enrichGO BP result has 180 significant terms and the top-20 dotplot is full of cell-cycle synonyms. Collapse the GO-DAG redundancy with simplify(), then dotplot the top 20, and tell me how many terms survived."
"I have an enrichResult with many overlapping terms. Run pairwise_termsim and draw an enrichment map so I can see which terms are really one biological theme, and a treeplot with five named clusters."
"Make a dotplot of my GO results ordered by fold enrichment instead of GeneRatio, and explain why the two orderings differ."
"Build a gene-concept network for my top 6 enriched terms colored by log2 fold change so I can see which genes bridge multiple terms."
"Plot my gseaResult as a ridgeplot showing the leading-edge distribution per set, keeping direction, and a gseaplot2 for the single most significant pathway."
"Show the running enrichment score for my top three GSEA pathways overlaid in one panel with the stats table."
"I ran compareCluster across up- and down-regulated genes. Make a faceted dotplot comparing the two."
"Save my enrichment dotplot as a publication-quality PDF with a viridis color scale and a caption noting the total significant term count."
| Plot | Function | Class | Owns |
|---|---|---|---|
| Dot plot | dotplot() | ORA + GSEA | three-channel summary; default x = GeneRatio |
| Bar plot | barplot() | ORA only | unsigned count/ratio; no GSEA method |
| Gene-concept net | cnetplot() | ORA + GSEA | shared genes across terms; direction by item color |
| Enrichment map | emapplot() | ORA + GSEA | term clusters = redundancy shown (needs pairwise_termsim) |
| Tree | treeplot() | ORA + GSEA | deterministic Ward clusters (needs pairwise_termsim) |
| Ridge | ridgeplot() | GSEA only | leading-edge metric density, direction preserved |
| Running score | gseaplot2() | GSEA only | ES curve + hit ticks + ranked metric |
| Upset | upsetplot() | ORA + GSEA | gene-overlap combinations (boxplots for GSEA) |
| GO DAG | goplot() | GO only | induced DAG subgraph |
| Heatmap | heatplot() | ORA + GSEA | gene x term matrix by fold change |