ranked-statistic-list-preparation
Summary
Prepare a ranked metabolite list sorted by test statistic (log2 fold change or -log10(p-value)) for input to fast set enrichment analysis (fgsea). This intermediate step converts differential analysis results into the ordered format required by GSEA algorithms.
When to use
After completing differential analysis (e.g., via run_de()) to generate p-values and log2 fold changes, and before executing fgsea-based MetSEA enrichment. Use this skill when you have summary statistics for metabolites and need to prepare them for pathway set enrichment testing with ranked statistics.
When NOT to use
- Input is already a ranked list or pre-computed fgsea result object
- Metabolite identifiers cannot be mapped to standard KEGG IDs or pathway reference
- Summary statistics contain missing or infinite values; rank metric cannot be computed
Inputs
- Differential analysis results table (data.frame with metabolite identifiers, p-values, adjusted p-values, log2 fold changes)
- Metabolite KEGG IDs or other standardized identifiers
- PathwayVsMetabolites reference mapping (defines pathway-to-metabolite associations)
Outputs
- Ranked metabolite list (numeric vector named by KEGG IDs, sorted by test statistic)
- fgsea-compatible input object ready for pathway enrichment testing
How to apply
Extract metabolite identifiers (KEGG IDs), p-values, and log2 fold changes from the differential analysis output. Create a ranking metric by selecting either log2 fold change directly or computing -log10(p-value) and optionally applying a sign correction based on directionality (e.g., 'signed_pval' method: sign(log2fc) × -log10(p-value)). Sort the metabolites by this ranking metric in descending order to prioritize metabolites with largest absolute effect sizes or lowest p-values. The ranked list serves as input to fgsea(), which tests whether metabolite sets (pathways) are enriched toward the top or bottom of the ranked list, computing Normalized Enrichment Scores (NES) and adjusted p-values for significance filtering (typically padj < 0.05).
Related tools
- fgsea (Performs fast set enrichment analysis on the ranked metabolite list, computing Normalized Enrichment Scores and adjusted p-values for pathway significance testing)
- enrichmet (Integrates fgsea and pathway enrichment pipeline; consumes the ranked metabolite list as input to execute MetSEA with curated KEGG pathway-to-metabolite mappings) — https://github.com/biodatalab/enrichmet
- run_de (Generates the upstream differential analysis results (p-values, log2 fold changes) that are reformatted into the ranked list) — https://github.com/biodatalab/enrichmet
- R (Implements ranking, sorting, and data transformation operations on differential analysis output)
Examples
# Load DE results, extract KEGG IDs and compute signed p-value ranking
ranked_list <- sign(da_results$log2fc) * (-log10(da_results$pval))
names(ranked_list) <- da_results$met_id
ranked_list <- sort(ranked_list, decreasing = TRUE)
# Pass to fgsea via enrichmet
results <- enrichmet(inputMetabolites = NULL, PathwayVsMetabolites = PathwayVsMetabolites, da_results = da_results, analysis_type = 'gsea')
Evaluation signals
- Ranked list contains all metabolites present in the input differential analysis table with no duplicates or loss of identifiers
- Numeric ranking values are strictly monotonic (either all ascending or all descending) with no ties or missing values
- KEGG IDs or metabolite identifiers in the ranked list match those in the PathwayVsMetabolites reference; unmapped metabolites are logged or excluded
- fgsea execution on the ranked list completes successfully and returns NES and adjusted p-value columns with no errors or NaN values
- Top-ranked metabolites correspond to smallest p-values or largest absolute log2 fold changes relative to input differential analysis results
Limitations
- Ranking metric selection (log2fc vs. -log10(p-value) vs. signed variant) affects downstream GSEA results and pathway interpretation; choice should align with study hypothesis
- Metabolite identifiers not found in the PathwayVsMetabolites reference are excluded from fgsea, reducing statistical power; verification of identifier format (KEGG ID extraction from complex IDs) is required
- Tied ranking values (e.g., identical p-values or fold changes) may lead to arbitrary ordering; application of random tie-breaking or secondary sorting by secondary statistic is recommended
- Missing or infinite values in p-values or log2 fold changes prevent rank computation; preprocessing and imputation/filtering are prerequisites
Evidence
- [other] Prepare ranked metabolite list sorted by test statistic (e.g., log2 fold change or -log10(p-value)) for input to fgsea.: "Prepare ranked metabolite list sorted by test statistic (e.g., log2 fold change or -log10(p-value)) for input to fgsea."
- [readme] Created rankings for 23 KEGG metabolites using 'signed_pval' method. Ranking range: -3.523 to 4: "Created rankings for 23 KEGG metabolites using 'signed_pval' method
Ranking range: -3.523 to 4"
- [readme] Testing 54 pathways with GSEA: "Testing 54 pathways with GSEA"
- [other] Execute fgsea with the ranked metabolite list and pathway-to-metabolite gene set definitions, computing Normalized Enrichment Scores (NES) for each metabolite set.: "Execute fgsea with the ranked metabolite list and pathway-to-metabolite gene set definitions, computing Normalized Enrichment Scores (NES) for each metabolite set."
- [readme] enrichment analysis using DE results results1 <- enrichmet(inputMetabolites = NULL, PathwayVsMetabolites = PathwayVsMetabolites, da_results = da_out: "enrichment analysis using DE results results1 <- enrichmet(inputMetabolites = NULL, PathwayVsMetabolites = PathwayVsMetabolites, da_results = da_out"
1---2name: ranked-statistic-list-preparation3description: Use when after completing differential analysis (e.g., via run_de()) to generate p-values and log2 fold changes, and before executing fgsea-based MetSEA enrichment.4license: CC-BY-4.05---67# ranked-statistic-list-preparation89## Summary1011Prepare a ranked metabolite list sorted by test statistic (log2 fold change or -log10(p-value)) for input to fast set enrichment analysis (fgsea). This intermediate step converts differential analysis results into the ordered format required by GSEA algorithms.1213## When to use1415After completing differential analysis (e.g., via run_de()) to generate p-values and log2 fold changes, and before executing fgsea-based MetSEA enrichment. Use this skill when you have summary statistics for metabolites and need to prepare them for pathway set enrichment testing with ranked statistics.1617## When NOT to use1819- Input is already a ranked list or pre-computed fgsea result object20- Metabolite identifiers cannot be mapped to standard KEGG IDs or pathway reference21- Summary statistics contain missing or infinite values; rank metric cannot be computed2223## Inputs2425- Differential analysis results table (data.frame with metabolite identifiers, p-values, adjusted p-values, log2 fold changes)26- Metabolite KEGG IDs or other standardized identifiers27- PathwayVsMetabolites reference mapping (defines pathway-to-metabolite associations)2829## Outputs3031- Ranked metabolite list (numeric vector named by KEGG IDs, sorted by test statistic)32- fgsea-compatible input object ready for pathway enrichment testing3334## How to apply3536Extract metabolite identifiers (KEGG IDs), p-values, and log2 fold changes from the differential analysis output. Create a ranking metric by selecting either log2 fold change directly or computing -log10(p-value) and optionally applying a sign correction based on directionality (e.g., 'signed_pval' method: sign(log2fc) × -log10(p-value)). Sort the metabolites by this ranking metric in descending order to prioritize metabolites with largest absolute effect sizes or lowest p-values. The ranked list serves as input to fgsea(), which tests whether metabolite sets (pathways) are enriched toward the top or bottom of the ranked list, computing Normalized Enrichment Scores (NES) and adjusted p-values for significance filtering (typically padj < 0.05).3738## Related tools3940- **fgsea** (Performs fast set enrichment analysis on the ranked metabolite list, computing Normalized Enrichment Scores and adjusted p-values for pathway significance testing)41- **enrichmet** (Integrates fgsea and pathway enrichment pipeline; consumes the ranked metabolite list as input to execute MetSEA with curated KEGG pathway-to-metabolite mappings) — https://github.com/biodatalab/enrichmet42- **run_de** (Generates the upstream differential analysis results (p-values, log2 fold changes) that are reformatted into the ranked list) — https://github.com/biodatalab/enrichmet43- **R** (Implements ranking, sorting, and data transformation operations on differential analysis output)4445## Examples4647```48# Load DE results, extract KEGG IDs and compute signed p-value ranking49ranked_list <- sign(da_results$log2fc) * (-log10(da_results$pval))50names(ranked_list) <- da_results$met_id51ranked_list <- sort(ranked_list, decreasing = TRUE)52# Pass to fgsea via enrichmet53results <- enrichmet(inputMetabolites = NULL, PathwayVsMetabolites = PathwayVsMetabolites, da_results = da_results, analysis_type = 'gsea')54```5556## Evaluation signals5758- Ranked list contains all metabolites present in the input differential analysis table with no duplicates or loss of identifiers59- Numeric ranking values are strictly monotonic (either all ascending or all descending) with no ties or missing values60- KEGG IDs or metabolite identifiers in the ranked list match those in the PathwayVsMetabolites reference; unmapped metabolites are logged or excluded61- fgsea execution on the ranked list completes successfully and returns NES and adjusted p-value columns with no errors or NaN values62- Top-ranked metabolites correspond to smallest p-values or largest absolute log2 fold changes relative to input differential analysis results6364## Limitations6566- Ranking metric selection (log2fc vs. -log10(p-value) vs. signed variant) affects downstream GSEA results and pathway interpretation; choice should align with study hypothesis67- Metabolite identifiers not found in the PathwayVsMetabolites reference are excluded from fgsea, reducing statistical power; verification of identifier format (KEGG ID extraction from complex IDs) is required68- Tied ranking values (e.g., identical p-values or fold changes) may lead to arbitrary ordering; application of random tie-breaking or secondary sorting by secondary statistic is recommended69- Missing or infinite values in p-values or log2 fold changes prevent rank computation; preprocessing and imputation/filtering are prerequisites7071## Evidence7273- [other] Prepare ranked metabolite list sorted by test statistic (e.g., log2 fold change or -log10(p-value)) for input to fgsea.: "Prepare ranked metabolite list sorted by test statistic (e.g., log2 fold change or -log10(p-value)) for input to fgsea."74- [readme] Created rankings for 23 KEGG metabolites using 'signed_pval' method. Ranking range: -3.523 to 4: "Created rankings for 23 KEGG metabolites using 'signed_pval' method75> Ranking range: -3.523 to 4"76- [readme] Testing 54 pathways with GSEA: "Testing 54 pathways with GSEA"77- [other] Execute fgsea with the ranked metabolite list and pathway-to-metabolite gene set definitions, computing Normalized Enrichment Scores (NES) for each metabolite set.: "Execute fgsea with the ranked metabolite list and pathway-to-metabolite gene set definitions, computing Normalized Enrichment Scores (NES) for each metabolite set."78- [readme] enrichment analysis using DE results results1 <- enrichmet(inputMetabolites = NULL, PathwayVsMetabolites = PathwayVsMetabolites, da_results = da_out: "enrichment analysis using DE results results1 <- enrichmet(inputMetabolites = NULL, PathwayVsMetabolites = PathwayVsMetabolites, da_results = da_out"