| name | bio-metabolomics-pathway-mapping |
| description | Map metabolites to biological pathways using KEGG, Reactome, and MetaboAnalyst. Perform pathway enrichment and topology analysis. Use when interpreting metabolomics results in the context of biochemical pathways. |
| tool_type | r |
| primary_tool | MetaboAnalystR |
Version Compatibility
Reference examples tested with: ReactomePA 1.46+, 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.
Metabolomics Pathway Mapping
"Map my metabolites to pathways" → Perform pathway enrichment and topology analysis using KEGG, Reactome, or MetaboAnalyst to interpret metabolomics results in biochemical context.
- R:
MetaboAnalystR::SetMetabolomeFilter() → PerformDetailMatch() → pathway topology
KEGG Pathway Enrichment
library(MetaboAnalystR)
mSet <- InitDataObjects('conc', 'pathora', FALSE)
mSet <- SetOrganism(mSet, 'hsa')
metabolites <- c('HMDB0000001', 'HMDB0000005', 'HMDB0000010')
mSet <- Setup.MapData(mSet, metabolites)
mSet <- CrossReferencing(mSet, 'hmdb')
mSet <- SetKEGG.PathLib(mSet, 'hsa', 'current')
mSet <- SetMetabolomeFilter(mSet, FALSE)
mSet <- CalculateOraScore(mSet, 'rbc', 'hyperg')
pathway_results <- mSet$analSet$ora.mat
print(pathway_results)
Quantitative Enrichment Analysis (QEA)
mSet <- InitDataObjects('conc', 'pathqea', FALSE)
mSet <- SetOrganism(mSet, 'hsa')
metabolite_data <- data.frame(
compound = c('Glucose', 'Lactate', 'Pyruvate'),
fc = c(1.5, 2.3, 0.7)
)
mSet <- Setup.MapData(mSet, metabolite_data)
mSet <- CrossReferencing(mSet, 'name')
mSet <- SetKEGG.PathLib(mSet, 'hsa', 'current')
mSet CalculateQeaScoremSet
qea_results mSetanalSetqea.mat
Topology-Based Analysis
mSet <- InitDataObjects('conc', 'pathinteg', FALSE)
mSet <- SetOrganism(mSet, 'hsa')
mSet <- Setup.MapData(mSet, metabolites)
mSet <- CrossReferencing(mSet, 'hmdb')
mSet <- SetKEGG.PathLib(mSet, 'hsa', 'current')
mSet <- SetMetabolomeFilter(mSet, FALSE)
mSet <- CalculateHyperScore(mSet)
topo_results <- mSet$analSet$topo.mat
Reactome Pathways
library(ReactomePA)
library(clusterProfiler)
reactome_ids <- c('R-HSA-70171', 'R-HSA-1428517')
enriched <- enrichPathway(gene = reactome_ids, organism = 'human', pvalueCutoff = 0.05)
print(enriched)
KEGG Mapper (Direct API)
library(KEGGREST)
pathway_info <- keggGet('hsa00010')
kegg_ids <- c('C00031', 'C00186', 'C00022')
find_pathways <- function(kegg_id) {
pathways <- keggLink('pathway', kegg_id)
return(pathways)
}
all_pathways <- lapply(kegg_ids, find_pathways)
Pathway Visualization
library(pathview)
metabolite_data <- c('C00031' = 1.5, 'C00186' = 2.3, 'C00022' = 0.7)
pathview(cpd.data = metabolite_data,
pathway.id = '00010',
species = 'hsa',
cpd.idtype = 'kegg',
out.suffix = 'glycolysis_mapped')
Network-Based Analysis
Goal: Visualize metabolite-pathway relationships as a bipartite network for identifying pathway crosstalk and hub metabolites.
Approach: Extract metabolite-pathway edges from enrichment results, build an igraph network, and annotate nodes by type for interactive visualization.
library(igraph)
build_network <- function(pathway_results) {
edges <- data.frame()
for (i in 1:nrow(pathway_results)) {
pathway <- rownames(pathway_results)[i]
metabolites <- strsplit(pathway_results$Metabolites[i], '; ')[[1]]
for (met in metabolites) {
edges <- rbind(edges, data.frame(from = met, to = pathway))
}
}
g <- graph_from_data_frameedges directed
Vgtype ifelseVgname edgesfrom
g
network build_networkpathway_results
plotnetwork vertex.size ifelseVnetworktype
Metabolite Set Enrichment
mSet <- InitDataObjects('conc', 'msetora', FALSE)
mSet <- SetMetaboliteFilter(mSet, FALSE)
mSet <- SetCurrentMsetLib(mSet, 'smpdb_pathway', 2)
mSet <- Setup.MapData(mSet, metabolites)
mSet <- CrossReferencing(mSet, 'hmdb')
mSet <- CalculateHyperScore(mSet)
msea_results <- mSet$analSet$ora.mat
Combine with Gene Expression
library(IMPaLA)
genes <- c('HK1', 'PFKM', 'ALDOA')
metabolites <- c('HMDB0000122', 'HMDB0000190')
Export Results
export_pathways <- function(results, output_file) {
results_df <- as.data.frame(results)
results_df$pathway <- rownames(results)
results_df <- results_df[, c('pathway', 'Total', 'Expected', 'Hits',
'Raw p', 'Holm adjust', 'FDR', 'Impact')]
results_df <- results_df[order(results_df$FDR), ]
write.csv(results_df, output_file, row.names = FALSE)
return(results_df)
export_pathwayspathway_results
Related Skills
- metabolite-annotation - Identify metabolites first
- statistical-analysis - Get significant metabolites
- pathway-analysis/kegg-pathways - Similar enrichment concepts for genes