Bulk RNAseq differential expression (DeSeq2)
Automates DESeq2 workflow for RNA-seq count data to identify differentially expressed genes.
Install
mkdir -p .claude/skills/bulk-rnaseq-differential-expression-deseq2 && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11018" && unzip -o skill.zip -d .claude/skills/bulk-rnaseq-differential-expression-deseq2 && rm skill.zipInstalls to .claude/skills/bulk-rnaseq-differential-expression-deseq2
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Core DESeq2 workflow for RNA-seq differential expression analysis with count data.Key capabilities
- →Process raw integer count matrices
- →Perform Wald or likelihood ratio tests
- →Apply log fold change shrinkage
- →Generate QC plots including PCA and volcano plots
- →Normalize count data using size factors
How it works
The skill creates a DESeqDataSet object from raw counts, performs size factor normalization, and estimates dispersions to test for differential expression.
Inputs & outputs
When to use Bulk RNAseq differential expression (DeSeq2)
- →Analyzing rna-seq counts
- →Differential expression testing
- →Ranking differentially expressed genes
About this skill
DESeq2 Differential Expression Analysis
Core DESeq2 workflow for RNA-seq differential expression analysis with count data.
When to Use This Skill
Use DESeq2 when you have:
- ✅ Raw integer count data (not normalized TPM/FPKM)
- ✅ Biological replicates (≥2 per condition, ≥4 recommended)
- ✅ Need for log fold change shrinkage (ranking/visualization)
- ✅ Medium to large sample sizes (DESeq2's strength)
Don't use DESeq2 for:
- ❌ Normalized data (TPM/FPKM) → use limma-voom instead
- ❌ Very small samples (n=2-3) → consider edgeR quasi-likelihood
Quick Start (Example Data)
Test this skill with real RNA-seq data in ~2 minutes:
source("scripts/load_example_data.R")
data <- load_pasilla_data() # Auto-installs pasilla package if needed (~2 min, ~50MB)
counts <- data$counts # 14,599 genes × 7 samples
coldata <- data$coldata # Metadata: treated vs untreated
# Run complete workflow
source("scripts/basic_workflow.R") # Creates dds, res, resLFC objects + prints summary
What you get:
- Dataset: Drosophila pasilla gene RNAi knockdown (Brooks et al. 2011)
- Comparison: 3 treated vs 4 untreated samples
- Expected results: ~1,000 significant genes at padj < 0.1
For your own data: Replace data loading with your count matrix and metadata (see Inputs section).
Installation
Core packages (required):
# Set CRAN mirror first (required for installation)
options(repos = c(CRAN = "https://cloud.r-project.org"))
if (!require('BiocManager', quietly = TRUE))
install.packages('BiocManager')
BiocManager::install(c('DESeq2', 'apeglm'))
Example data packages (optional - for testing/learning):
BiocManager::install(c('pasilla', 'airway')) # ~70MB total, ~2-3 min
Visualization packages (required for QC plots):
# For publication-quality plots (required - generates PNG)
install.packages(c('ggplot2', 'ggprism', 'ggrepel'))
# For SVG export (optional - generates both PNG + SVG)
install.packages('svglite')
License: LGPL (>= 3) (commercial use permitted)
Inputs
Required:
- Count matrix: Raw integer counts (genes × samples)
- Rows = genes (any identifier: Ensembl, symbols, etc.)
- Columns = samples
- Values = non-negative integers
- Sample metadata: Data frame with sample information
- Row names must match count matrix column names
- Required column:
condition(factor with 2+ levels) - Optional: batch, covariates for complex designs
Alternative inputs:
- Salmon/Kallisto output (via tximport)
- SummarizedExperiment object
- featureCounts/HTSeq output
- Bioconductor data packages (pasilla, airway)
See references/deseq2-reference.md for loading examples.
Outputs
Primary results:
deseq2_results.csv- Full differential expression table (baseMean, log2FC, lfcSE, pvalue, padj)deseq2_results_shrunk.csv- Shrunken LFC for visualization/rankingdds_object.rds- DESeqDataSet for further analysis
Normalized data:
normalized_counts.csv- Size-factor normalized countsvst_transformed.csv/rlog_transformed.csv- Variance-stabilized values
QC plots (PNG always, SVG strongly preferred, 300 DPI):
dispersion_plot.png/.svg- Dispersion estimates vs meanpca_plot.png/.svg- Principal component analysisma_plot.png/.svg- Mean-average plotvolcano_plot.png/.svg- Volcano plot (log2FC vs -log10 padj)- ⚠️ SVG requires
svglitepackage:install.packages('svglite')(falls back to PNG-only if unavailable)
Clarification Questions
⚠️ CRITICAL: Always ask question #1 first to check if user has provided input files before proceeding with analysis.
Before starting, gather:
-
Input Files (ASK THIS FIRST):
- Do you have specific count matrix file(s) to analyze?
- If uploaded: Is this the count matrix (genes × samples, raw integer counts)?
- Expected formats: CSV/TSV, RDS (SummarizedExperiment), Salmon/Kallisto output
- Or use example data for testing?
- Use
source("scripts/load_example_data.R"); data <- load_pasilla_data() - Requires installing
pasillapackage (~2 min, ~50MB)
- Use
- ⚠️ If data is normalized (TPM/FPKM): Use limma-voom skill instead
- Do you have specific count matrix file(s) to analyze?
-
Sample Metadata (if using own data):
- What is the primary comparison (e.g., treated vs control)?
- Which group is the reference/control?
- Any covariates to adjust for (batch, sex, sequencing run)?
- Validation: Confirm sample IDs match between count matrix columns and metadata rows
-
Experimental Design:
- Simple:
~ condition| Multi-factor:~ batch + condition| Paired:~ individual + condition| Interaction:~ genotype * treatment - See references/decision-guide.md#design-formulas
- Simple:
-
Sample Size Check:
- n ≥ 4 per group (recommended) | n = 2-3 (consider edgeR) | n < 2 (insufficient)
-
Significance Thresholds:
- Standard: padj < 0.05, |log2FC| ≥ 1 | Relaxed: padj < 0.1 | Stringent: padj < 0.01, |log2FC| ≥ 2
-
Analysis Goals:
- Single pairwise comparison or multiple comparisons?
- Need visualizations (volcano, heatmap)? → Use de-results-to-plots skill after
- Need gene annotations? → Use de-results-to-gene-lists skill after
Typical Complete Workflow
This skill performs core differential expression analysis with QC plots. For a complete RNA-seq workflow:
- This skill: Run DESeq2 → get
dds,res, normalized counts, QC plots (PCA, MA, volcano, dispersion) - de-results-to-gene-lists: Filter significant genes → add annotations → export
- de-results-to-plots (optional): Advanced visualizations (heatmaps, custom plots)
Quick start: "Run DESeq2 analysis and filter significant genes with annotations"
Why separate skills? Modular design works across DE methods (DESeq2, edgeR, limma). See Suggested Next Steps for details.
Standard Workflow
Note: Run from the OmicsClaw root directory and add the workflow scripts to
sys.path:import sys; import os; sys.path.insert(0, os.path.abspath('knowledge_base/scripts/bulk-rnaseq-counts-to-de-deseq2'))
🚨 MANDATORY: USE SCRIPTS EXACTLY AS SHOWN - DO NOT WRITE INLINE CODE 🚨
This skill uses low-freedom script execution. You must:
- ✅ Source the scripts using the exact commands below
- ✅ Wait for confirmation messages after each step
- ❌ NOT write inline DESeq2 code
- ❌ NOT rewrite plotting code
- ❌ NOT modify commands unless explicitly adapting for user-specific data
WHY USE SCRIPTS: They handle package installation, data validation, sample ID fixes, and error checking automatically. Writing inline code wastes time, introduces errors, and violates the skill design.
Step 1 - Load example data:
source("scripts/load_example_data.R")
data <- load_pasilla_data()
counts <- data$counts
coldata <- data$coldata
Step 2 - Run DESeq2 analysis:
source("scripts/basic_workflow.R")
DO NOT expand this into inline code. DO NOT write the DESeq2 steps manually. Just source the script.
Step 3 - Generate QC plots:
source("scripts/qc_plots.R")
run_all_qc(dds, res, output_dir = "results")
🚨 DO NOT write inline plotting code (ggsave, plotMA, etc.). Just source the script. 🚨
The script handles PNG + SVG export with graceful fallback for SVG dependencies.
Step 4 - Export results:
source("scripts/export_results.R")
export_all(dds, res, resLFC, output_dir = "results")
DO NOT write custom export code. Use export_all() to save all standard outputs including RDS and transformed counts.
✅ VERIFICATION - You should see these messages:
- After Step 1:
"✓ Pasilla dataset loaded successfully"with dimensions - After Step 2:
"✓ Basic workflow completed successfully!"with summary statistics - After Step 3:
"✓ All QC plots generated successfully!"with file names - After Step 4:
"=== Export Complete ==="with list of 6-7 files saved
❌ IF YOU DON'T SEE THESE MESSAGES: You wrote inline code instead of using source(). Stop and use the commands above.
⚠️ CRITICAL - DO NOT:
- ❌ Write inline data loading code → STOP: This violates the skill design. Use
source("scripts/load_example_data.R")instead. Inline loading causes sample ID mismatches and missing validations. - ❌ Write inline DESeq2 workflow code → STOP: This violates the skill design. Use
source("scripts/basic_workflow.R")instead. Inline workflow wastes time and introduces bugs. - ❌ Write inline plotting code (ggsave, plotMA, etc.) → STOP: This violates the skill design. Use
source("scripts/qc_plots.R")andrun_all_qc()instead. If scripts fail, fix the script, don't rewrite inline. - ❌ Write custom export code → STOP: This violates the skill design. Use
source("scripts/export_results.R")andexport_all()instead. Custom export code misses RDS objects and transformed counts needed downstream. - ❌ Try to install svglite → script handles SVG fallback automatically
- ❌ Use absolute paths for scripts → Always use relative paths
scripts/file.R- ❌ WRONG:
source("/mnt/knowhow/workflows/bulk-rnaseq-counts-to-de-deseq2/scripts/load_example_data.R") - ❌ WRONG:
setwd("/absolute/path/to/skill") - ✅ CORRECT:
source("scripts/load_example_data.R")(skill should already be working directory)
- ❌ WRONG:
⚠️ IF SCRIPTS FAIL - Script Failure Hierarchy:
- Fix and Retry (90%) - Install missing package, re-run script
- Modify Script (5%) - Edit the script file itself, document changes
- Use as Reference (4%) - Read script, adapt approach, cite source
- Write from Scratch (1%) - Only if genuinely impossible, explain why
NEVER skip directly to writing inline code without trying the script first.
📁 Output Directory Paths:
- ✅ Reco
Content truncated.
When not to use it
- →When input data is already normalized as TPM or FPKM
- →When sample sizes are very small (n=2-3)
Prerequisites
Limitations
- →Requires raw integer counts
- →Not suitable for normalized TPM or FPKM data
- →Best performance requires n>=4 samples
How it compares
This workflow automates the specific statistical pipeline for raw count data, whereas manual approaches require individual script management for normalization and testing.
Compared to similar skills
Bulk RNAseq differential expression (DeSeq2) side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| Bulk RNAseq differential expression (DeSeq2) (this skill) | 0 | 2mo | No flags | Advanced |
| quant-analyst | 103 | 2mo | No flags | Advanced |
| umap-learn | 6 | 2mo | Review | Intermediate |
| embedding-strategies | 8 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by BioTender-max
View all by BioTender-max →You might also like
quant-analyst
zenobi-us
Expert quantitative analyst specializing in financial modeling, algorithmic trading, and risk analytics. Masters statistical methods, derivatives pricing, and high-frequency trading with focus on mathematical rigor, performance optimization, and profitable strategy development.
umap-learn
K-Dense-AI
UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D/3D visualization, clustering preprocessing (HDBSCAN), supervised/parametric UMAP, for high-dimensional data.
embedding-strategies
wshobson
Select and optimize embedding models for semantic search and RAG applications. Use when choosing embedding models, implementing chunking strategies, or optimizing embedding quality for specific domains.
building-automl-pipelines
jeremylongshore
Build automated machine learning pipelines, including feature engineering, model selection, and performance evaluation.
model-compare
rawwerks
Compare 3D CAD models using boolean operations (IoU, Dice, precision/recall). Use when evaluating generated models against gold references, diffing CAD revisions, or computing similarity metrics for ML training. Triggers on: model diff, compare models, IoU, intersection over union, model similarity, CAD comparison, STEP diff, 3D evaluation, gold reference, generated model, precision recall 3D.
matchms
davila7
Mass spectrometry analysis. Process mzML/MGF/MSP, spectral similarity (cosine, modified cosine), metadata harmonization, compound ID, for metabolomics and MS data processing.