scverse / scverse/PyDESeq2

Add instructions on setting a reference level with `formulaic`

Open
#362 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Python
Stars
761
Forks
90
Avg merge
25m
Merged PRs (30d)
10

Description

Is your feature request related to a problem? Please describe.

With the switch to formulaic designs in v0.5.0, the ref_level argument of DeseqDataSet was deprecated. As a result, we may encounter cases in which it is not possible to shrink a given LFC coefficient because it does not correspond to a column in the design matrix. C.f. #361.

Describe the solution you'd like

The reference level can actually be set using the following syntax: design = '~ C(condition, contr.treatment(base="B")).
As this requires some knowledge of formulaic's API, we should

  • Add an example in the tutorials
  • Update ref_level's deprecation message
  • Update lfc_shrink's docstring (and maybe raise a warning when lfc_shrink is called on a non-existant coefficient?)

Describe alternatives you've considered

It might be possible to update the columns of the design matrix without re-fitting dispersions. Something like

dds.design = '~ C(condition, contr.treatment(base="B"))
dds.formulaic_contrasts = FormulaicContrasts(dds.obs, dds.design)
dds.obsm["design_matrix"] = dds.formulaic_contrasts.design_matrix

And then run the pipeline step by step from dds.fit_LFC().

We could consider implementing a method to achieve this.

Additional context
C.f. the discussion in #361.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names the tutorials, DeseqDataSet's ref_level deprecation message, and lfc_shrink's docstring; start by reading those entry points and discussion #361. Confirm whether the intended contribution is documentation and messaging only or also the proposed design-matrix update, then verify the reference-level syntax and expected handling of missing coefficients.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.