Agent Skills

Ssgsea Immune Infiltration Analysis

AIPOCH

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.

9
0
FILES
ssgsea-immune-infiltration-analysis/
skill.md
scripts
cli_options.R
functions.R
io.R
main.R
recording.R
run_analysis.R
utils.R
visualization.R
references
algorithm.md
cli-guide.md
troubleshooting.md
95100Total Score
View Evaluation Report
Core Capability
94 / 100
Functional Suitability
12 / 12
Reliability
11 / 12
Performance & Context
7 / 8
Agent Usability
15 / 16
Human Usability
7 / 8
Security
12 / 12
Maintainability
12 / 12
Agent-Specific
18 / 20
Medical Task
20 / 20 Passed
96Default ssGSEA with plots
4/4
95GSVA Gaussian without plots
4/4
96Numeric column selectors
4/4
95Named column selectors
4/4
99Reuse-toggle no-plot cleanup
4/4

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

  1. Confirm that the expression matrix, group file, and gene-set file match the documented schemas.
  2. Run scripts/main.R with the target case and control groups.
  3. Review run_record.txt, output_manifest.txt, and the generated tables or plots.
  4. If execution fails, read references/troubleshooting.md before retrying.

When to Read External Files

SituationFile to ReadPurpose
Need to run the analysisscripts/main.RCLI entry point
Need algorithm detailsreferences/algorithm.mdMethod assumptions and interpretation
Encounter an errorreferences/troubleshooting.mdError codes and fixes
Need CLI examples or baseline execution detailsreferences/cli-guide.mdExamples and recorded run details
Need dependency declarationsDESCRIPTIONPackage list and Bioconductor source note
Need test commandstests/run_tests.REnd-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:

  • 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

ShortLongTypeDefaultDescription
-i--input_filefilerequiredExpression matrix with genes as rows and samples as columns
-g--group_filefilerequiredGroup annotation table
-e--gene_setfiletests/data/immune_gene_sets.csvImmune gene-set CSV
-a--case_groupstringrequiredCase group label
-b--control_groupstringrequiredControl group label
-o--output_dirdir./outputOutput directory
-m--methodstringssgseaGSVA method: ssgsea, gsva
-k--kcdfstringGaussianKernel mode: Gaussian, Poisson; Gaussian is the validated GSVA baseline
-n--min_szinteger2Minimum overlap genes per gene set
-x--max_szinteger10000Maximum genes per gene set
-p--parallel_szinteger2Requested parallel CPU count
-u--taunumeric0.25Tau parameter for ssGSEA
-d--mx_diffbooleantrueGSVA mx.diff switch
-c--gene_id_casestringupperGene ID normalization: asis, upper, lower
-s--seedinteger42Random seed
-t--timeout_secondsinteger0Optional timeout; 0 disables it
--sample_colstring/intnoneSample column name or 1-based index
--group_colstring/intnoneGroup column name or 1-based index
--make_plotsbooleantrueGenerate PDF plots
--verbosebooleantruePrint 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

FileDescription
data/ssgsea_list.rdsSerialized analysis result object
table/ssgsea_scores_long.csvLong-format immune infiltration scores
table/ssgsea_scores_wide.csvWide-format immune infiltration score matrix
table/ssgsea_group_compare.csvCase-vs-control comparison summary
table/immune_cell_correlation_matrix.csvImmune-cell Spearman correlation matrix
table/immune_cell_correlation_pvalue.csvCorrelation p-value matrix
plot/immune_cell_composition_sample.pdfSample-level composition plot; generated only when --make_plots=true
plot/immune_group_boxplot.pdfGroup comparison boxplot; generated only when --make_plots=true
plot/immune_correlation_heatmap.pdfImmune-cell correlation heatmap; generated only when --make_plots=true
plot/gene_immune_correlation_scatter_*.pdfAuto-selected gene-vs-cell scatter plot; generated only when --make_plots=true
run_record.txtStructured execution record
output_manifest.txtOutput file manifest with descriptions
session_info.txtR session information

Error Handling

ErrorCauseSolution
SKILL_FILE_NOT_FOUNDInput file path is invalidCheck file paths
SKILL_MISSING_COLUMNSRequired columns are absentFix the input schema
SKILL_EMPTY_DATANo usable rows, gene sets, or aligned samples remainCheck IDs and filters
SKILL_INVALID_PARAMETERCLI value is invalid or data is malformedReview arguments and file content
SKILL_SAMPLE_MISMATCHExpression and group samples do not alignHarmonize sample identifiers
SKILL_PACKAGE_NOT_FOUNDRequired R package is missingInstall the missing package
SKILL_TIMEOUTThe configured time limit was exceededIncrease --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.