Deseq2 multifactor analysis
1
0
Entering edit mode
genomica • 0
@genomica-8869
Last seen 8.0 years ago
United Kingdom

Hello,

I have a RNAseq experiment where I have 2 conditions and 3 replicates each and replicates are taken from different individuals. So my design is as follows:

Sample Condition Individual
S1 treated A
S2 untreated A
S3 treated B
S4 untreated B
S5 treated C
S6 untreated C 

Here is my code to analyse the data using deseq2:

library('DESeq2')
directory<-"counts"
sampleFilesN1_N2 <- grep("*N[1-2]",list.files(directory),value=TRUE)
sampleConditionN1_N2<-c("treated","untreated","treated","untreated","treated","untreated")
sampleIndividual<-c("A","A","B","B","C","C")
sampleTable1<-data.frame(sampleName=sampleFilesN1_N2, fileName=sampleFilesN1_N2, condition=sampleConditionN1_N2, individual=sampleIndividual)
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable1, directory = directory,design= ~ condition + individual)
ddsHTSeq$condition <- relevel(ddsHTSeq$condition, "untreated")
dds<-DESeq(ddsHTSeq)
res<-results(dds)
res<-res[order(res$padj),]
write.csv(as.data.frame(res),file="DeSEQ2_treated_vs_untreated.csv")

From help(results), I understand if I want to get comparison of conditions considering the pairing of samples into account, I should give 

res <- results(dds, contrast=c("condition","treated","untreated"))

Is this correct? 

Also is my design correct: design=~condition+individual?

Any help is hugely appreciated. 

Thanks in advance.

 

deseq2 • 1.3k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 1 day ago
United States
Yes your code is correct. A side note: If you put condition at the end of the design formula instead of as the first variable, then results(dds) without arguments would have given the same results table. See vignette beginning for details on this.
ADD COMMENT

Login before adding your answer.

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