
Batch Effect Correction
Use when correcting batch effects in merged bulk expression matrices with sample-level...
Install
npx skills add aipoch/medical-research-skills --skill batch-effect-correction -g -a claude-code -y- Repository
- aipoch/medical-research-skills2k
- Category
- Engineering
- Updated
- 2mo ago
- License
- MIT
- Context cost
- Mediumabout 2,653 tokens
- Runs scripts
- No, instructions only
What it does
Use when correcting batch effects in merged bulk expression matrices with sample-level batch metadata while preserving biological group structure and generating before-and-after QC plots. NOT for: single-cell integration, raw FASTQ processing, differential expression without batch labels, or datasets without biological groups.
Batch Effect Correction
Prerequisites
Run the following before the first analysis to install all required R packages:
Rscript -e "if (!require('BiocManager', quietly=TRUE)) install.packages('BiocManager'); BiocManager::install(c('sva', 'limma')); install.packages('ggplot2', repos='https://cloud.r-project.org')"
Note:
svaandlimmaare Bioconductor packages and requireBiocManagerfor installation.ggplot2is a standard CRAN package.
The skill cannot run until these packages are installed. In new or bare R environments, always run the prerequisite step first.
When to Read External Files
| Situation | File to Read | Purpose |
|---|---|---|
| Need algorithm details | references/algorithm.md | ComBat workflow, assumptions, and QC logic |
| Need to run analysis | scripts/main.R | Execute: Rscript scripts/main.R --input_file ... --group_file ... |
| Encounter errors | references/troubleshooting.md | Common errors and solutions |
| Need CLI examples | references/cli-guide.md | Detailed CLI usage examples and baseline run record |
| Need test data | tests/data/ | Sample input files for testing |
Usage
Rscript scripts/main.R \
--input_file ./expression_matrix.csv \
--group_file ./sample_info.csv \
--output_dir ./output/ \
--batch_column batch \
--group_column group \
--sample_column sample \
--log_transform auto \
--timeout_seconds 600 \
--seed 42
