gsea
Run GSEA on a ranked gene list and produce the enrichment table, running-score table, and enrichment plots.
- License 许可
- MIT
- 最近更新
- 2026-10-12
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- gsea
- author
- AIPOCH
- license
- MIT
- description
- Run GSEA on a ranked gene list and produce the enrichment table, running-score table, and enrichment plots.
02 资源文件 10
- 资产文件assets/ssGSEA.rds2.7 MB
- 参考文档references/algorithm.md1.2 KB
- 参考文档references/cli-guide.md1.4 KB
- 参考文档references/troubleshooting.md1.6 KB
- 脚本scripts/functions.R7.3 KB
- 脚本scripts/main.R12.8 KB
- 脚本scripts/plot_functions.R16.5 KB
- 脚本scripts/run_analysis.R11.6 KB
- 脚本scripts/utils.R6.0 KB
- 资产文件tests/data/sample_deg_results.csv1.2 KB
03 SKILL.md 正文
When to read external files
| Situation | Read | Purpose |
|---|---|---|
| Need algorithm details | references/algorithm.md |
Statistical method and formulas |
| Need to run an analysis | scripts/main.R |
Full command reference |
| Hit an error | references/troubleshooting.md |
Look up error codes and fixes |
| Need CLI examples | references/cli-guide.md |
Worked argument examples |
Scope
Use this skill for:
- Running GSEA on a gene list ranked by a statistic
- Generating enrichment curve plots from existing
enrichGSEA.csvandgsea_running_scores.csv - Smoke-testing the pipeline with
tests/data/sample_deg_results.csv
Do not use it for:
- Differential expression on raw expression matrices
- Single-sample ssGSEA
- Network analysis or multi-omics integration
Usage
Analysis mode:
Rscript scripts/main.R --input tests/data/sample_deg_results.csv --outdir ./GSEA_analysis --type KEGG --species human --seed 42 --timeout 300
Plot mode:
Rscript scripts/main.R --running_file ./GSEA_analysis/Table/gsea_running_scores.csv --enrich_file ./GSEA_analysis/Table/enrichGSEA.csv --plot_output ./GSEA_analysis/plot/gsea_plot.pdf --top_n 5 --plot_format pdf --seed 42 --timeout 300
See references/cli-guide.md for more.
Mode selection:
- Passing only
--inputruns analysis mode - Passing both
--running_fileand--enrich_fileruns plot mode - If both sets of arguments are provided, plot mode takes precedence; analysis mode is skipped and a warning is logged
Arguments
Analysis-mode arguments
| Short | Long | Type | Default | Required | Description |
|---|---|---|---|---|---|
-i |
--input |
character | NULL |
yes | Input CSV file |
-o |
--outdir |
character | GSEA_analysis |
no | Output directory |
-g |
--gene_col |
character | name |
no | Gene column name |
-f |
--fc_col |
character | logFC |
no | Ranking-statistic column name |
-t |
--type |
character | KEGG |
no | Gene-set type: KEGG, HALLMARKS, GO_BP, GO_MF, GO_CC. With a preloaded RDS, HALLMARKS is automatically mapped to the asset key Hallmarks |
-s |
--species |
character | human |
no | Species: human, mouse, rat |
-p |
--pvalue_cutoff |
numeric | 0.05 |
no | Significance threshold |
-m |
--method |
character | fgsea |
no | GSEA backend: fgsea or DOSE |
-c |
--chunk_size |
numeric | 1000 |
no | Chunk size for large gene-set conversion |
-r |
--rds_path |
character | NULL |
no | Path to a pre-stored gene-set RDS |
-v |
--verbose |
logical | FALSE |
no | Verbose logging |
--seed |
integer | 42 |
no | Random seed | |
--timeout |
integer | 300 |
no | Timeout in seconds; <=0 disables it |
|
-h |
--help |
logical | FALSE |
no | Show help |
Plot-mode arguments
| Short | Long | Type | Default | Required | Description |
|---|---|---|---|---|---|
--running_file |
character | NULL |
yes | Path to gsea_running_scores.csv |
|
--enrich_file |
character | NULL |
yes | Path to enrichGSEA.csv |
|
--plot_output |
character | gsea_plot.pdf |
no | Output plot path | |
--plot_width |
numeric | 8 |
no | Plot width | |
--plot_height |
numeric | 6 |
no | Plot height | |
--plot_format |
character | pdf |
no | Output format: pdf or png |
|
--top_n |
numeric | 1 |
no | Number of top pathways to plot when geneSetID is not given |
|
--rank_by |
character | p.adjust |
no | Column used to rank pathways | |
--geneSetID |
character | "" |
no | Comma-separated pathway IDs | |
--plot_title |
character | "" |
no | Plot title | |
--colors |
character | #4DBBD5,#E64B35,#00A087,#F39B7F,#3C5488,#8491B4 |
no | Color list | |
--base_size |
numeric | 11 |
no | Base font size | |
--subplots |
character | 1,2,3 |
no | Sub-panel indices to display | |
--rel_heights |
character | 1.5,0.8,1 |
no | Relative panel heights | |
--NES_table |
logical | TRUE |
no | Show NES annotation | |
--no_NES_table |
logical | FALSE |
no | Disable NES annotation | |
--NES_label_size |
numeric | 4 |
no | NES label font size | |
--NES_label_x |
numeric | 0.75 |
no | NES label x position | |
--NES_label_y |
numeric | 0.75 |
no | NES label y position | |
--NES_label_color |
character | black |
no | NES label color | |
--NES_label_hjust |
numeric | 0 |
no | NES label horizontal justification | |
--NES_label_vjust |
numeric | 1 |
no | NES label vertical justification | |
--line_width |
numeric | 1 |
no | ES line width | |
--dot_size |
numeric | 1.2 |
no | ES dot size | |
--legend_position |
character | auto |
no | Legend position | |
--legend_x |
numeric | 0.02 |
no | Inset legend x coordinate | |
--legend_y |
numeric | 0.02 |
no | Inset legend y coordinate | |
--legend_just_x |
numeric | 0 |
no | Legend horizontal justification | |
--legend_just_y |
numeric | 0 |
no | Legend vertical justification | |
--legend_text_size |
numeric | 9 |
no | Legend text size | |
--legend_key_size |
numeric | 0.6 |
no | Legend key size | |
--legend_bg_alpha |
numeric | 0 |
no | Legend background alpha | |
--grid_major_color |
character | grey92 |
no | Major grid color | |
--grid_minor_color |
character | grey92 |
no | Minor grid color | |
--ylab_es |
character | Enrichment Score |
no | ES panel y-axis title | |
--ylab_rank |
character | Ranked List Metric |
no | Rank panel y-axis title | |
--xlab_rank |
character | Rank in Ordered Dataset |
no | Rank panel x-axis title | |
--hit_height |
numeric | 1 |
no | Hit-bar height | |
--hit_gap |
numeric | 0 |
no | Hit-bar gap | |
--hit_linewidth |
numeric | 0.5 |
no | Hit-bar line width | |
--rank_bar_alpha |
numeric | 0.9 |
no | Rank-bar alpha | |
--rank_bar_height_ratio |
numeric | 0.3 |
no | Rank-bar height ratio | |
--rank_metric_segment_color |
character | grey |
no | Rank-line color | |
--rank_metric_segment_width |
numeric | 0.3 |
no | Rank-line width | |
--rank_metric_segment_alpha |
numeric | 1 |
no | Rank-line alpha | |
--pvalue_table |
logical | FALSE |
no | Show p-value table | |
--ES_geom |
character | line |
no | ES geometry: line or dot |
|
--verbose |
logical | FALSE |
no | Verbose logging | |
--seed |
integer | 42 |
no | Random seed | |
--timeout |
integer | 300 |
no | Timeout in seconds; <=0 disables it |
|
-h |
--help |
logical | FALSE |
no | Show help |
Input format
Analysis-mode input is a CSV with at least:
- a gene column (default name
name) - a ranking-statistic column (default name
logFC)
Example:
name,logFC,pvalue,padj
TP53,2.5,0.001,0.01
BRCA1,1.8,0.005,0.02
EGFR,-1.2,0.01,0.05
Value constraints:
typeacceptsKEGG,HALLMARKS,GO_BP,GO_MF,GO_CC- When using a preloaded RDS,
HALLMARKSis automatically matched to the asset keyHallmarks speciesacceptshuman,mouse,rat
Output files
| File | Format | Description |
|---|---|---|
data/GSEA_list.rda |
RDA | Full GSEA result object |
Table/enrichGSEA.csv |
CSV | Enrichment result table |
Table/gsea_running_scores.csv |
CSV | Running-score table; if no enrichment passes, a header-only file is still written |
plot/ |
directory | Plot output directory |
session_info.txt |
TXT | R version and package versions |
enrichGSEA.csv mainly contains: ID, Description, NES, pvalue, p.adjust, core_enrichment.
Error handling
Common error codes:
SKILL_FILE_NOT_FOUND: input file does not existSKILL_MISSING_COLUMNS: required columns are missingSKILL_EMPTY_DATA: input is empty, or empty after filteringSKILL_INVALID_PARAMETER: an argument has an invalid valueSKILL_PACKAGE_NOT_FOUND: a required package is not installedSKILL_ANALYSIS_FAILED: GSEA still failed after retries
Triage doc: references/troubleshooting.md
Exit codes:
0: success1: failure
Testing
Minimal test dataset: tests/data/sample_deg_results.csv
Minimal command:
Rscript scripts/main.R --input tests/data/sample_deg_results.csv --outdir ./test_output --type KEGG --species human --seed 42 --timeout 300 --verbose
Expected output:
./test_output/data/GSEA_list.rda./test_output/Table/enrichGSEA.csv./test_output/Table/gsea_running_scores.csv./test_output/session_info.txt- If no significant enrichment is found,
gsea_running_scores.csvis still written but contains only the header - Exit code
0
04 同仓库更多 Skills
bio-workflows-metabolomics-pipeline
Orchestrates the untargeted LC-MS metabolomics pipeline end-to-end (xcms 4.x feature extraction, QC/drift/normalization, confidence-stratified annotation, permutation-validated statistics, background-aware pathway mapping), naming what each stage decides and where it silently fails. Use when running a full LC-MS metabolomics study from raw mzML to enriched pathways and needing the honest handoffs between stages. Each stage defers to its component skill for parameters and traps; for stable-isotope flux (a separate branch, not this untargeted flow) see metabolomics/isotope-tracing.
bio-metabolomics-xcms-preprocessing
Programmatic untargeted LC-MS feature extraction in R with the modern xcms 4.x MsExperiment/XcmsExperiment API, taking raw mzML to a feature table via CentWave peak detection, retention-time alignment, peak-density correspondence, gap-filling, CAMERA redundancy collapse, and built-in QC feature filtering. Use when converting centroided LC-MS runs into a features-by-samples matrix and deciding centWave/grouping/alignment parameters. For drift correction and QC/CV filtering execution see metabolomics/normalization-qc; for metabolite identification see metabolomics/metabolite-annotation; for the MS-DIAL GUI alternative with MS2Dec deconvolution see metabolomics/msdial-preprocessing; for downstream statistics see metabolomics/statistical-analysis.
bio-metabolomics-statistical-analysis
Decision-grade statistical analysis for metabolomics intensity tables. Covers transformation and scaling (Pareto vs unit-variance as a hidden hypothesis), unsupervised structure (PCA/HCA for QC), permutation-validated PLS-DA/OPLS-DA (R2 vs Q2, double CV, VIP as heuristic), univariate testing (Welch/Mann-Whitney/ANOVA/LMM with covariate adjustment), and dependence-aware multiple testing. Use when testing which metabolites differ, building or validating a discriminant model, choosing a scaling, or correcting many correlated tests. For sample-wise normalization/drift correction see metabolomics/normalization-qc; for ML classifiers and selection-inside-CV leakage see machine-learning/biomarker-discovery and machine-learning/model-validation; for pathway interpretation see metabolomics/pathway-mapping; for design/power/multiplicity regime see experimental-design/multiple-testing.
bio-metabolomics-pathway-mapping
Maps metabolomics results to biological pathways via over-representation (ORA), metabolite-set enrichment (MSEA/QEA), mummichog/PSEA on raw m/z peaks, and network-diffusion enrichment (FELLA), with correct background-set construction and honest interpretive ceilings. Use when interpreting differential metabolites or an untargeted LC-MS feature table in pathway context, choosing ORA vs MSEA vs mummichog vs topology, or setting the reference/background set. For annotation confidence levels feeding ORA see metabolomics/metabolite-annotation; for gene-set concepts see pathway-analysis/go-enrichment and pathway-analysis/gsea; for joint gene+metabolite pathways see multi-omics-integration/mofa-integration.
bio-metabolomics-normalization-qc
Designs QC, corrects signal drift, removes batch effects, filters features, normalizes samples, and imputes missing values for untargeted LC-MS/GC-MS metabolomics, framing each step as a measurement model that can create or erase biological signal. Use when processing a peak/feature table before statistical analysis, choosing a drift-correction or sample-normalization method, deciding QC RSD vs D-ratio filtering, or handling left-censored missing values. The feature table is produced by metabolomics/xcms-preprocessing or metabolomics/msdial-preprocessing; transformation/scaling for modeling defers to metabolomics/statistical-analysis; cross-study design issues link to experimental-design/batch-design.
bio-metabolomics-msdial-preprocessing
Runs the MS-DIAL preprocessing workflow (peak picking, MS2Dec spectral deconvolution, alignment, gap-filling) and imports the alignment-result table into R or Python with honest filtering. Use when preprocessing LC-MS DDA/DIA (SWATH) or GC-MS raw data with MS-DIAL, deciding MS-DIAL vs XCMS, configuring the MSDIALCUI console run, or parsing an MS-DIAL export into a clean feature matrix. For programmatic R peak detection and the feature-table-as-artifact framing see metabolomics/xcms-preprocessing; for lipid annotation mode see metabolomics/lipidomics; for MSI-level confidence honesty see metabolomics/metabolite-annotation; for drift correction and QC see metabolomics/normalization-qc.