biotender-max/awesome-bio-agent-skills/bioskills-differential-expression-batch-correction
Claude Code and agent skill by biotender-max/awesome-bio-agent-skills
- community
Checking that the SKILL.md file is still in the repository.
Remove batch effects from RNA-seq data using ComBat, ComBat-Seq, limma removeBatchEffect, and SVA for unknown batch variables. Use when correcting batch effects in expression data.
Install
npx vskill@latest install biotender-max/awesome-bio-agent-skills/bioskills-differential-expression-batch-correctionSKILL.md
The same SKILL.md was published earlier as biotender-max/awesome-bio-agent-skills/bioskills-differential-expression-batch-correction.
Version Compatibility
Reference examples tested with: DESeq2 1.42+, ggplot2 3.5+, limma 3.58+, scanpy 1.10+
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion('<pkg>')then?function_nameto verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Batch Effect Correction
ComBat-Seq (Count Data)
Goal: Remove batch effects from raw count data while preserving biological group differences.
Approach: Apply ComBat-Seq's negative binomial regression to adjust counts, keeping the integer nature of the data.
"Remove batch effects from my RNA-seq counts" → Adjust raw count matrix for known batch labels using negative binomial modeling, preserving biological condition effects.
ComBat (Normalized Data)
Goal: Remove batch effects from normalized (log-transformed or TPM) expression data.
Approach: Apply parametric empirical Bayes adjustment to normalized expression while protecting biological covariates.
limma removeBatchEffect
Goal: Produce batch-corrected expression values for visualization while preserving group differences.
Approach: Regress out the batch effect from normalized expression using limma's linear model.
DESeq2 Design Formula (Recommended for DE)
Goal: Account for batch effects during DE testing without modifying the count data.
Approach: Include batch as a covariate in the DESeq2 design formula so batch variance is modeled, not removed.
Surrogate Variable Analysis (SVA)
Goal: Discover and correct for unknown sources of variation (hidden batch effects).
Approach: Estimate surrogate variables from the residual variation not explained by the biological model.
"Correct for unknown batch effects in my expression data" → Estimate latent surrogate variables capturing unwanted variation, then include them as covariates in the DE model.
SVA with DESeq2
Goal: Integrate surrogate variables into DESeq2 to adjust for hidden confounders during DE testing.
Approach: Estimate SVs from normalized counts, add them to colData, and update the design formula.
Visualize Batch Effects
Goal: Confirm batch effect removal by comparing PCA plots before and after correction.
Approach: Run PCA on pre- and post-correction expression, coloring points by batch and condition.
Quantify Batch Effect
Goal: Measure the proportion of variance attributable to batch versus biological condition.
Approach: Correlate principal components with batch and condition labels, or use PVCA.
Harmony (Single-Cell Integration)
Goal: Integrate single-cell data from multiple batches into a shared embedding.
Approach: Apply Harmony to PCA embeddings to iteratively remove batch effects while preserving cell-type structure.
Critical: When NOT to Use Corrected Counts
Never use batch-corrected counts as input to DESeq2 or edgeR. Two-step correction (ComBat/ComBat-Seq then DE) introduces correlation structure in residuals, inflating or deflating significance. Include batch as a covariate in the design formula (~ batch + condition) instead.
limma::removeBatchEffect() is designed for visualization only — it does not produce counts suitable for DE testing.
| Task | Use Raw Counts + Design | Use Corrected Values | |
|---|---|---|---|
| Differential expression | Yes (~ batch + condition) | No | |
| Pathway analysis on DE results | Yes (from design-based DE) | No | |
| PCA, UMAP, heatmaps | — | Yes | |
| Clustering | — | Yes | |
| Machine learning features | — | Yes | |
| Cross-study meta-analysis | — | Yes (ComBat-Seq) |
Confounding and Limitations
| Situation | Detectable? | Solution | |
|---|---|---|---|
| Batch partially correlated with condition | Yes (PCA) | Include batch in design; results are valid but power is reduced | |
| Batch perfectly correlated with condition (all treated in batch 1, all control in batch 2) | Yes (PCA) | Unfixable — cannot separate batch from condition | |
| Unknown batch variables | Sometimes (PCA shows unexplained clustering) | Use SVA to estimate surrogate variables | |
| Over-correction removing biological signal | Hard to detect | Compare results with and without correction; balanced designs prevent this |
Related Skills
- differential-expression/deseq2-basics - DE with batch in design
- single-cell/clustering - Integration methods
- expression-matrix/normalization - Data normalization and transformation
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/bioskills/bioskills__differential-expression__batch-correction/SKILL.md
Popularity
- Repository stars
- 193
- Repository forks
- 33
- 7-day trend score
- 26
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/biotender-max/awesome-bio-agent-skills/bioskills-differential-expression-batch-correction)