differentialabundance icon indicating copy to clipboard operation
differentialabundance copied to clipboard

Contrast specification

Open grst opened this issue 1 year ago • 0 comments

Description of feature

In #362 we suggested to support more complex models and contrasts. This issue is to explore and find a consens on how to define contrasts for a given model.

Types of contrasts

While trying to be as consistent as possible between methods, different methods support different tests and might require different contrast definitions. I envisage we have a set of contrast types and each method can support one or multiple contrast types. Below I provide an overview of the suggested contrast types and how I envisage they could be specified in yaml format.

We don't need to support all of them initially, but we should design the pipeline in a way it can be easily extended to more contrast types in the future.

Complex contrasts based on coefficients

Most linear-model based methods should support definition of contrasts based on comparison of linear model coefficients. There are different mini "domain specific languages" (DSL) to specify contrasts based on variable names that all ultimately resolve into a numeric contrast vector that aligns with the linear model design matrix. Choosing the right one is a topic for itself, so I'll open a separate issue. Still, I'd imagine the contrast definition to look somewhat like

contrasts:
 - id: interaction_treatment_response
   type: complex # or `makeContrasts`, `cond`, ... depending on the method used to build contrasts (??)
   comparison: (treatmentA_responders - treatmentA_nonresponders) - (treatmentB_responders - treatmentB_nonresponders)

--> See #386 for complex contrasts specification

Simple pairwise comparison

This is a special case of the complex contrasts. It is mostly for convenience (one doesn't need to understand design matrices to define a "simple" contrast). Also there could be methods added that do not support complex contrasts.

contrasts:
 - id: a_vs_b
   type: pairwise # or 'simple' ? 
   comparison: ["treatment", "A", "B"] # variable, baseline, target

or alternatively a bit more verbose

 contrasts:
 - id: a_vs_b
   variable: treatment
   baseline: A
   target: B

Full and reduced model

DESeq2 implements a liklihood ratio test (LRT) where two models are compared to each other.

contrasts:
 - id: check_treatment_effect
   type: full_vs_reduced
   full: "~treatment + response"
   reduced: "~ response"

ANOVA

ANOVA is a special case of the liklihood ratio test. Supported by propd (see https://github.com/nf-core/differentialabundance/issues/362#issuecomment-2517282602) and by DESeq2 via LRT.

contrasts:
 - id: check_treatment_effect
   type: anova
   variable: treatment

CC @apeltzer @tschwarzl @atrigila @alanmmobbs93 @nschcolnicov @suzannejin

grst avatar Dec 06 '24 07:12 grst