{"data":{"slug":"github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-ssgsea-immune-infiltration-analysis-0440b3e7fbbe","title":"ssGSEA Immune Infiltration Analysis","summary":"Estimate relative immune infiltration from bulk RNA-seq expression matrices, compare case vs control groups, and generate structured result tables and visualizations for downstream review.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-ssgsea-immune-infiltration-analysis-0440b3e7fbbe","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-ssgsea-immune-infiltration-analysis-0440b3e7fbbe","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-ssgsea-immune-infiltration-analysis-0440b3e7fbbe.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-ssgsea-immune-infiltration-analysis-0440b3e7fbbe\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"Ensure the input expression matrix has genes as rows and samples as columns, with the first column containing gene identifiers. The group file must include at least one sample column and one group column. The gene set file should contain `gene`, `cell_type`, and optionally `immunity_class` columns. Use `--method ssgsea` for the validated path, and `--kcdf Gaussian` for the documented baseline GSVA execution.","instructions":"---\nname: ssgsea-immune-infiltration-analysis\ndescription: 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.\nlicense: MIT\nauthor: AIPOCH\n---\n> **Source**: [https:\/\/github.com\/aipoch\/medical-research-skills](https:\/\/github.com\/aipoch\/medical-research-skills)\n\n# ssGSEA Immune Infiltration Analysis\n\n## When to Use\n\n- Estimate relative immune infiltration from a bulk RNA-seq expression matrix.\n- Compare immune enrichment scores between one case group and one control group.\n- Generate structured result tables plus optional PDF visualizations for downstream review.\n\n## When Not to Use\n\n- Single-cell RNA-seq or spatial transcriptomics.\n- Absolute immune cell proportion estimation or deconvolution.\n- Clinical diagnosis, treatment recommendation, or any other medical decision making.\n\n## Workflow\n\n1. Confirm that the expression matrix, group file, and gene-set file match the documented schemas.\n2. Run `scripts\/main.R` with the target case and control groups.\n3. Review `run_record.txt`, `output_manifest.txt`, and the generated tables or plots.\n4. If execution fails, read `references\/troubleshooting.md` before retrying.\n\n## When to Read External Files\n\n| Situation | File to Read | Purpose |\n|-----------|--------------|---------|\n| Need to run the analysis | `scripts\/main.R` | CLI entry point |\n| Need algorithm details | `references\/algorithm.md` | Method assumptions and interpretation |\n| Encounter an error | `references\/troubleshooting.md` | Error codes and fixes |\n| Need CLI examples or baseline execution details | `references\/cli-guide.md` | Examples and recorded run details |\n| Need dependency declarations | `DESCRIPTION` | Package list and Bioconductor source note |\n| Need test commands | `tests\/run_tests.R` | End-to-end test entry |\n\n## Usage\n\n```bash\nRscript scripts\/main.R \\\n  --input_file .\/expression_matrix.csv \\\n  --group_file .\/group_info.csv \\\n  --gene_set .\/immune_gene_sets.csv \\\n  --case_group treatment \\\n  --control_group control \\\n  --output_dir .\/output \\\n  --method ssgsea \\\n  --seed 42\n```\n\nValidated path note:\n\n- `ssgsea` is the default validated path.\n- `gsva` is supported, but only with kernels validated in the local GSVA environment.\n- In the current audited environment, `gsva` with `Gaussian` completed successfully and is the documented baseline.\n\n## Arguments\n\n| Short | Long | Type | Default | Description |\n|-------|------|------|---------|-------------|\n| `-i` | `--input_file` | file | required | Expression matrix with genes as rows and samples as columns |\n| `-g` | `--group_file` | file | required | Group annotation table |\n| `-e` | `--gene_set` | file | `tests\/data\/immune_gene_sets.csv` | Immune gene-set CSV |\n| `-a` | `--case_group` | string | required | Case group label |\n| `-b` | `--control_group` | string | required | Control group label |\n| `-o` | `--output_dir` | dir | `.\/output` | Output directory |\n| `-m` | `--method` | string | `ssgsea` | GSVA method: `ssgsea`, `gsva` |\n| `-k` | `--kcdf` | string | `Gaussian` | Kernel mode: `Gaussian`, `Poisson`; `Gaussian` is the validated GSVA baseline |\n| `-n` | `--min_sz` | integer | `2` | Minimum overlap genes per gene set |\n| `-x` | `--max_sz` | integer | `10000` | Maximum genes per gene set |\n| `-p` | `--parallel_sz` | integer | `2` | Requested parallel CPU count |\n| `-u` | `--tau` | numeric | `0.25` | Tau parameter for ssGSEA |\n| `-d` | `--mx_diff` | boolean | `true` | GSVA `mx.diff` switch |\n| `-c` | `--gene_id_case` | string | `upper` | Gene ID normalization: `asis`, `upper`, `lower` |\n| `-s` | `--seed` | integer | `42` | Random seed |\n| `-t` | `--timeout_seconds` | integer | `0` | Optional timeout; `0` disables it |\n|  | `--sample_col` | string\/int | none | Sample column name or 1-based index |\n|  | `--group_col` | string\/int | none | Group column name or 1-based index |\n|  | `--make_plots` | boolean | `true` | Generate PDF plots |\n|  | `--verbose` | boolean | `true` | Print progress logs |\n\n## Input Format\n\n### Expression Matrix\n\nCSV or TSV. The first column must contain gene identifiers. Remaining columns are sample-level numeric expression values.\n\n```csv\ngene,Sample1,Sample2,Sample3\nTP53,10.2,8.5,9.1\nCXCL9,4.3,6.1,5.7\n```\n\n### Group File\n\nCSV or TSV with at least one sample column and one group column.\n\n```csv\nsample,group\nSample1,control\nSample2,treatment\nSample3,treatment\n```\n\n### Gene Set File\n\nCSV with `gene` and `cell_type`; `immunity_class` is optional.\n\n```csv\ngene,cell_type,immunity_class\nCXCL9,Activated CD8 T cell,Adaptive\nCD3D,Activated CD8 T cell,Adaptive\n```\n\n## Output Files\n\n| File | Description |\n|------|-------------|\n| `data\/ssgsea_list.rds` | Serialized analysis result object |\n| `table\/ssgsea_scores_long.csv` | Long-format immune infiltration scores |\n| `table\/ssgsea_scores_wide.csv` | Wide-format immune infiltration score matrix |\n| `table\/ssgsea_group_compare.csv` | Case-vs-control comparison summary |\n| `table\/immune_cell_correlation_matrix.csv` | Immune-cell Spearman correlation matrix |\n| `table\/immune_cell_correlation_pvalue.csv` | Correlation p-value matrix |\n| `plot\/immune_cell_composition_sample.pdf` | Sample-level composition plot; generated only when `--make_plots=true` |\n| `plot\/immune_group_boxplot.pdf` | Group comparison boxplot; generated only when `--make_plots=true` |\n| `plot\/immune_correlation_heatmap.pdf` | Immune-cell correlation heatmap; generated only when `--make_plots=true` |\n| `plot\/gene_immune_correlation_scatter_*.pdf` | Auto-selected gene-vs-cell scatter plot; generated only when `--make_plots=true` |\n| `run_record.txt` | Structured execution record |\n| `output_manifest.txt` | Output file manifest with descriptions |\n| `session_info.txt` | R session information |\n\n## Error Handling\n\n| Error | Cause | Solution |\n|-------|-------|----------|\n| `SKILL_FILE_NOT_FOUND` | Input file path is invalid | Check file paths |\n| `SKILL_MISSING_COLUMNS` | Required columns are absent | Fix the input schema |\n| `SKILL_EMPTY_DATA` | No usable rows, gene sets, or aligned samples remain | Check IDs and filters |\n| `SKILL_INVALID_PARAMETER` | CLI value is invalid or data is malformed | Review arguments and file content |\n| `SKILL_SAMPLE_MISMATCH` | Expression and group samples do not align | Harmonize sample identifiers |\n| `SKILL_PACKAGE_NOT_FOUND` | Required R package is missing | Install the missing package |\n| `SKILL_TIMEOUT` | The configured time limit was exceeded | Increase `--timeout_seconds` or disable it with `0` |\n\n## Testing\n\n```bash\nRscript scripts\/main.R --help\n\nRscript tests\/run_tests.R\n\nRscript tests\/test_skill.R\n```\n\n`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.\n","use_cases":["Estimate relative immune infiltration from bulk RNA-seq expression matrices.","Compare immune enrichment scores between case and control groups.","Generate structured result tables and visualizations for downstream review."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/awesome-med-research-skills\/Data%20Analysis\/ssgsea-immune-infiltration-analysis\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T07:32:30.000000Z","updated_at":"2026-11-24T07:13:22.000000Z","seo_title":"ssGSEA Immune Infiltration Analysis Tool","seo_description":"Analyze bulk RNA-seq data to estimate immune infiltration scores and compare case vs control groups with ssGSEA\/GSVA methods.","seo_keywords":["ssGSEA immune infiltration analysis","bulk RNA-seq immune score comparison","case vs control immune enrichment analysis"]}}