DESeq2 contrast using list
1
2
Entering edit mode
zhuozhu132 ▴ 20
@zhuozhu132-14097
Last seen 6.5 years ago

Hi!!

I'm having trouble to do a contrast using DESeq2. I have 12 samples, AA(2 replicates), AB(4 replicates), BA(4 replicates) and BB(2 replicates). I wanted to compare AB (or BA) with the mean of AA and BB, so I found out that I should do this from another post:

res <- results(dds, contrast=list("conditionAB", c("conditionAA", "conditionBB"), listValues=c(1, -1/2))

But I couldn't get it work. The error says conditionAA, conditionBB etc are not in resultNames().

Here is my code:

countData <- read.csv(file = dataFile, header = TRUE,  row.names=1)
colData <- DataFrame(row.names=colnames(countData), condition=factor(c(rep("AA",2), rep("AB",4), rep("BA",4), rep("AA",2))))

dds <- DESeqDataSetFromMatrix(countData = countData,

                                colData = colData,
                                design = ~condition)
 

dds <- DESeq(dds)

res <- results(dds, contrast=list("conditionAB", c("conditionAA", "conditionBB"), listValues=c(1, -1/2))

When I check resultsNames(dds), I got those:

[1] "Intercept"          "condition_AB_vs_AA" "condition_BA_vs_AA" "condition_BB_vs_AA"

I would like to have "conditionAA", "conditionBB" etc. in the resultsNames() output, so I can make the contrast I mentioned. I have been reading on this website for hours but couldn't find the solution. Any suggestions would be highly appreciated!

Thank you!

-Zhu

deseq2 • 3.6k views
ADD COMMENT
3
Entering edit mode
Gavin Kelly ▴ 680
@gavin-kelly-6944
Last seen 4.0 years ago
United Kingdom / London / Francis Crick…

You can have design = ~condition-1 to remove the intercept terms, or you can alter the formulation of the contrast using the existing names by using the fact that Intercept is really conditionAA, and so conditionBB is Intercept+conditionBB_vs_AA etc, and doing the algebra to get your numerators and denominators in terms of the existing resultsNames.  I get contrast=list("condition_AB_vs_AA", "condition_BB_vs_AA") with listVars=c(1,-1/2), but you might want to double-check that!

ADD COMMENT
1
Entering edit mode

Gavin is right on both. I get the same contrast using existing terms, but it's probably easier for you, and more future proof (you will recognize what you did if you look back at the code in a year), if you use design=~0+condition or equivalently ~condition-1 (both remove the intercept term).

ADD REPLY
0
Entering edit mode

Problem solved!!! Thank you both for the help!!!

ADD REPLY

Login before adding your answer.

Traffic: 732 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