Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Visualize enrichment results using enrichplot package functions. Use when creating publication-quality figures from clusterProfiler results. Covers dotplot, barplot, cnetplot, emapplot, gseaplot2, ridgeplot, and treeplot.
.claude/skills/bio-pathway-enrichment-visualization/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-05 | ✗→✓ | ▲ Improved | — | — |
| case-12 | ✗→✓ | ▲ Improved | — | — |
| case-03 | ✗→✓ | ▲ Improved | — | — |
| case-01 | ✓→✓ | = Same ✓ | — | — |
| case-06 | ✓→✓ | = Same ✓ | — | — |
Reference examples tested with: ggplot2 3.5+
Before using code patterns, verify installed versions match. If versions differ:
packageVersion('<pkg>') then ?function_name to verify parametersIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
"Create publication-quality plots from my enrichment analysis" → Generate dotplots, gene-concept networks, enrichment maps, GSEA running score plots, and ridgeplots from clusterProfiler results.
dotplot(), cnetplot(), emapplot(), gseaplot2() (enrichplot)This skill covers enrichplot package functions designed for clusterProfiler results:
dotplot(), barplot() - Summary viewscnetplot(), emapplot(), treeplot() - Network/hierarchical viewsgseaplot2(), ridgeplot() - GSEA-specificgoplot(), heatplot(), upsetplot() - Specialized viewsFor custom ggplot2 enrichment dotplots (manual implementation), see data-visualization/specialized-omics-plots.
Goal: Load required packages for visualizing enrichment analysis results.
Approach: Import clusterProfiler, enrichplot, and ggplot2 which provide the plotting functions for enrichment objects.
rlibrary(clusterProfiler) library(enrichplot) library(ggplot2) # Assume ego (enrichGO result), kk (enrichKEGG result), or gse (GSEA result) exists
Goal: Summarize enrichment results showing gene ratio, count, and significance in a single figure.
Approach: Use enrichplot dotplot which maps gene ratio to x-axis, term to y-axis, dot size to count, and color to p-value.
Most common visualization - shows gene ratio, count, and significance.
rdotplot(ego, showCategory = 20) # Customize dotplot(ego, showCategory = 15, font.size = 10, title = 'GO Enrichment') + scale_color_gradient(low = 'red', high = 'blue') # Save pdf('go_dotplot.pdf', width = 10, height = 8) dotplot(ego, showCategory = 20) dev.off()
Shows enrichment count or gene ratio.
rbarplot(ego, showCategory = 20) # Customize barplot(ego, showCategory = 15, x = 'GeneRatio', color = 'p.adjust')
Goal: Visualize which genes contribute to multiple enriched terms, revealing shared biology.
Approach: Build a bipartite network connecting enriched terms to their member genes, optionally colored by fold change.
Shows relationships between genes and enriched terms.
r# Basic cnetplot cnetplot(ego) # With fold change colors cnetplot(ego, foldChange = gene_list) # Circular layout cnetplot(ego, circular = TRUE, colorEdge = TRUE) # Customize node size cnetplot(ego, node_label = 'gene', cex_label_gene = 0.8)
Goal: Identify clusters of related enriched terms by visualizing shared gene overlap.
Approach: Compute pairwise term similarity, then plot as a network where edges connect terms sharing genes.
Shows term-term relationships based on shared genes.
r# Requires pairwise_termsim first ego_pt <- pairwise_termsim(ego) emapplot(ego_pt) # Customize emapplot(ego_pt, showCategory = 30, cex_label_category = 0.6) # Cluster by similarity emapplot(ego_pt, group_category = TRUE, group_legend = TRUE)
Hierarchical clustering of enriched terms.
rego_pt <- pairwise_termsim(ego) treeplot(ego_pt) # Show more categories treeplot(ego_pt, showCategory = 30)
Show overlapping genes between terms.
rupsetplot(ego) # Limit to specific number of terms upsetplot(ego, n = 10)
r# Single gene set gseaplot2(gse, geneSetID = 1, title = gse$Description[1]) # Multiple gene sets gseaplot2(gse, geneSetID = 1:3) # With subplots gseaplot2(gse, geneSetID = 1, subplots = 1:3) # By term ID gseaplot2(gse, geneSetID = 'GO:0006955')
Distribution of fold changes in gene sets.
rridgeplot(gse) # Top n gene sets ridgeplot(gse, showCategory = 15) # Order by NES ridgeplot(gse, showCategory = 20) + theme(axis.text.y = element_text(size = 8))
DAG structure of GO terms.
r# Only for GO enrichment results goplot(ego) # Specific ontology goplot(ego_bp) # where ego_bp is enrichGO with ont='BP'
Gene-concept heatmap.
rheatplot(ego, foldChange = gene_list) # Customize heatplot(ego, showCategory = 15, foldChange = gene_list)
Goal: Visualize enrichment results side by side across multiple gene lists or conditions.
Approach: Use dotplot on compareCluster output, optionally faceting by cluster.
r# Compare clusters (from compareCluster) dotplot(ck, showCategory = 10) # Facet by cluster dotplot(ck) + facet_grid(~Cluster)
Goal: Fine-tune enrichment plots with custom titles, themes, colors, and text sizes.
Approach: Chain ggplot2 modifiers onto enrichplot output since all functions return ggplot2 objects.
All enrichplot functions return ggplot2 objects.
rp <- dotplot(ego, showCategory = 20) # Add title p + ggtitle('GO Biological Process Enrichment') # Change theme p + theme_minimal() # Adjust text p + theme(axis.text.y = element_text(size = 10)) # Change colors p + scale_color_viridis_c()
Goal: Export enrichment plots as publication-quality PDF or PNG files.
Approach: Use base R pdf/png device functions or ggplot2 ggsave to write plots to files.
r# PDF (vector, publication quality) pdf('enrichment_plots.pdf', width = 10, height = 8) dotplot(ego, showCategory = 20) dev.off() # PNG (raster) png('dotplot.png', width = 800, height = 600, res = 100) dotplot(ego, showCategory = 20) dev.off() # Using ggsave p <- dotplot(ego) ggsave('dotplot.pdf', p, width = 10, height = 8)
| Function | Best For | Input Type | |----------|----------|------------| | dotplot | Overview of enrichment | ORA, GSEA | | barplot | Simple counts/ratios | ORA | | cnetplot | Gene-term relationships | ORA | | emapplot | Term clustering | ORA | | treeplot | Hierarchical grouping | ORA | | upsetplot | Term overlap | ORA | | gseaplot2 | Running enrichment score | GSEA | | ridgeplot | Fold change distribution | GSEA | | goplot | GO DAG structure | GO only | | heatplot | Gene-concept matrix | ORA |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-05 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-15 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-16 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-17 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-19 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-02 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-01 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-12 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-20 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-04 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-21 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-06 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-11 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-07 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-09 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-03 | fail→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-22 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-18 | pass→pass | — | — | — | — | — | — | — | — | — | — | — | — |
case-10 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-13 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-08 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
case-14 | fail→fail | — | — | — | — | — | — | — | — | — | — | — | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
The per-case answers from this run were removed by the retention sweep, so the case table below shows the verdicts without the text either arm produced. The counts above were recorded at the time and are unaffected. Answers are now kept for 180 days.
Other measured skills in the registry, with their headline benchmark lift.