ssgsea-immune-infiltration-analysis
Use when estimating immune infiltration from bulk RNA-seq expression matrices with ssGSEA/GSVA, comparing case versus control groups, and generating downstream immune-score visualizations. NOT for single-cell RNA-seq, absolute cell proportion estimation, or clinical decision making.
- License 许可
- MIT
- 最近更新
- 2026-10-12
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- ssgsea-immune-infiltration-analysis
- author
- AIPOCH
- license
- MIT
- description
- Use when estimating immune infiltration from bulk RNA-seq expression matrices with ssGSEA/GSVA, comparing case versus control groups, and generating downstream immune-score visualizations. NOT for single-cell RNA-seq, absolute cell proportion estimation, or clinical decision making.
02 资源文件 14
- 参考文档references/algorithm.md1.4 KB
- 参考文档references/cli-guide.md7.3 KB
- 参考文档references/troubleshooting.md2.2 KB
- 脚本scripts/cli_options.R3.7 KB
- 脚本scripts/functions.R3.6 KB
- 脚本scripts/io.R5.2 KB
- 脚本scripts/main.R1.5 KB
- 脚本scripts/recording.R1023 B
- 脚本scripts/run_analysis.R7.5 KB
- 脚本scripts/utils.R2.8 KB
- 脚本scripts/visualization.R4.1 KB
- 资产文件tests/data/group_info.csv2.6 KB
- 资产文件tests/data/immune_gene_sets.csv26.8 KB
- 其他tests/run_tests.R3.8 KB
03 SKILL.md 正文
ssGSEA Immune Infiltration Analysis
When to Use
- Estimate relative immune infiltration from a bulk RNA-seq expression matrix.
- Compare immune enrichment scores between one case group and one control group.
- Generate structured result tables plus optional PDF visualizations for downstream review.
When Not to Use
- Single-cell RNA-seq or spatial transcriptomics.
- Absolute immune cell proportion estimation or deconvolution.
- Clinical diagnosis, treatment recommendation, or any other medical decision making.
Workflow
- Confirm that the expression matrix, group file, and gene-set file match the documented schemas.
- Run
scripts/main.Rwith the target case and control groups. - Review
run_record.txt,output_manifest.txt, and the generated tables or plots. - If execution fails, read
references/troubleshooting.mdbefore retrying.
When to Read External Files
| Situation | File to Read | Purpose |
|---|---|---|
| Need to run the analysis | scripts/main.R |
CLI entry point |
| Need algorithm details | references/algorithm.md |
Method assumptions and interpretation |
| Encounter an error | references/troubleshooting.md |
Error codes and fixes |
| Need CLI examples or baseline execution details | references/cli-guide.md |
Examples and recorded run details |
| Need dependency declarations | DESCRIPTION |
Package list and Bioconductor source note |
| Need test commands | tests/run_tests.R |
End-to-end test entry |
Usage
Rscript scripts/main.R \
--input_file ./expression_matrix.csv \
--group_file ./group_info.csv \
--gene_set ./immune_gene_sets.csv \
--case_group treatment \
--control_group control \
--output_dir ./output \
--method ssgsea \
--seed 42
Validated path note:
ssgseais the default validated path.gsvais supported, but only with kernels validated in the local GSVA environment.- In the current audited environment,
gsvawithGaussiancompleted successfully and is the documented baseline.
Arguments
| Short | Long | Type | Default | Description |
|---|---|---|---|---|
-i |
--input_file |
file | required | Expression matrix with genes as rows and samples as columns |
-g |
--group_file |
file | required | Group annotation table |
-e |
--gene_set |
file | tests/data/immune_gene_sets.csv |
Immune gene-set CSV |
-a |
--case_group |
string | required | Case group label |
-b |
--control_group |
string | required | Control group label |
-o |
--output_dir |
dir | ./output |
Output directory |
-m |
--method |
string | ssgsea |
GSVA method: ssgsea, gsva |
-k |
--kcdf |
string | Gaussian |
Kernel mode: Gaussian, Poisson; Gaussian is the validated GSVA baseline |
-n |
--min_sz |
integer | 2 |
Minimum overlap genes per gene set |
-x |
--max_sz |
integer | 10000 |
Maximum genes per gene set |
-p |
--parallel_sz |
integer | 2 |
Requested parallel CPU count |
-u |
--tau |
numeric | 0.25 |
Tau parameter for ssGSEA |
-d |
--mx_diff |
boolean | true |
GSVA mx.diff switch |
-c |
--gene_id_case |
string | upper |
Gene ID normalization: asis, upper, lower |
-s |
--seed |
integer | 42 |
Random seed |
-t |
--timeout_seconds |
integer | 0 |
Optional timeout; 0 disables it |
--sample_col |
string/int | none | Sample column name or 1-based index | |
--group_col |
string/int | none | Group column name or 1-based index | |
--make_plots |
boolean | true |
Generate PDF plots | |
--verbose |
boolean | true |
Print progress logs |
Input Format
Expression Matrix
CSV or TSV. The first column must contain gene identifiers. Remaining columns are sample-level numeric expression values.
gene,Sample1,Sample2,Sample3
TP53,10.2,8.5,9.1
CXCL9,4.3,6.1,5.7
Group File
CSV or TSV with at least one sample column and one group column.
sample,group
Sample1,control
Sample2,treatment
Sample3,treatment
Gene Set File
CSV with gene and cell_type; immunity_class is optional.
gene,cell_type,immunity_class
CXCL9,Activated CD8 T cell,Adaptive
CD3D,Activated CD8 T cell,Adaptive
Output Files
| File | Description |
|---|---|
data/ssgsea_list.rds |
Serialized analysis result object |
table/ssgsea_scores_long.csv |
Long-format immune infiltration scores |
table/ssgsea_scores_wide.csv |
Wide-format immune infiltration score matrix |
table/ssgsea_group_compare.csv |
Case-vs-control comparison summary |
table/immune_cell_correlation_matrix.csv |
Immune-cell Spearman correlation matrix |
table/immune_cell_correlation_pvalue.csv |
Correlation p-value matrix |
plot/immune_cell_composition_sample.pdf |
Sample-level composition plot; generated only when --make_plots=true |
plot/immune_group_boxplot.pdf |
Group comparison boxplot; generated only when --make_plots=true |
plot/immune_correlation_heatmap.pdf |
Immune-cell correlation heatmap; generated only when --make_plots=true |
plot/gene_immune_correlation_scatter_*.pdf |
Auto-selected gene-vs-cell scatter plot; generated only when --make_plots=true |
run_record.txt |
Structured execution record |
output_manifest.txt |
Output file manifest with descriptions |
session_info.txt |
R session information |
Error Handling
| Error | Cause | Solution |
|---|---|---|
SKILL_FILE_NOT_FOUND |
Input file path is invalid | Check file paths |
SKILL_MISSING_COLUMNS |
Required columns are absent | Fix the input schema |
SKILL_EMPTY_DATA |
No usable rows, gene sets, or aligned samples remain | Check IDs and filters |
SKILL_INVALID_PARAMETER |
CLI value is invalid or data is malformed | Review arguments and file content |
SKILL_SAMPLE_MISMATCH |
Expression and group samples do not align | Harmonize sample identifiers |
SKILL_PACKAGE_NOT_FOUND |
Required R package is missing | Install the missing package |
SKILL_TIMEOUT |
The configured time limit was exceeded | Increase --timeout_seconds or disable it with 0 |
Testing
Rscript scripts/main.R --help
Rscript tests/run_tests.R
Rscript tests/test_skill.R
tests/test_skill.R is self-contained: if expected outputs are absent, it first runs tests/run_tests.R and then validates both file presence and core result structure.
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.