sciagent-skill-creator
Scaffold a new SciAgent-Skills entry. Picks pipeline/toolkit/database/guide template, creates skills/{category}/{name}/SKILL.md…
Bulk RNA-seq DE with PyDESeq2: load counts, normalize, fit negative binomial models, Wald test (BH-FDR), LFC shrinkage, volcano/MA plots. Use for two-group comparisons, multi-factor designs with batch correction, multiple contrasts.
Claude Code
$ npx -y skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression --agent claude-code
Codex
$ npx skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression -a codex -y
Cursor
$ npx skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression -a cursor -y
Gemini CLI
$ npx skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression -a gemini-cli -y
GitHub Copilot
$ npx skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression -a github-copilot -y
OpenCode
$ npx skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression -a opencode -y
Windsurf
$ npx skills add jaechang-hits/SciAgent-Skills --skill pydeseq2-differential-expression -a windsurf -y
name: "pydeseq2-differential-expression" description: "Bulk RNA-seq DE with PyDESeq2: load counts, normalize, fit negative binomial models, Wald test (BH-FDR), LFC shrinkage, volcano/MA plots. Use for two-group comparisons, multi-factor designs with batch correction, multiple contrasts." license: "CC-BY-4.0"
PyDESeq2 is a Python reimplementation of the R DESeq2 package for differential gene expression analysis from bulk RNA-seq count data. It fits negative binomial generalized linear models per gene, estimates dispersion with empirical Bayes shrinkage, and performs Wald tests with Benjamini-Hochberg FDR correction. This skill covers the full pipeline from raw counts to publication-ready result tables and visualizations.
pip install pydeseq2 matplotlib seaborn
Settle these with the user before writing any analysis code.
decisions:
- id: D1
param: design
kind: required
source: data
ask: "Which column of the sample sheet separates the groups you want to compare?"
default: null
- id: D2
param: contrast
kind: required
source: user
depends_on: [D1]
ask: "Within that column, which group is the baseline the others are measured against?"
default: null
- id: D3
param: design
kind: required
source: data
depends_on: [D1]
ask: "Is there a nuisance variable to adjust for (batch, donor, sex, sequencing run)?"
default: "none - compare groups without covariates"
skip_if: "sample sheet carries no column besides the grouping variable"
- id: D4
param: alpha
kind: optional
source: user
ask: "How strong must the evidence be before a gene counts as changed (false-discovery rate)?"
default: 0.05
- id: D5
param: lfc_cutoff
kind: optional
source: user
ask: "How large a fold change is worth reporting, on top of the statistical call?"
default: "|log2FC| > 0.58 (1.5x change)"
- id: D6
param: min_total_counts
kind: optional_conditional
source: data
ask: "Genes with very few reads cannot be tested - where should the floor sit?"
default: 10
- id: D7
param: lfc_shrink
kind: optional
source: user
ask: "Shrink fold-change estimates so low-count genes stop dominating the rankings and plots?"
default: "applied for ranking and visualization, not for significance calls"
- id: D8
param: refit_cooks, cooks_filter, independent_filter
kind: optional
source: user
ask: "Should DESeq2 retain its default outlier replacement and adaptive filtering behavior?"
default: true
- id: D9
param: n_cpus
kind: never_ask
source: data
reason: "Affects runtime only, not the result"
default: 4`design` appears twice because the formula is assembled from both D1 and D3; D2 then selects which coefficient of that fitted model is tested.
Load the count matrix and metadata. PyDESeq2 expects counts as a samples x genes DataFrame with non-negative integers, and metadata as a samples x variables DataFrame with matching indices.
import pandas as pd
# Load data — typical CSV has genes as rows, samples as columns
counts_raw = pd.read_csv("counts.csv", index_col=0)
metadata = pd.read_csv("metadata.csv", index_col=0)
# Transpose if needed: PyDESeq2 requires samples x genes
if counts_raw.shape[0] > counts_raw.shape[1]:
counts_df = counts_raw.T # genes x samples → samples x genes
else:
counts_df = counts_raw
# Validate alignment
common_samples = counts_df.index.intersection(metadata.index)
counts_df = counts_df.loc[common_samples]
metadata = metadata.loc[common_samples]
print(f"Samples: {counts_df.shape[0]}, Genes: {counts_df.shape[1]}")
print(f"Metadata columns: {list(metadata.columns)}")
print(f"Condition counts:\n{metadata['condition'].value_counts()}")Remove lowly expressed genes to improve statistical power and reduce multiple testing burden.
# Filter genes with total counts below threshold
min_total_counts = 10
gene_counts = counts_df.sum(axis=0)
genes_to_keep = gene_counts[gene_counts >= min_total_counts].index
counts_df = counts_df[genes_to_keep]
# Optional: require minimum counts in a minimum number of samples
min_count_per_sample = 5
min_samples = 3
genes_expressed = (counts_df >= min_count_per_sample).sum(axis=0) >= min_samples
counts_df = counts_df.loc[:, genes_expressed]
print(f"Genes after filtering: {counts_df.shape[1]}")Create the DESeq dataset object, specify the design formula, and run the full pipeline (size factor estimation, dispersion estimation, model fitting).
from pydeseq2.dds import D
Turn your AI coding agent into a life sciences expert — 199 bioinformatics skills for Claude Code covering RNA-seq, single-cell analysis, genomics, proteomics, drug discovery, and more. Boosted BixBench from 65% to 92%. Open source.
Scaffold a new SciAgent-Skills entry. Picks pipeline/toolkit/database/guide template, creates skills/{category}/{name}/SKILL.md…
Bayesian modeling with PyMC 5: priors, likelihood, NUTS/ADVI sampling, diagnostics (R-hat, ESS), LOO/WAIC comparison, prediction.…
Time-to-event modeling with scikit-survival: Cox PH (elastic net), Random Survival Forests, Boosting, SVMs for censored data.…
Guided statistical analysis: test choice, assumption checks, effect sizes, power, APA reporting. Pick tests, verify assumptions,…
Python statistical modeling: regression (OLS, WLS, GLM), discrete (Logit, Poisson, NegBin), time series (ARIMA, SARIMAX, VAR),…
DL cell/nucleus segmentation for fluorescence and brightfield microscopy. Pre-trained models (cyto3, nuclei, tissuenet) and a…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.