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
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).Problem solved!!! Thank you both for the help!!!