DESeq2 contrast with list no longer works: all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'
1
0
Entering edit mode
sxv • 0
@sxv-14831
Last seen 4.7 years ago

Hi,

I am encountering an error which I cannot solve when attempting a contrast that references a list.

"dx" is a column in my design file and each sample row has a value of "dx1", "dx2", or "dx3" in this column.

"batch" is a column with three possible values "group1", "group2", "group3".

Now I want to run DESeq and then look for genes differentially expressed in "dx1" vs both other groups combined, then look in "dx2" vs the other two, etc. I am referencing the following examples:

  1. DESeq2: one condition vs multiple combined
  2. Using the "listValues" argument of DESEQ in multiple group comparisons

Here is the relevant code:

dds <- DESeqDataSetFromMatrix(countData = read_counts, colData = design.file, design = ~ batch + dx)

dds <- DESeq(dds, parallel=TRUE)

res1 <- results(dds, contrast = list( c("dx1"),c("dx2","dx3") ), listValues=c(1,-1/2) )

which produces this error:

Error in checkContrast(contrast, resNames) : 
  all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'

A look into resultsNames(dds) reveals this list:

[1] "Intercept"                   "batch_group2_vs_group1"      "batch_group3_vs_group1" "dx_dx2_vs_dx1"             
[5] "dx_dx3_vs_dx1"

Any idea what is the problem? Thanks in advance.

RStudio Version 1.1.414 ; R version 3.4.3 (2017-11-30) -- "Kite-Eating Tree"; Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/604.4.7 (KHTML, like Gecko)

deseq2 • 3.6k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 4 hours ago
United States

The easiest option is to set betaPrior=TRUE when you run DESeq(), which will give you the same behavior as before. 

The change is noted in the NEWS file as one of the changes in version 1.16.

Another option is to use DESeq() with it's default values, but a design of ~0 + dx + batch. Here the order matters, and it's different than the usual suggestion of putting the variable of interest at the end. The reason is that you specifically want all three levels of dx, but batch is just a nuisance. So putting dx after the 0 will give you three coefficients for the three levels of dx.

ADD COMMENT

Login before adding your answer.

Traffic: 599 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6