bio-pathway-kegg-pathways
KEGG pathway and module enrichment analysis using clusterProfiler enrichKEGG and enrichMKEGG. Use when identifying metabolic and signaling pathways over-represented in a gene list. Supports 4000+ organisms via KEGG online database.
What this skill does
## Version Compatibility
Reference examples tested with: R stats (base), clusterProfiler 4.10+
Before using code patterns, verify installed versions match. If versions differ:
- R: `packageVersion('<pkg>')` then `?function_name` to verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
# KEGG Pathway Enrichment
## Core Pattern
**Goal:** Identify KEGG metabolic and signaling pathways over-represented in a gene list.
**Approach:** Test for enrichment using the hypergeometric test via clusterProfiler enrichKEGG against the KEGG online database.
**"Find enriched KEGG pathways in my gene list"** -> Test whether KEGG pathway gene sets are over-represented among significant genes.
```r
library(clusterProfiler)
kk <- enrichKEGG(
gene = gene_list, # Character vector of gene IDs
organism = 'hsa', # KEGG organism code
pvalueCutoff = 0.05,
pAdjustMethod = 'BH'
)
```
## Prepare Gene List
**Goal:** Extract significant Entrez gene IDs from DE results in the format required by enrichKEGG.
**Approach:** Filter by significance thresholds and convert gene symbols to Entrez IDs (KEGG requires NCBI Entrez).
```r
library(org.Hs.eg.db)
de_results <- read.csv('de_results.csv')
sig_genes <- de_results$gene_id[de_results$padj < 0.05 & abs(de_results$log2FoldChange) > 1]
# KEGG requires NCBI Entrez gene IDs (kegg, ncbi-geneid)
gene_ids <- bitr(sig_genes, fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db)
gene_list <- gene_ids$ENTREZID
```
## KEGG ID Conversion
**Goal:** Convert between KEGG-specific identifiers and other gene ID formats.
**Approach:** Use bitr_kegg to map between kegg, ncbi-geneid, ncbi-proteinid, and uniprot ID types.
```r
# Convert between KEGG and other IDs
kegg_ids <- bitr_kegg(gene_list, fromType = 'ncbi-geneid', toType = 'kegg', organism = 'hsa')
# Available types: kegg, ncbi-geneid, ncbi-proteinid, uniprot
```
## Run KEGG Pathway Enrichment
**Goal:** Perform KEGG pathway over-representation analysis with customizable parameters.
**Approach:** Run enrichKEGG with specified organism, ID type, and statistical thresholds.
```r
kk <- enrichKEGG(
gene = gene_list,
organism = 'hsa',
keyType = 'ncbi-geneid', # or 'kegg'
pvalueCutoff = 0.05,
pAdjustMethod = 'BH',
minGSSize = 10,
maxGSSize = 500
)
# View results
head(kk)
results <- as.data.frame(kk)
```
## Make Results Readable
```r
# enrichKEGG does NOT have readable parameter - use setReadable
library(org.Hs.eg.db)
kk_readable <- setReadable(kk, OrgDb = org.Hs.eg.db, keyType = 'ENTREZID')
```
## KEGG Module Enrichment
**Goal:** Test for enrichment of KEGG modules (smaller functional units than pathways).
**Approach:** Use enrichMKEGG which tests against KEGG module definitions rather than full pathways.
```r
# KEGG modules are smaller functional units than pathways
mkk <- enrichMKEGG(
gene = gene_list,
organism = 'hsa',
pvalueCutoff = 0.05
)
```
## Common Organism Codes
| Code | Organism | Notes |
|------|----------|-------|
| hsa | Human (Homo sapiens) | |
| mmu | Mouse (Mus musculus) | |
| rno | Rat (Rattus norvegicus) | |
| dre | Zebrafish (Danio rerio) | |
| dme | Fruit fly (Drosophila) | |
| cel | Worm (C. elegans) | |
| sce | Yeast (S. cerevisiae) | |
| ath | Arabidopsis thaliana | |
| eco | E. coli K-12 | Bacterial |
| pae | P. aeruginosa PAO1 | Bacterial |
| bsu | B. subtilis 168 | Bacterial |
| sau | S. aureus N315 | Bacterial |
| mtc | M. tuberculosis H37Rv | Bacterial |
| ko | KEGG Orthology | Cross-species, use with KO IDs |
KEGG covers 8,000+ organisms. Always verify the code for the specific strain:
```r
search_kegg_organism('Pseudomonas', by = 'scientific_name')
search_kegg_organism('aeruginosa', by = 'scientific_name')
```
## Background Universe (Critical)
**Goal:** Restrict KEGG enrichment to genes actually measured in the experiment.
**Approach:** Convert all tested genes to Entrez IDs and pass as the universe parameter.
Without specifying the universe, enrichKEGG uses all KEGG-annotated genes as background. This inflates significance for tissue-specific pathways (e.g., liver-expressed pathways in a liver RNA-seq experiment will appear enriched simply because liver genes are expressed and brain genes are not).
```r
# Background = all tested genes (non-NA pvalue from DE analysis)
all_tested <- de_results$gene_id[!is.na(de_results$pvalue)]
universe_ids <- bitr(all_tested, fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db)
kk <- enrichKEGG(
gene = gene_list,
universe = universe_ids$ENTREZID,
organism = 'hsa',
pvalueCutoff = 0.05
)
```
## Extract and Export Results
**Goal:** Save KEGG enrichment results to CSV and extract genes belonging to specific pathways.
**Approach:** Convert enrichment object to data frame, export, and access pathway gene sets via the geneSets slot.
```r
# Convert to data frame
results_df <- as.data.frame(kk)
# Key columns: ID (pathway), Description, GeneRatio, BgRatio, pvalue, p.adjust, geneID, Count
# Export
write.csv(results_df, 'kegg_enrichment_results.csv', row.names = FALSE)
# Get genes in a specific pathway
pathway_genes <- kk@geneSets[['hsa04110']] # Cell cycle
```
## Browse KEGG Pathways
**Goal:** Visualize enriched genes overlaid on KEGG pathway diagrams.
**Approach:** Use browseKEGG for interactive browser view or pathview to generate annotated pathway images.
```r
# View pathway in browser (opens KEGG website)
browseKEGG(kk, 'hsa04110')
# Download pathway image
library(pathview)
pathview(gene.data = gene_list, pathway.id = 'hsa04110', species = 'hsa')
```
## Key Parameters
| Parameter | Default | Description |
|-----------|---------|-------------|
| gene | required | Vector of gene IDs |
| organism | hsa | KEGG organism code |
| keyType | kegg | Input ID type |
| pvalueCutoff | 0.05 | P-value threshold |
| qvalueCutoff | 0.2 | Q-value threshold |
| pAdjustMethod | BH | Adjustment method |
| universe | NULL | Background genes |
| minGSSize | 10 | Min genes per pathway |
| maxGSSize | 500 | Max genes per pathway |
| use_internal_data | FALSE | Use local KEGG data |
## Compare Multiple Gene Lists
**Goal:** Compare KEGG pathway enrichment across multiple gene lists (e.g., upregulated vs downregulated).
**Approach:** Use compareCluster with enrichKEGG to run enrichment per group and visualize with dotplot.
```r
# Compare KEGG enrichment across groups
gene_lists <- list(
up = up_genes,
down = down_genes
)
ck <- compareCluster(
geneClusters = gene_lists,
fun = 'enrichKEGG',
organism = 'hsa'
)
dotplot(ck)
```
## Prokaryotic / Non-Model Organism KEGG
Bacteria and non-model organisms do NOT use org.*.eg.db packages or bitr(). Bacterial genes use locus tags (e.g., PA0001 for P. aeruginosa, b0001 for E. coli) that map directly as KEGG gene IDs.
```r
# Bacterial KEGG ORA -- no bitr() or OrgDb needed
# Gene IDs should be locus tags matching the KEGG genome
kegg_bac <- enrichKEGG(
gene = sig_locus_tags, # e.g., c('PA0001', 'PA0612', 'PA3476')
organism = 'pae', # P. aeruginosa PAO1
keyType = 'kegg', # use locus tags directly
pvalueCutoff = 0.05,
pAdjustMethod = 'BH'
)
# Note: setReadable() requires an OrgDb which does not exist for most bacteria
# Instead, map gene IDs manually or use KEGG gene names from the result
```
For organisms without KEGG strain-specific annotation, use KEGG Orthology (KO) with organism = 'ko'. Map genes to KO IDs via eggNOG-mapper or BlastKOALA first.
## Multi-Condition Comparison
**Goal:** Find shared and condition-specific enriched pathways across experimental conditions.
**Approach:** Run enrichKEGG per condition, then use set operations on significant pathway IDs. Do NOT compare p-values across conditions (they depend on sample size and DE gene count).
```r
# Run enrichmeRelated in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.