Hi,
I am trying to run DESeq2 with the duplicated raw counts from 4 groups and 2 conditions using the two-way ANOVA design below. Referring a vignette of DESeq2, various comparisons have been run as below. Besides of these results, I want to get DEGs between groups (group1 vs each other group). How can get DEGs between groups in each condition? I tried to run following comparisons, but it did not get reasonable number of DEGs. Do I need to make other design for these comparisons between groups? Thank you in advance for your valuable comments.
Jin
>library("DESeq2") >countMatrix = read.table("~/Desktop/aaa.txt",header = T,row.names = 1) >coldata = data.frame(row.names =colnames(countMatrix),group =rep(c("gt1","gt2","gt3","gt4"),2,each = 2),treatment = rep(c("control","treated"),each= 8)) >coldata$treatment = factor(x = coldata$treatment,levels = c('control','treated'))>dds = DESeqDataSetFromMatrix(countData =countMatrix, colData = coldata, design = ~ group + treatment +group:treatment) >dds = DESeq(dds) > resultsNames(dds) [1] "Intercept" "groupgt1" "groupgt2" "groupgt3" [5] "groupgt4" "treatmentcontrol" "treatmenttreated" "groupgt1.treatmentcontrol" [9] "groupgt2.treatmentcontrol" "groupgt3.treatmentcontrol" "groupgt4.treatmentcontrol" "groupgt1.treatmenttreated" [13] "groupgt2.treatmenttreated" "groupgt3.treatmenttreated" "groupgt4.treatmenttreated"
# the main effect for condition
>res <- results(dds,contrast=list("treatmenttreated","treatmentcontrol"))
#the interaction term for condition in each group >res <- results(dds, contrast=list("groupgt1.treatmenttreated","groupgt1.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt2.treatmenttreated","groupgt2.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt3.treatmenttreated","groupgt3.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt4.treatmenttreated","groupgt4.treatmentcontrol"))
# the condition effect in each goup >res <- results(dds, contrast=list(c("treatmenttreated","groupgt1.treatmenttreated"), c("treatmentcontrol","groupgt1.treatmentcontrol"))) >res <- results(dds, contrast=list(c("treatmenttreated","groupgt2.treatmenttreated"), c("treatmentcontrol","groupgt2.treatmentcontrol"))) >res <- results(dds, contrast=list(c("treatmenttreated","groupgt3.treatmenttreated"), c("treatmentcontrol","groupgt3.treatmentcontrol"))) >res <- results(dds, contrast=list(c("treatmenttreated","groupgt4.treatmenttreated"), c("treatmentcontrol","groupgt4.treatmentcontrol")))
## The comparison between groups
# group1 vs other group
>res <- results(dds, contrast=list("groupgt2","groupgt1")) >res <- results(dds, contrast=list("groupgt3","groupgt1")) >res <- results(dds, contrast=list("groupgt4","groupgt1")) # In the control condition >res <- results(dds, contrast=list("groupgt2.treatmentcontrol","groupgt1.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt3.treatmentcontrol","groupgt1.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt4.treatmentcontrol","groupgt1.treatmentcontrol")) # In the treated condition >res <- results(dds, contrast=list("groupgt2.treatmenttreated","groupgt1.treatmenttreated")) >res <- results(dds, contrast=list("groupgt3.treatmenttreated","groupgt1.treatmenttreated")) >res <- results(dds, contrast=list("groupgt4.treatmenttreated","groupgt1.treatmenttreated")) # treated vs control >res <- results(dds, contrast=list("groupgt2.treatmenttreated","groupgt1.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt3.treatmenttreated","groupgt1.treatmentcontrol")) >res <- results(dds, contrast=list("groupgt4.treatmenttreated","groupgt1.treatmentcontrol"))
Hi Michael Love,
Great! Thanks for your help as always.
I tried to use the group comparison and got a error message as below. How can be it fixed?
> coldata
set condition
Genotype1.1 gt1 control
Genotype1.2 gt1 control
Genotype2.1 gt2 control
Genotype2.2 gt2 control
Genotype3.1 gt3 control
Genotype3.2 gt3 control
Genotype4.1 gt4 control
Genotype4.2 gt4 control
Genotype1.1_treated gt1 treated
Genotype1.2_treated gt1 treated
Genotype2.1_treated gt2 treated
Genotype2.2_treated gt2 treated
Genotype3.1_treated gt3 treated
Genotype3.2_treated gt3 treated
Genotype4.1_treated gt4 treated
Genotype4.2_treated gt4 treated
> dds$group <- factor(paste0(dds$set, dds$condition))
Error in `[[<-`(`*tmp*`, name, value = integer(0)) :
0 elements in value to replace 16 elements
You haven't constructed dds yet so you can't operate on its columns. You can either first make dds or you can perform this operation on coldata columns: