Skip to content

Add configurable DESeq2 design formula - #20

Open
rmillikin wants to merge 1 commit into
mainfrom
claude/deseq2-custom-design-uxo398
Open

Add configurable DESeq2 design formula#20
rmillikin wants to merge 1 commit into
mainfrom
claude/deseq2-custom-design-uxo398

Conversation

@rmillikin

Copy link
Copy Markdown
Contributor

DESeq2 was hard-coded to ~ condition. The design formula is now set in the config YAML via design_formula and defaults to ~ condition.

DESeq2 was hard-coded to `~ condition`, so within-subject (paired) designs
and batch-corrected designs weren't expressible. The design formula is now
set in the config YAML via `design_formula` and defaults to `~ condition`,
so existing configs are unaffected.

Validation happens twice: the Snakefile checks the formula against the
design CSV header when the workflow is parsed, so a formula naming a column
that doesn't exist (e.g. `~ subject + condition` with no `subject` column)
fails before any step runs rather than hours later; deseq2.R repeats the
check so the script is safe to run standalone. The formula must also include
`condition`, since contrasts are tested on its coefficients.

Every variable in the formula is coerced to a factor, so a numeric subject
or batch ID is read as a group label rather than a continuous covariate,
and a blank value or a single-level variable is reported by name instead of
surfacing as a rank-deficient model matrix.

The formula is a restricted character set (variable names and R formula
operators only), which also keeps it safe to interpolate into the rules'
shell commands.

Also threads the formula into the generated methods paragraph, which
previously claimed a `~condition` design unconditionally.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VcESmVRNhqwhuw8psAzvkr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants