You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
8
8
### Added
9
9
10
+
-[[#450](https://github.com/nf-core/differentialabundance/pull/441)] - Allow usage of strings for makeContrasts in DREAM. ([@atrigila](https://github.com/atrigila), review by [@pinin4fjords](https://github.com/pinin4fjords), [@suzannejin](https://github.com/suzannejin) and [@grst](https://github.com/grst)).
10
11
-[[#441](https://github.com/nf-core/differentialabundance/pull/441)] - Add dream differential module. ([@nschcolnicov](https://github.com/nschcolnicov) and [@alanmmobbs93](https://github.com/alanmobbs93), review by [@pinin4fjords](https://github.com/pinin4fjords), [@suzannejin](https://github.com/suzannejin) and [@grst](https://github.com/grst)).
11
12
-[[#440](https://github.com/nf-core/differentialabundance/pull/440)] - Add handling for formula based contrasts. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@pinin4fjords](https://github.com/pinin4fjords))
12
13
-[[#437](https://github.com/nf-core/differentialabundance/pull/437)] - Add nf-tests to deseq2/differential, rmarkdownnotebook, and proteus modules. ([@nschcolnicov](https://github.com/nschcolnicov), review by [@TODO](TODO)).
Copy file name to clipboardExpand all lines: docs/usage.md
+39-11Lines changed: 39 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -175,30 +175,58 @@ contrasts:
175
175
blocking_factors: ["replicate"]
176
176
```
177
177
178
-
Alternatively, the YAML contrasts also supports formula based model definitions:
178
+
The necessary fields in order are:
179
+
180
+
- `id` - an arbitrary identifier, will be used to name contrast-wise output files
181
+
- `comparison`(respectively):
182
+
- - `variable` - which column from the observations information will be used to define groups
183
+
- - `reference` - the base/ reference level for the comparison. If features have higher values in this group than target they will generate negative fold changes
184
+
- - `target` - the target/ non-reference level for the comparison. If features have higher values in this group than the reference they will generate positive fold changes
185
+
- `blocking_factors`- Any additional variables (also observation columns) that should be modelled alongside the contrast variable
186
+
- `exclude_samples_col`and `exclude_samples_values` - the former being a valid column in the samples sheet, the latter a list of values in that column which should be used to select samples prior to differential modelling. This is helpful where certain samples need to be excluded prior to analysis of a given contrast.
187
+
188
+
Alternatively, the YAML contrasts also supports formula based model definitions for tools such as `VARIANCEPARTITION_DREAM`:
179
189
180
190
```yaml
181
191
contrasts:
182
192
- id: condition_control_treated
183
193
formula: "~ condition"
184
-
comparison: ["condition", "control", "treated"]
194
+
make_contrasts_str: "conditiontreated"
185
195
- id: condition_control_treated_blockrep
186
196
formula: "~ condition + replicate"
187
-
comparison: ["condition", "control", "treated"]
197
+
make_contrasts_str: "conditiontreated"
188
198
```
189
199
190
200
The necessary fields in order are:
191
201
192
-
- `id` - an arbitrary identifier, will be used to name contrast-wise output files
193
-
- `comparison`(respectively):
194
-
- - `variable` - which column from the observations information will be used to define groups
195
-
- - `reference` - the base/ reference level for the comparison. If features have higher values in this group than target they will generate negative fold changes
196
-
- - `target` - the target/ non-reference level for the comparison. If features have higher values in this group than the reference they will generate positive fold changes
202
+
- `formula`- A string representation of the model formula. It is used to build the design matrix.
203
+
- `make_contrasts_str`- An explicit literal contrast string (e.g., "treatmenthND6 - treatmentmCherry") that is passed directly to [`limma::makeContrasts()`](https://rdrr.io/bioc/limma/man/makeContrasts.html) in `VARIANCEPARTITION_DREAM`. The parameter names must be syntactically valid variable names in R (see [`make.names`](https://stat.ethz.ch/R-manual/R-devel/library/base/html/make.names.html)). This field provides full control for complex designs. Requires `formula`.
197
204
198
-
You can optionally supply:
205
+
> [!WARNING]
206
+
> Formula-based contrasts are currently only supported by `VARIANCEPARTITION_DREAM`. They **do not work** with tools like `DESEQ2` or base `LIMMA` implementations yet.
199
207
200
-
- `blocking_factors`- Any additional variables (also observation columns) that should be modelled alongside the contrast variable
201
-
- `exclude_samples_col`and `exclude_samples_values` - the former being a valid column in the samples sheet, the latter a list of values in that column which should be used to select samples prior to differential modelling. This is helpful where certain samples need to be excluded prior to analysis of a given contrast.
208
+
> [!NOTE]
209
+
>
210
+
> #### Notes on `make_contrasts_str`
211
+
>
212
+
> This string must match exactly the name of the coefficient in the model matrix as generated by the specified `formula`. It is passed to `limma::makeContrasts()` without modification. For example:
213
+
>
214
+
> - `formula: "~ condition"` will generate model coefficients like `conditiontreated` (if `control` is the reference).
215
+
> - Then, `make_contrasts_str: "conditiontreated"` selects that coefficient for testing.
216
+
>
217
+
> This gives full control over the contrast definition but requires understanding of the model matrix.
218
+
219
+
Beyond the basic one-factor comparison, the YAML contrasts format supports advanced experimental designs through the use of interaction terms and custom contrast strings. These are particularly useful in multifactorial experiments where the effect of one variable may depend on the level of another (e.g. genotype × treatment). To model an interaction between genotype and treatment, use a formula like `~ genotype * treatment`, which expands the yaml to:
220
+
221
+
```yaml
222
+
contrasts:
223
+
- id: genotype_WT_KO_treatment_Control_Treated
224
+
formula: "~ genotype * treatment"
225
+
comparison: ["genotype", "WT", "KO"]
226
+
make_contrasts_str: "genotypeKO.treatmentTreated"
227
+
```
228
+
229
+
To facilitate constructing and validating such models and contrast strings, consider using the [`ExploreModelMatrix`](https://www.bioconductor.org/packages/release/bioc/html/ExploreModelMatrix.html) Shiny app to have visual inspection of the design matrix and interactive contrast building. Another helpful resource is the [guide to creating design matrices for gene expression experiments](https://bioconductor.org/packages/release/workflows/vignettes/RNAseq123/inst/doc/designmatrices.html).
0 commit comments