Source: https://github.com/aipoch/medical-research-skills
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.R with 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.md before retrying.
When to Read External Files
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:
ssgsea is the default validated path.
gsva is supported, but only with kernels validated in the local GSVA environment.
- In the current audited environment,
gsva with Gaussian completed successfully and is the documented baseline.
Arguments
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
Error Handling
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.