Skip to content

Add instructions on setting a reference level with formulaic #362

@BorisMuzellec

Description

@BorisMuzellec

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions