Hypothesis Generation
spacering-net/codeg
Structured hypothesis formulation from observations. An agent skill from spacering-net/codeg.
Aligns sample metadata with count matrices and constructs design matrices for downstream DE, handling the alphabetical-reference-level trap (relevel BEFORE DESeq), LRT reduced-model rules, the…
$ npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install GPTomics/bioSkills bio-expression-matrix-metadata-joins --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ git clone --depth 1 https://github.com/GPTomics/bioSkills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/expression-matrix/metadata-joins .claude/skills/bio-expression-matrix-metadata-joins && rm -rf skills-srcUse ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.
Claude Code skills documentation · loads skills from .claude/skills/
Install the "bio-expression-matrix-metadata-joins" agent skill from https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joins into .claude/skills/bio-expression-matrix-metadata-joins/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "bio-expression-matrix-metadata-joins", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joinsType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install GPTomics/bioSkills bio-expression-matrix-metadata-joins --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/GPTomics/bioSkills.git skills-src && mkdir -p .agents/skills && cp -r skills-src/expression-matrix/metadata-joins .agents/skills/bio-expression-matrix-metadata-joins && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "bio-expression-matrix-metadata-joins" agent skill from https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joins into .agents/skills/bio-expression-matrix-metadata-joins/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "bio-expression-matrix-metadata-joins", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install GPTomics/bioSkills bio-expression-matrix-metadata-joins --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/GPTomics/bioSkills.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/expression-matrix/metadata-joins .cursor/skills/bio-expression-matrix-metadata-joins && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "bio-expression-matrix-metadata-joins" agent skill from https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joins into .cursor/skills/bio-expression-matrix-metadata-joins/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "bio-expression-matrix-metadata-joins", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/GPTomics/bioSkills.git --path expression-matrix/metadata-joins--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install GPTomics/bioSkills bio-expression-matrix-metadata-joins --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/GPTomics/bioSkills.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/expression-matrix/metadata-joins .gemini/skills/bio-expression-matrix-metadata-joins && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "bio-expression-matrix-metadata-joins" agent skill from https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joins into .gemini/skills/bio-expression-matrix-metadata-joins/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "bio-expression-matrix-metadata-joins", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install GPTomics/bioSkills bio-expression-matrix-metadata-joinsInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/GPTomics/bioSkills.git skills-src && mkdir -p .github/skills && cp -r skills-src/expression-matrix/metadata-joins .github/skills/bio-expression-matrix-metadata-joins && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "bio-expression-matrix-metadata-joins" agent skill from https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joins into .github/skills/bio-expression-matrix-metadata-joins/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "bio-expression-matrix-metadata-joins", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install GPTomics/bioSkills bio-expression-matrix-metadata-joins --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/GPTomics/bioSkills.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/expression-matrix/metadata-joins .opencode/skills/bio-expression-matrix-metadata-joins && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "bio-expression-matrix-metadata-joins" agent skill from https://github.com/GPTomics/bioSkills/tree/main/expression-matrix/metadata-joins into .opencode/skills/bio-expression-matrix-metadata-joins/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "bio-expression-matrix-metadata-joins", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
bio-expression-matrix-metadata-joinsAligns sample metadata with count matrices and constructs design matrices for downstream DE, handling the alphabetical-reference-level trap (relevel BEFORE DESeq), LRT reduced-model rules, the…
Bio Expression Matrix Metadata Joins is an agent skill from GPTomics/bioSkills. Aligns sample metadata with count matrices and constructs design matrices for downstream DE, handling the alphabetical-reference-level trap (relevel BEFORE DESeq), LRT reduced-model rules, the interaction-term resultsNames trap, continuous-covariate scaling and splines, repeated measures via duplicateCorrelation or dream, high-cardinality categorical pseudo-singular designs, sample swap detection via XIST/RPS4Y1 expression and somalier/NGSCheckMate genotypes, SABV (sex-as-biological-variable) mandate…
Its SKILL.md is about 6.4k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files (for example `examples/join_metadata.py` and `usage-guide.md`).
It sits in Research & Science. The repository describes itself as: a set of SKILLS.md for doing bioinformatics with agents like claude code. The licence is MIT.
Read from SKILL.md and the folder at commit d91ed3d. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Ships script files (Python), which the agent can run.
Shell commands in SKILL.md call:
pipFrom the folder's file list and the shell code blocks in SKILL.md.
No URLs in SKILL.md. Its commands use pip, which can reach the network depending on how they are called.
From URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
Bio Expression Matrix Metadata Joins loads about 6.4k tokens when it runs. Until then it costs about 219 tokens; SKILL.md has 2,312 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check found no risky patterns in SKILL.md.
Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from GPTomics/bioSkills at commit d91ed3d, republished under its MIT licence (© GPTomics). 2,312 words, ~6,376 tokens.
.claude/skills/bio-expression-matrix-metadata-joins/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.Reference examples tested with: pandas 2.2+, DESeq2 1.42+, edgeR 4.0+, limma 3.58+, variancePartition / dream 1.32+, somalier 0.2.18+ (CLI), pyensembl 2.3+, anndata 0.10+
Before using code patterns, verify installed versions match. If versions differ:
packageVersion('<pkg>') then ?function_name to verify parameterspip show <package> then help(module.function) to check signatures<tool> --version then <tool> --help to confirm flagsIf code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
"Align my sample metadata with my count matrix and build a design" -> Reconcile sample identifiers, validate the join, set factor levels explicitly to control fold-change direction, encode the experimental structure (paired, repeated measures, interaction) in the design formula, and detect swaps before downstream DE.
DESeq2 picks the reference level alphabetically if not told otherwise. With condition = c('Treated', 'Untreated'), T < U, so Treated becomes the reference. The reported log2FoldChange is then Untreated vs Treated -- the opposite of what the methods section says. No error; the volcano plot looks plausible; the gene list is correct but with reversed sign.
dds$condition <- relevel(dds$condition, ref = 'Untreated')
coldata$condition <- factor(coldata$condition, levels = c('Untreated', 'Treated'))Set BEFORE DESeq(); relevel-then-DESeq again to take effect.
A second insight: in interaction designs ~ genotype * treatment, results(dds, name='treatment_drug_vs_vehicle') returns the drug effect IN THE WT REFERENCE only, not the marginal/average effect. The interaction coefficient genotypeKO.treatmentdrug is the DIFFERENCE in drug effect between KO and WT (the difference of differences), NOT the drug effect in KO. The cleanest fix is to use ~ 0 + group with group = paste(genotype, treatment, sep='_') so every comparison of interest is a single contrast.
| Pattern | Encoding | Tests | Caveat |
|---|---|---|---|
| Simple two-group | ~ condition | results(name='condition_treated_vs_control') | Set reference level explicitly |
| With known batch | ~ batch + condition | results(name='condition_...') | Variable of interest LAST is the convention; not required |
| Paired (pre/post per subject) | ~ subject + condition | results(name='condition_...') | Pairing FIRST; subject absorbs baseline variability |
| Repeated measures (>2 time per subject) | DREAM `~ condition + (1 | subject)` | topTable(coef='condition') |
| Interaction (2x2) | ~ A * B (expands to A + B + A:B) | results(name='A.B') for diff-in-diff; combined factor for cleaner contrasts | resultsNames trap |
| Multi-group all pairwise | ~ 0 + group + makeContrasts | Contrasts named directly | DESeq2 needs intercept; works for edgeR/limma |
| Multi-level "any change" | LRT reduced = ~ 1 | results(dds) from LRT fit | padj is omnibus; LFC is one specific level |
| Scenario | Recommended approach |
|---|---|
| Tumor / normal paired by patient | ~ patient + tissue; pairing FIRST -- absorbs subject variability |
| Pre / post drug, same patient (2 time points) | ~ subject + condition |
| Longitudinal, 4+ time points per subject | DREAM mixed model with (1 | subject) random effect |
| Known batch (sequencing run, library prep date) | ~ batch + condition; do NOT subtract |
| Many batches (>10 levels, n=20-40) | ~ condition + (1 | batch) via DREAM; or aggregate batches |
| Continuous covariate (age, RIN) | Center first; include linearly OR via ns(x, df=3) if non-linear |
| Mixed-sex cohort | Include sex unless sex-specific; report sex-stratified sensitivity |
| Multi-group, want pairwise contrasts | ~ 0 + group + makeContrasts |
| Interaction question (does effect of A differ across B?) | Either ~ A * B (handle resultsNames trap) or combined factor ~ 0 + group |
| Many technical reps within bio reps | duplicateCorrelation (limma) OR aggregate via collapseReplicates (DESeq2) |
| Cohort >=20 samples | Run somalier or NGSCheckMate genotype check at the matrix-build step |
Goal: Align count matrix columns with metadata rows; remove samples present in only one source; verify alignment before downstream use.
Approach: Intersect sample identifiers; reorder both data sources; assert match.
import pandas as pd
counts = pd.read_csv('counts.tsv', sep='\t', index_col=0)
metadata = pd.read_csv('metadata.csv', index_col=0)
common = counts.columns.intersection(metadata.index)
only_counts = set(counts.columns) - set(metadata.index)
only_meta = set(metadata.index) - set(counts.columns)
if only_counts: print(f'In counts not metadata: {only_counts}')
if only_meta: print(f'In metadata not counts: {only_meta}')
counts = counts[common]
metadata = metadata.loc[common]
assert all(counts.columns == metadata.index)common <- intersect(colnames(counts), rownames(coldata))
counts <- counts[, common]
coldata <- coldata[common, , drop = FALSE]
stopifnot(all(colnames(counts) == rownames(coldata)))When sample names differ by formatting (underscore vs dash, BAM suffix, case), try systematic transformations -- replace _ <-> -, strip .bam, lower-case, take prefix before _ -- before giving up.
Goal: Pick the baseline against which fold changes are reported, controlling sign direction.
Approach: relevel() or construct the factor with explicit levels=. Set BEFORE DESeq() runs.
coldata$condition <- factor(coldata$condition, levels = c('control', 'treated'))
coldata$condition <- relevel(coldata$condition, ref = 'control')metadata['condition'] = pd.Categorical(metadata['condition'],
categories=['control', 'treated'],
ordered=True)With factor levels explicit, the LFC reads treated / control -- treated up means LFC > 0.
A reminder for edgeR / limma users: makeContrasts(Treated - Control) is explicit and immune to the reference-level trap. Same caution applies less because the user names the contrast.
design = ~ patient + tissuePairing variable FIRST (convention). Patient absorbs inter-subject baseline variability, dramatically increasing power for the tissue effect.
For DESeq2:
dds <- DESeqDataSetFromMatrix(counts, coldata, design = ~ patient + tissue)
dds <- DESeq(dds)
res <- results(dds, name = 'tissue_tumor_vs_normal')For edgeR:
design <- model.matrix(~ patient + tissue, coldata)
y <- estimateDisp(y, design, robust = TRUE)
fit <- glmQLFit(y, design, robust = TRUE)
qlf <- glmQLFTest(fit, coef = 'tissuetumor')Common mistake: writing ~ tissue + patient. Numerically the model is the same; the convention of pairing-first improves readability and matches the natural mental model.
design = ~ genotype + treatment + genotype:treatment
dds <- DESeqDataSetFromMatrix(counts, coldata, design = design)
dds <- DESeq(dds)
resultsNames(dds)Output names (after relevel):
"Intercept"
"genotype_KO_vs_WT"
"treatment_drug_vs_vehicle"
"genotypeKO.treatmentdrug"| Question | Wrong answer | Right answer |
|---|---|---|
| Drug effect averaged over genotypes | results(name='treatment_drug_vs_vehicle') -- this is drug effect in WT only | Combined factor ~ 0 + group; or contrast that explicitly averages |
| Is drug effect different between genotypes? | n/a | results(name='genotypeKO.treatmentdrug') -- the interaction coefficient IS the difference of differences |
| Drug effect in KO | results(name='treatment_drug_vs_vehicle') -- WRONG, this is drug in WT | results(contrast=list(c('treatment_drug_vs_vehicle', 'genotypeKO.treatmentdrug'))) (sum of main + interaction) |
The cleaner alternative for designs with many contrasts of interest:
coldata$group <- factor(paste(coldata$genotype, coldata$treatment, sep = '_'))
dds <- DESeqDataSetFromMatrix(counts, coldata, design = ~ 0 + group)
dds <- DESeq(dds)
res_drug_in_ko <- results(dds, contrast = c('group', 'KO_drug', 'KO_vehicle'))
res_drug_in_wt <- results(dds, contrast = c('group', 'WT_drug', 'WT_vehicle'))
res_diff <- results(dds, contrast = list(c('groupKO_drug', 'groupWT_vehicle'),
c('groupKO_vehicle', 'groupWT_drug')))~ 0 + group parameterization is the long-standing edgeR / limma recommendation (Smyth and Robinson User's Guides) for any design with multiple pairwise contrasts of interest.
dds <- DESeq(dds, test = 'LRT', reduced = ~ batch)Reduced model drops the term being tested. With design = ~ batch + condition and reduced = ~ batch, the LRT tests condition. With interaction designs:
dds <- DESeq(dds, test = 'LRT', reduced = ~ genotype + treatment)(Tests the interaction.)
The reduced model must be NESTED in the full model (every term in reduced must appear in full).
| Encoding | Assumption | When |
|---|---|---|
Linear (+ age) | log-expression linear in age | Limited range, biologically linear |
Centered linear (+ I(age - mean(age))) | As linear, interpretable intercept | Standard for age-RIN-day covariates |
Natural spline (+ ns(age, df=3)) | Smooth nonlinear | Wide age range with non-monotonic effects |
Polynomial (+ poly(age, 2)) | Quadratic; orthogonal polynomials | Limited use; splines usually better |
coldata$age_c <- coldata$age - mean(coldata$age)
design = ~ age_c + RIN + condition
library(splines)
design = ~ ns(age, df = 3) + conditionDO NOT include library size as a covariate -- it is handled by size factors / normalization factors internally.
Goal: Correctly model within-subject correlation when the same subject contributes multiple samples.
Approach: For technical reps within bio reps OR paired pre/post: duplicateCorrelation (limma) is adequate. For >2 time points per subject or random slopes: DREAM (variancePartition).
library(limma)
library(edgeR)
v <- voom(y, design)
corfit <- duplicateCorrelation(v, design, block = coldata$donor)
v <- voom(y, design, block = coldata$donor, correlation = corfit$consensus)
corfit <- duplicateCorrelation(v, design, block = coldata$donor)
fit <- lmFit(v, design, block = coldata$donor, correlation = corfit$consensus)
fit <- eBayes(fit, robust = TRUE)The double pass is intentional: estimate correlation, re-voom with correlation, re-estimate, fit. Limma's duplicateCorrelation assumes ONE within-subject correlation across all genes -- approximation.
For proper per-gene mixed models:
library(variancePartition)
form <- ~ condition + (1 | donor)
vobj <- voomWithDreamWeights(y, form, coldata)
fitmm <- dream(vobj, form, coldata)
fitmm <- eBayes(fitmm)
tt <- topTable(fitmm, coef = 'condition')See differential-expression/timeseries-de for full longitudinal designs.
Before committing to a design, variancePartition::fitExtractVarPartModel(vobj, form, coldata) quantifies the fraction of expression variance explained by each covariate, gene-by-gene. If a candidate "nuisance" covariate explains <1% of variance across most genes, it can usually be dropped; if a known biological factor explains <5% and isn't of direct interest, model it as a random effect rather than fixed.
Goal: Detect mislabeled samples by checking that gene-expression sex matches reported sex.
Approach: Compare XIST expression (high in XX, low/absent in XY) against chrY-gene expression (DDX3Y, RPS4Y1, UTY, KDM5D, EIF1AY -- high in XY, absent in XX).
import pandas as pd
def sex_check(counts, metadata, sex_column='sex'):
y_genes = ['DDX3Y', 'RPS4Y1', 'UTY', 'KDM5D', 'EIF1AY']
y_avail = [g for g in y_genes if g in counts.index]
if 'XIST' not in counts.index or not y_avail:
return None
predicted = pd.Series('unknown', index=counts.columns)
predicted[counts.loc[y_avail].sum() > counts.loc['XIST']] = 'M'
predicted[counts.loc['XIST'] > counts.loc[y_avail].sum()] = 'F'
if sex_column in metadata.columns:
mis = predicted != metadata[sex_column]
if mis.any():
print(f'SEX MISMATCHES: {list(metadata.index[mis])}')
return predictedsex_check <- function(counts, coldata, sex_col = 'sex') {
y_genes <- c('DDX3Y', 'RPS4Y1', 'UTY', 'KDM5D', 'EIF1AY')
y_expr <- colSums(counts[intersect(y_genes, rownames(counts)), , drop = FALSE])
predicted <- ifelse(y_expr > counts['XIST', ], 'M', 'F')
mis <- predicted != coldata[[sex_col]]
if (any(mis)) cat('Sex mismatches:', colnames(counts)[mis], '\n')
predicted
}CAVEAT: tumors with X loss, sex chromosome aneuploidies, HeLa (XXX with mixed inactivation) muddy this. Genotype-based methods are more robust.
somalier extract -d extracted/ --sites sites.GRCh38.vcf.gz \
-f reference.fa sample.bam
somalier relate --infer extracted/*.somalierncm_fastq.py -l fastq_list.txt -O outdir -bed common_sites.bedSomalier (Pedersen et al. 2020 Genome Med 12:62) extracts a few thousand SNP sketches per sample (sub-second per sample) and computes pairwise relatedness from BAM/CRAM/VCF. NGSCheckMate (Lee et al. 2017 NAR 45:e103) computes VAF correlation across a common-SNP panel; works on FASTQ/BAM/VCF including RNA-seq.
For any cohort >=20 samples, run one of these at the matrix-build step. Catching a swap in raw data is cheap; finding it after DE is expensive.
NIH 2016+ requires sex consideration in vertebrate animal and human studies. Mauvais-Jarvis F et al. 2020 Lancet 396:565 reviews effect-size differences across diseases.
Practical implication:
~ sex + condition rarely hurts and captures real biology.Goal: Aggregate technical replicates from the same subject correctly; never treat them as independent biological replicates.
Approach: Sum (not average) technical replicates of the same subject BEFORE downstream DE.
library(DESeq2)
dds_collapsed <- collapseReplicates(dds, groupby = dds$subject)counts_per_subject = counts.T.groupby(metadata['subject']).sum().T
metadata_per_subject = metadata.drop_duplicates(subset='subject').set_index('subject')Why sum and not average? Reads add. Two technical replicates yielding 1M reads each are equivalent to one library yielding 2M reads. Averaging would understate the effective library size.
Treating technical replicates as independent biological samples is the cardinal sin: it inflates the apparent sample size and deflates standard errors. With 4 patients x 3 tech reps = 12 samples, naive DE assumes 12 independent observations; the truth is closer to 4. p-values are compressed ~3x.
Goal: Handle batch / lane / well covariates with many levels without making the design matrix singular.
Approach: Aggregate to fewer levels, model as random effect via DREAM, or drop if confounded.
ct <- table(coldata$condition, coldata$batch)
ct
ad <- alias(model.matrix(~ batch + condition, coldata))
ad$CompleteFor a batch with 30 levels in n=40 samples: 30 batch coefficients + condition + intercept = 32 parameters for 40 observations. Symptoms: Matrix not positive definite (DESeq2), degenerate p-values (limma).
Fixes:
~ condition + (1 | batch) via DREAM borrows information across batch levels via shrinkage.alias() reveals collinearity).design_default <- model.matrix(~ group, coldata)
# columns: (Intercept), groupB, groupC -- A is reference
design_nointercept <- model.matrix(~ 0 + group, coldata)
# columns: groupA, groupB, groupC -- each column is mean of that groupWith ~ 0 + group, every contrast reads as B - A:
library(limma)
con <- makeContrasts(BvsA = groupB - groupA,
CvsA = groupC - groupA,
BvsC = groupB - groupC,
levels = design_nointercept)
fit <- glmQLFit(y, design_nointercept, robust = TRUE)
qlf <- glmQLFTest(fit, contrast = con[, 'BvsA'])DESeq2 needs an intercept internally, so ~ 0 + group works directly with edgeR/limma but DESeq2 uses contrast= to achieve the same effect.
dds <- DESeqDataSetFromMatrix(as.matrix(counts), coldata, design = ~ batch + condition)
y <- DGEList(counts = as.matrix(counts), group = coldata$condition)
y$samples <- cbind(y$samples, coldata)
adata <- ad.AnnData(X = t(as.matrix(counts)), obs = coldata, var = data.frame(row.names = rownames(counts)))AnnData convention is cells (samples) in rows -- transpose from the typical R genes-in-rows convention.
Trigger: Methods says "treated vs control"; published volcano shows expected up-genes on the LEFT.
Mechanism: Factor levels left at alphabetical default; c('Treated','Untreated') -> T < U -> Treated is reference -> LFC is Untreated/Treated.
Symptom: Known up-regulated genes appear down; reviewer questions direction.
Fix: relevel(coldata$condition, ref = 'Untreated') BEFORE DESeq(). Re-run.
Trigger: ~ A * B design; results(name='B_drug_vs_vehicle') reported as "drug effect"; reviewer asks about genotype-specific effect.
Mechanism: With interaction, B_drug_vs_vehicle is drug effect IN THE A REFERENCE LEVEL only, not averaged across A.
Symptom: Drug effect doesn't match the marginal estimate from a separate ~ B-only fit.
Fix: Use ~ 0 + group with combined factor; OR extract per-stratum results explicitly using contrasts that sum main + interaction.
Trigger: 3 subjects x 4 conditions = 12 samples; vanilla DESeq2 with ~ condition; many DE genes.
Mechanism: Same subject contributes multiple observations; not independent. Effective sample size for testing condition is ~3, not 12.
Symptom: p-value histogram anti-conservative; replication low.
Fix: Include subject in design (~ subject + condition) OR use DREAM with random subject.
Trigger: PCA shows "control" sample clustering with treated; investigation reveals it was mislabeled at thaw.
Mechanism: Manual sample tracking is error-prone; cohort >=20 inevitably has swaps.
Symptom: One sample dramatically off its group cluster; DE gene list dominated by sample-specific effects.
Fix: Run somalier or NGSCheckMate at the matrix-build step, BEFORE DE. Catching a swap early is cheap; finding it post-DE is expensive.
Trigger: Mixed-sex cohort; sex not in design; PCA shows clear sex split on PC1.
Mechanism: Sex distribution differs between groups; "treatment effect" partially captures sex.
Symptom: Top DE genes are DDX3Y, RPS4Y1, UTY (chrY) and XIST -- not biology of interest.
Fix: Add sex to design (~ sex + condition). For sex-specific analyses, stratify and report each separately.
Trigger: limma user wrote a one-pass duplicateCorrelation + lmFit; QC reviewer asks why no re-voom.
Mechanism: The proper pattern is: voom -> dupCor -> re-voom WITH correlation -> dupCor again -> lmFit. The first voom doesn't know about block structure; re-voom with correlation gets better weights.
Symptom: Slightly inflated DE counts vs the two-pass pattern.
Fix: Implement the two-pass pattern per the limma User's Guide (section 9.7).
| Error / symptom | Cause | Fix |
|---|---|---|
| Sample names don't match between counts and metadata | Underscore/dash inconsistency, BAM suffix, case | fuzzy_match_samples() or manual normalization; report what failed |
| DESeq2 design not full rank | Confounded covariates | alias(design)$Complete to identify; aggregate or drop |
Matrix not positive definite | High-cardinality batch with few samples | Aggregate batches or use random effect via DREAM |
| LFC direction reversed | Alphabetical reference level | relevel() before DESeq() |
results(name='...') returns drug effect in WT only | Interaction design and naming trap | Use combined factor ~ 0 + group; or contrast summing main + interaction |
| Inflated DE list with 12 samples from 3 subjects | Pseudoreplication | Include subject; or use DREAM |
| Sex effect appears as treatment effect | Sex not in design | Add ~ sex + condition |
| Sample distance heatmap shows mixing groups | Likely swap | Run somalier or NGSCheckMate |
© GPTomics, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 2 other files in expression-matrix/metadata-joins of GPTomics/bioSkills.
Open the folder on GitHubat commit d91ed3d
We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in GPTomics/bioSkills, which our catalogue first saw on October 7, 2026.
Bio Expression Matrix Metadata Joins next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| Bio Expression Matrix Metadata Joins this skillGPTomics/bioSkills | 1.2k | 1 repos | ~6.4k | Automated safety check: Pass | MIT | |
| Hypothesis Generationspacering-net/codeg | 3.9k | 14 repos | ~3.6k | Automated safety check: Notes | MIT | |
| GitHub Deep Researchbytedance/deer-flow | 84k | 4 repos | ~1.3k | Automated safety check: Pass | MIT | |
| Nature Paper CardYuan1z0825/nature-skills | 47k | 2 repos | ~2.1k | Automated safety check: Pass | Apache-2.0 | |
| Content Research Writerweapp-tailwindcss/weapp-tailwindcss | 1.9k | 25 repos | ~3.5k | Automated safety check: Pass | MIT | |
| Last30daysmvanhorn/last30days-skill | 64k | — | ~7.9k | Automated safety check: Notes | MIT |
spacering-net/codeg
Structured hypothesis formulation from observations. An agent skill from spacering-net/codeg.
bytedance/deer-flow
Researches a GitHub repository over four rounds using the GitHub API and web search, then writes a structured markdown report with timeline, metrics and Mermaid diagrams.
Yuan1z0825/nature-skills
Builds a structured deep-reading card for one scientific paper, covering methods, how experiments support claims, limitations and research ideas, with a script to prepare the source.
weapp-tailwindcss/weapp-tailwindcss
Assists in writing high-quality content by conducting research, adding citations, improving hooks, iterating on outlines, and providing real-time feedback on each section.
mvanhorn/last30days-skill
Research what people actually say about any topic in the last 30 days.
spacering-net/codeg
Structured manuscript/grant review with checklist-based evaluation.
GPTomics/bioSkills
Read, write, and convert multiple sequence alignment files using Biopython Bio.AlignIO.
GPTomics/bioSkills
Installs the bioSkills collection of 425 bioinformatics skills in one step, or only chosen categories, so sequencing, RNA-seq, single-cell and variant tasks get specialized help.
GPTomics/bioSkills
Write biological sequences to files (FASTA, FASTQ, GenBank, EMBL) using Biopython Bio.SeqIO.
GPTomics/bioSkills
Soft- or hard-clips PCR primer footprints from aligned amplicon BAMs so primer bases stop masquerading as confirmed reference sequence.
GPTomics/bioSkills
Filters BAM alignments by FLAG bits, mapping quality and regions with samtools view or pysam, with recipes for common keep and drop cases.
GPTomics/bioSkills
Create and use BAI/CSI indices for BAM/CRAM files using samtools and pysam.
Categories
Aligns sample metadata with count matrices and constructs design matrices for downstream DE, handling the alphabetical-reference-level trap (relevel BEFORE DESeq), LRT reduced-model rules, the…. Bio Expression Matrix Metadata Joins is an agent skill from GPTomics/bioSkills.
Bio Expression Matrix Metadata Joins fits situations like: building a design matrix; troubleshooting reversed fold-change direction; encoding paired; repeated-measures designs.
Run `npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a claude-code`. Or copy the skill folder (expression-matrix/metadata-joins in GPTomics/bioSkills) into .claude/skills/bio-expression-matrix-metadata-joins in your project. Claude Code loads it when a task matches its description.
Run `npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a codex`. Or copy the skill folder (expression-matrix/metadata-joins in GPTomics/bioSkills) into .agents/skills/bio-expression-matrix-metadata-joins in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add GPTomics/bioSkills --skill bio-expression-matrix-metadata-joins -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/bio-expression-matrix-metadata-joins, .gemini/skills/bio-expression-matrix-metadata-joins, .github/skills/bio-expression-matrix-metadata-joins and .opencode/skills/bio-expression-matrix-metadata-joins in your project.
Going by SKILL.md and its folder, Bio Expression Matrix Metadata Joins needs Python for the scripts in its folder and the command-line tools its instructions call (pip). Our summary lists: Python 3.
SKILL.md contains no URLs. Its commands use pip, which can reach the network depending on how they are called. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.
Bio Expression Matrix Metadata Joins is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 6.4k tokens (SKILL.md is roughly 26k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with Bio Expression Matrix Metadata Joins: Hypothesis Generation (spacering-net/codeg, 3.9k stars), GitHub Deep Research (bytedance/deer-flow, 84k stars), Nature Paper Card (Yuan1z0825/nature-skills, 47k stars) and Content Research Writer (weapp-tailwindcss/weapp-tailwindcss, 1.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
GPTomics (a GitHub organization) maintains it in GPTomics/bioSkills, which has 1,218 GitHub stars. The repository holds 559 skills in this directory. The repository was last updated on August 15, 2026.
Source: GPTomics/bioSkills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.