{"data":{"slug":"github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-estimate-immune-score-analysis-46b0ea938437","title":"ESTIMATE Immune Score Analysis","summary":"Compute ESTIMATE immune and stromal scores from bulk expression data, generate heatmaps, and create group-wise boxplots and significance tables when a sample group file is provided. The deliverable is a sample-level result table with scores and visualizations.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-estimate-immune-score-analysis-46b0ea938437","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-estimate-immune-score-analysis-46b0ea938437","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-estimate-immune-score-analysis-46b0ea938437.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-awesome-med-research-skills-data-analysis-estimate-immune-score-analysis-46b0ea938437\/download","category":{"slug":"data-research","name":"Data & Research"},"editor_note":"The input file must be a CSV or TSV with genes in the first column and samples in the remaining columns. Expression values must be numeric and non-missing. Sample column names must be unique. A group file is optional but required for boxplots and significance tables.","instructions":"---\nname: estimate-immune-score-analysis\ndescription: \"Use this skill to compute ESTIMATE immune-related microenvironment scores from a bulk expression matrix, generate an ESTIMATE score heatmap, and optionally generate group-wise ESTIMATE score boxplots plus significance tables when a sample group file is supplied. Trigger keywords: ESTIMATE, immune score, stromal score, tumor microenvironment score. NOT for: immune cell deconvolution, single-cell analysis, differential expression, clinical diagnosis.\"\nlicense: MIT\nskill-author: AIPOCH\n---\n\n# ESTIMATE Immune Score Analysis\n\n## When to Use\n\nUse this skill when the user wants to:\n\n- compute ESTIMATE-derived immune and stromal scores from a bulk expression matrix\n- transform an expression matrix into `estimate` package input files and score outputs\n- generate an ESTIMATE score heatmap across samples\n- compare ESTIMATE scores across sample groups when a sample group file is available\n- create a reproducible CLI-backed ESTIMATE workflow with structured output records\n\nTypical request patterns:\n\n- \"Run ESTIMATE immune score analysis on this expression matrix\"\n- \"Calculate ImmuneScore and StromalScore from my bulk RNA-seq data\"\n- \"Generate ESTIMATE scores and save a sample-level result table\"\n\n## Execution Model\n\nThis is a CLI-backed analysis skill.\n\n1. Use `SKILL.md` to confirm that the task is ESTIMATE score generation from bulk expression data.\n2. Use `scripts\/main.R` for the real execution.\n3. Provide one expression matrix file with genes in the first column and samples in the remaining columns.\n4. Optionally provide a sample group file to generate ESTIMATE score boxplots and a significance summary table.\n5. The workflow always generates an ESTIMATE score heatmap from the computed score table.\n6. Read reference files only when you need algorithm details, troubleshooting, or baseline execution notes.\n\n## When to Read External Files\n\n| Situation | File to Read | Purpose |\n|-----------|--------------|---------|\n| Need algorithm details | `references\/algorithm.md` | Understand the ESTIMATE scoring workflow and result interpretation |\n| Need to run the skill | `scripts\/main.R` | Execute the CLI entry point |\n| Encounter errors | `references\/troubleshooting.md` | Find standard error codes and fixes |\n| Need more CLI examples or the real-data baseline record | `references\/cli-guide.md` | Copy commands and review the recorded execution template |\n| Need sample input files | `tests\/data\/` | Use the bundled demo expression matrix |\n\n## When Not to Use\n\n- Immune cell fraction estimation: use a CIBERSORT-like deconvolution workflow instead\n- Differential testing between biological groups: use a differential analysis skill instead\n- Single-cell analysis: use a single-cell-specific workflow\n- Clinical diagnosis or treatment decision support: do not use this skill\n\nIf the request is outside ESTIMATE score generation for bulk expression matrices, stop and explain that this skill only covers ESTIMATE-based score computation.\n\n## Input Validation\n\nThis skill accepts:\n\n- one bulk expression matrix in CSV or TSV format with genes in the first column and samples in the remaining columns\n- an optional sample group file in CSV or TSV format for grouped boxplots and significance testing\n- requests to compute ESTIMATE-derived StromalScore, ImmuneScore, ESTIMATEScore, TumorPurity, and related visualizations from bulk transcriptomic data\n\nDo not use this workflow for:\n\n- single-cell RNA-seq or spatial transcriptomics\n- immune cell deconvolution requests\n- direct clinical diagnosis, treatment recommendation, or patient-level medical decision making\n- unrelated tasks such as literature writing, web scraping, or generic plotting without ESTIMATE score generation\n\nIf the user's request is outside this scope, do not proceed with the workflow. Instead respond:\n\n> `estimate-immune-score-analysis` is designed to compute ESTIMATE-based tumor microenvironment scores from a bulk expression matrix. Your request appears to be outside this scope. Please provide a valid bulk expression matrix and, if needed, a matching sample group file, or use a more appropriate skill for your task.\n\n## Usage\n\n```bash\nRscript scripts\/main.R \\\n  --input_file .\/expression_matrix.csv \\\n  --group_file .\/group_info.csv \\\n  --output_dir .\/output \\\n  --gene_id_type GeneSymbol \\\n  --platform affymetrix \\\n  --seed 42\n```\n\n## Arguments\n\n| Short | Long | Type | Default | Description |\n|-------|------|------|---------|-------------|\n| `-i` | `--input_file` | character | required | Expression matrix file in CSV or TSV format |\n| `-o` | `--output_dir` | character | `.\/output` | Output directory |\n|  | `--group_file` | character | optional | Sample group file used for ESTIMATE score boxplots and significance testing |\n| `-g` | `--gene_id_type` | character | `GeneSymbol` | Gene identifier type: `GeneSymbol` or `EntrezID` |\n| `-p` | `--platform` | character | `affymetrix` | ESTIMATE platform: `affymetrix`, `agilent`, or `illumina` |\n| `-s` | `--seed` | integer | `42` | Random seed |\n| `-t` | `--timeout_seconds` | integer | `0` | Optional timeout in seconds; `0` disables timeout |\n|  | `--input_delimiter` | character | `auto` | Input delimiter hint: `auto`, `csv`, or `tsv` |\n|  | `--group_delimiter` | character | `auto` | Group file delimiter hint: `auto`, `csv`, or `tsv` |\n|  | `--sample_column` | character | `sample` | Sample column name in the group file |\n|  | `--group_column` | character | `group` | Group column name in the group file |\n|  | `--plot_file` | character | `estimate_scores_boxplot.pdf` | Boxplot file name written under `plot\/` |\n|  | `--heatmap_file` | character | `estimate_scores_heatmap.pdf` | Heatmap file name written under `plot\/` |\n\n## Input Format\n\n- CSV or TSV file\n- First column contains gene identifiers\n- Remaining columns are sample names\n- Expression values must be numeric and non-missing\n- Sample column names must be unique; duplicate sample column names raise `SKILL_INVALID_PARAMETER`\n\nExample:\n\n```csv\ngene,S1,S2,S3\nTP53,8.1,7.9,6.5\nEGFR,5.2,5.0,4.2\n```\n\nThe bundled `tests\/data\/expression_matrix.csv` was copied from `cibersort-immune-infiltration-analysis\/tests\/data\/expression_matrix.csv` for demo and validation use.\n\n### Optional Group File\n\n- CSV or TSV file\n- Must contain one sample column and one group column\n- Sample names must match the ESTIMATE score table sample IDs\n- **Exactly two group levels are supported** for boxplot comparison. If more than two groups are present in the group file, `SKILL_INVALID_PARAMETER` is raised.\n- Each group must contain **at least 3 samples** for valid statistical testing. Groups with fewer samples trigger `SKILL_INVALID_PARAMETER`.\n- If the group file is provided but grouped comparison fails after core scoring, the command exits with a `SKILL_*` error after preserving the core ESTIMATE outputs and failure records\n\nExample:\n\n```csv\nsample,group\nS1,Tumor\nS2,Tumor\nS3,Healthy\nS4,Healthy\n```\n\n## Output Files\n\n| File | Description |\n|------|-------------|\n| `data\/expression_input.tsv` | Tab-delimited expression matrix prepared for ESTIMATE |\n| `data\/estimate_input.gct` | GCT file created by `estimate::filterCommonGenes()` |\n| `data\/estimate_score.gct` | Raw ESTIMATE score output from `estimate::estimateScore()` |\n| `table\/estimate_scores.tsv` | Reformatted sample-by-score table |\n| `plot\/estimate_scores_heatmap.pdf` | Sample-level ESTIMATE score heatmap |\n| `table\/estimate_score_group_stats.csv` | Per-score p-values and the group with the higher median score when `--group_file` is provided |\n| `plot\/estimate_scores_boxplot.pdf` | ESTIMATE score boxplot when `--group_file` is provided |\n| `session_info.txt` | R session and package version information |\n| `output_manifest.txt` | Append-only output file manifest with descriptions |\n| `run_record.txt` | Append-only run record with parameters, runtime, and output summary |\n\n## Workflow\n\n### Step 1: Validate Input\n\n- Confirm the input file exists\n- Confirm the matrix contains at least one gene column and one or more sample columns\n- Confirm all expression columns are numeric and sample names are unique\n\n### Step 2: Run ESTIMATE\n\n- Convert the matrix to a tab-delimited file with the selected gene identifier header\n- Run `estimate::filterCommonGenes()`\n- Run `estimate::estimateScore()`\n\n### Step 3: Export Results\n\n- Save the raw GCT outputs under `data\/`\n- Reformat the score matrix into `table\/estimate_scores.tsv`\n- Create `plot\/estimate_scores_heatmap.pdf`\n- If `--group_file` is supplied, create `plot\/estimate_scores_boxplot.pdf`\n- If `--group_file` is supplied, create `table\/estimate_score_group_stats.csv`\n- If grouped comparison fails after core scoring, keep the core outputs, append failure details to `output_manifest.txt` and `run_record.txt`, and exit with a `SKILL_*` message\n- Save `session_info.txt`\n- Append a run section to `output_manifest.txt` and `run_record.txt`\n\n## Examples\n\n### Basic Usage\n\n```bash\nRscript scripts\/main.R \\\n  --input_file .\/expression_matrix.csv \\\n  --output_dir .\/output\n```\n\n### Grouped Comparison\n\n```bash\nRscript scripts\/main.R \\\n  --input_file .\/expression_matrix.csv \\\n  --group_file .\/group_info.csv \\\n  --output_dir .\/grouped_output\n```\n\n### TSV Input\n\n```bash\nRscript scripts\/main.R \\\n  --input_file .\/expression_matrix.tsv \\\n  --input_delimiter tsv \\\n  --output_dir .\/tsv_output \\\n  --gene_id_type GeneSymbol\n```\n\n### Alternate Platform\n\n```bash\nRscript scripts\/main.R \\\n  --input_file .\/expression_matrix.csv \\\n  --output_dir .\/illumina_output \\\n  --platform illumina \\\n  --seed 123\n```\n\nFor the real-data baseline execution record, READ: `references\/cli-guide.md`\n\n## Error Handling\n\n| Error Code | Meaning | Solution |\n|------------|---------|----------|\n| `SKILL_FILE_NOT_FOUND` | Input file is missing or an expected intermediate file was not created | Check file paths and rerun |\n| `SKILL_MISSING_COLUMNS` | The gene identifier column contains missing values | Repair the first column and rerun |\n| `SKILL_EMPTY_DATA` | The matrix or ESTIMATE output is empty | Verify input content and identifier compatibility |\n| `SKILL_INVALID_PARAMETER` | A CLI argument is unsupported; the matrix contains invalid values; duplicate sample column names detected; more than two group levels provided; or a group contains fewer than 3 samples | Review arguments and input values |\n| `SKILL_SAMPLE_MISMATCH` | Sample names in the group file do not overlap the ESTIMATE score table | Align sample IDs before rerunning |\n| `SKILL_PACKAGE_NOT_FOUND` | Required R packages are not installed | Install missing packages listed in `references\/cli-guide.md` |\n\nIf the error persists, READ: `references\/troubleshooting.md`\n\nFor optional group comparison failures such as `SKILL_SAMPLE_MISMATCH`, inspect the preserved core outputs together with `output_manifest.txt` and `run_record.txt` to see what completed before the grouped step failed.\n\n## Testing\n\n```bash\nRscript scripts\/main.R --help\n\nRscript tests\/run_tests.R\n\nRscript scripts\/main.R \\\n  --input_file tests\/data\/expression_matrix.csv \\\n  --group_file tests\/data\/group_info.csv \\\n  --output_dir tests\/output \\\n  --gene_id_type GeneSymbol \\\n  --platform affymetrix \\\n  --seed 42\n```\n\nExpected outputs:\n\n- `tests\/output\/data\/expression_input.tsv`\n- `tests\/output\/data\/estimate_input.gct`\n- `tests\/output\/data\/estimate_score.gct`\n- `tests\/output\/table\/estimate_scores.tsv`\n- `tests\/output\/plot\/estimate_scores_heatmap.pdf`\n- `tests\/output\/table\/estimate_score_group_stats.csv`\n- `tests\/output\/plot\/estimate_scores_boxplot.pdf`\n- `tests\/output\/session_info.txt`\n- `tests\/output\/output_manifest.txt`\n- `tests\/output\/run_record.txt`\n\nOptional post-check:\n\n```bash\nRscript tests\/test_skill.R tests\/output\n```\n\n## References\n\n1. Yoshihara K, Shahmoradgoli M, Martinez E, et al. (2013) Inferring tumour purity and stromal and immune cell admixture from expression data. *Nature Communications*. doi:10.1038\/ncomms3612\n\nFor detailed algorithm notes, READ: `references\/algorithm.md`\n\n## Implementation Checklist\n\n- [x] CLI parsing with `optparse`\n- [x] `set.seed()` for reproducibility\n- [x] Only public CRAN\/Bioconductor packages used\n- [x] Script parameters documented in `SKILL.md`\n- [x] `get_script_dir()` defined before any call to it\n- [x] File reading instructions in `SKILL.md`\n- [x] Test data provided in `tests\/data\/`\n- [x] Error handling implemented with `SKILL_*` messages\n- [x] Baseline record completed in `references\/cli-guide.md`\n- [x] `skill-auditor` outputs generated after container execution\n","use_cases":["Run ESTIMATE immune score analysis on bulk RNA-seq data","Calculate ImmuneScore and StromalScore from bulk transcriptomic data","Generate ESTIMATE scores and save a sample-level result table"],"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\/estimate-immune-score-analysis\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-24","created_at":"2026-11-23T07:05:52.000000Z","updated_at":"2026-11-24T07:13:04.000000Z","seo_title":"ESTIMATE Immune Score Analysis Tool","seo_description":"Compute ESTIMATE immune and stromal scores from bulk expression data with heatmap and group-wise boxplots. Use for tumor microenvironment analysis.","seo_keywords":["ESTIMATE immune score analysis","bulk RNA-seq ESTIMATE scores","tumor microenvironment analysis","ESTIMATE score heatmap","group-wise ESTIMATE boxplots"]}}