Skip to content

Let tidy_deseq_results() extract a coefficient by name - #37

Open
jayhesselberth wants to merge 1 commit into
develfrom
deseq-results-name
Open

Let tidy_deseq_results() extract a coefficient by name#37
jayhesselberth wants to merge 1 commit into
develfrom
deseq-results-name

Conversation

@jayhesselberth

Copy link
Copy Markdown
Member

tidy_deseq_results() accepts only a contrast, which compares two levels of one factor. That cannot address an interaction coefficient, so any model with an interaction term is unreachable through this function.

Differential charging is the case that hits it. In a design like

~ genotype + charge_status + genotype:charge_status

the interaction coefficient is exactly what separates this tRNA is more charged from this tRNA is more abundant — the genotype main effect answers the second question, not the first. No contrast specification refers to that coefficient, so callers had to drop to DESeq2::results(dds, name = ...) and rebuild the tibble by hand, losing the ref/significant columns the rest of the package expects.

Change

Adds a name argument that passes through to DESeq2. It is validated against DESeq2::resultsNames(), so a typo reports the available coefficients rather than failing somewhere inside DESeq2:

dds <- run_deseq(chg_mat, coldata, ~ prep + genotype + charge_status + genotype:charge_status)
tidy_deseq_results(dds, name = "genotypeMUT.charge_statuscharged")

Exactly one of contrast or name is required. contrast keeps its position and gains a default, so existing positional and named calls are unaffected.

Testing

533 tests pass, 8 pre-existing skips for uninstalled optional packages. Four new tests cover extraction by name, agreement with the equivalent contrast for a two-level factor, reaching an interaction coefficient in a charged/uncharged design, and the two error paths.

Found while building a differential charging analysis on aa-tRNA-seq-pipeline output, where this was the one step that had to bypass clover.

🤖 Generated with Claude Code

A contrast compares two levels of one factor, so it cannot address an
interaction coefficient. That makes differential charging unreachable
through this function: in a design like

    ~ genotype + charge_status + genotype:charge_status

the interaction term is exactly what separates "this tRNA is more
charged" from "this tRNA is more abundant", and no contrast refers to it.
Callers had to drop to DESeq2::results() and rebuild the tibble by hand.

Add a `name` argument that passes through to DESeq2, validated against
resultsNames() so a typo reports the available coefficients rather than
failing obscurely. Exactly one of contrast or name is required; contrast
keeps its position, so existing calls are unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

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.

1 participant