differentialabundance
differentialabundance copied to clipboard
With DESeq2, when using formula, can only use coefficient names, but not complex contrasts
Description of the bug
Currently, in the DESeq2 module, the "make_contrast_str" is passed via the name parameter to DESeq2::results
https://github.com/nf-core/differentialabundance/blob/ecfdc89c7ec3cf5404b430d11cc47eed5e8057a2/modules/nf-core/deseq2/differential/templates/deseq2_differential.R#L436-L438
This allows to use one individual coefficient as contrast, but doesnt' allow to build complex contrasts as it's currently implemented in the limma module, e.g.
formula: ~ 0 + BORC_simple
make_contrasts_str: "BORC_simplePD - BORC_simpleSD"
DESeq2 doesn't directly support this syntax, but it does support numeric contrasts via the results(..., contrasts = ...) argument.
limma::makeContrasts converts a contrasts string such as "BORC_simplePD - BORC_simpleSD" to a numeric contrast vector. Therefore, for consistency between the different method, and to support arbitrary contrasts with DESeq2, I suggest to also use limma::makeContrasts in the DESeq2 module when a contrasts string is provided and then pass the resulting numeric contrast vector to DESeq2.
Please note that, as in the limma module, this requires dealing with special characters in the design matrix colnames (-> call make.names).
Command used and terminal output
Relevant files
No response
System information
No response