Question: DESeq2 contrast cleaning problem
gravatar for
3.5 years ago by
john.hu0 wrote:

I am testing DESeq2 1.10.1 version and find some issue with cleanContrast function.

I use a standard 2x2  A*B design with interaction terms. 

DESeqDataSetFromMatrix(countData = round(datacounts), colData = designtable, design = ~ Gender*Site)

dds<- DESeq(dds, modelMatrixType="standard")

output <- results(dds, independentFiltering=T, contrast=c(0, 0, 1, 0))


When I extract the contrast results to get the site M vs site K when gender is Female with the contrast vector, I found that some of the all zero contrasts are not properly filtered.  I debug the code using RStudio and find that in CleanContrast function , when a numeric contrast vector is used, contrastAllZero <- contrastAllZeroNumeric(object, contrast) is called. If I get the logic right, this function is used to detect genes whose counts for samples used in contrasts are all zero. However, after checking the source code of contrastAllZeroNumeric, it will do nothing for my contrast vector above. 

### in contrastAllZeroNumeric function ###

if (all(contrast >= 0) | all(contrast <= 0)) {
        return(rep(FALSE, nrow(object)))

I kind of feel this is a bug.


deseq2 bugs software error • 923 views
ADD COMMENTlink modified 3.5 years ago by Michael Love24k • written 3.5 years ago by john.hu0
Answer: DESeq2 contrast cleaning problem
gravatar for Michael Love
3.5 years ago by
Michael Love24k
United States
Michael Love24k wrote:

hi John,

Thanks for the report. The extra leg work in DESeq2 to zero out the log2FoldChange, lfcSE, and set the p-value to 1 only is implemented for simple multi-factor designs and not for designs with interactions. This was a feature request from a user a year or so ago, who had an experiment with size factors differing by more than an order of magnitude and confounded with group (this is problematic for many reasons). Here, comparing a group with all zeros against another group with all zeros gives a paradoxical non-zero LFC. You can observe the same with glm() and providing a non-zero offset. So it's not really a bug, but I knowingly only implemented this for the simpler designs. I will add some comments in the code to state this explicitly.

ADD COMMENTlink written 3.5 years ago by Michael Love24k

I should add, it works under the default DESeq() use of expanded model matrices, but not for standard model matrices.

ADD REPLYlink written 3.5 years ago by Michael Love24k

Yeah, I think this function is written for expanded matrix only. For standard matrix, the filter works file when a contrast is specified in text as contrast=c("Term", "A", "B") 

It makes biological sense to reset the log2fc and p-values for RNA-Seq data when all samples in the contrast have zero counts. Probably should extend this to complex models as well.


ADD REPLYlink modified 3.5 years ago • written 3.5 years ago by john.hu0
Thanks again for your report and suggestion. For standard design matrices and numeric contrasts, I think we will continue to provide the standard LFC, not zeroed out. You can use the character vector to enable the zeroing feature.
ADD REPLYlink written 3.5 years ago by Michael Love24k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 279 users visited in the last hour