Question: DESeq2 contrast with list no longer works: all elements of the contrast as a list of length 2 should be elements of 'resultsNames(object)'
0
21 months ago by
sxv0
sxv0 wrote:

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:

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 • 925 views
modified 21 months ago by Michael Love25k • written 21 months ago by sxv0
Answer: DESeq2 contrast with list no longer works: all elements of the contrast as a lis
0
21 months ago by
Michael Love25k
United States
Michael Love25k wrote:

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.