Group comparison in DESeq2
2
2
Entering edit mode
@jjinhyoungkim-8476
Last seen 9.2 years ago
Canada

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"))
 
deseq2 results • 18k views
ADD COMMENT
3
Entering edit mode
@mikelove
Last seen 5 days ago
United States

In order to compare the different groups in each condition, I recommend to follow the advice from another post:

A: DESEq2 comparison with mulitple cell types under 2 conditions

This will make it easy for you to contrast any groups you want.

ADD COMMENT
0
Entering edit mode

Hi Michael Love,

Great! Thanks for your help as always.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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:

coldata$group <- factor(paste0(coldata$set, coldata$condition))
ADD REPLY
0
Entering edit mode
@mikelove
Last seen 5 days ago
United States

post changed to comment above

ADD COMMENT
0
Entering edit mode

Here is update what I did. I will try to run group comparison, if it is correct. Thanks again.

 

> coldata = data.frame(row.names = colnames(countMatrix),set = rep(c("gt1","gt2","gt3","gt4"),2,each = 2),condition = rep(c("control","treated"),each = 8))
>
> coldata$condition = factor(x = coldata$condition,levels = c('control','treated'))
>
> dds = DESeqDataSetFromMatrix(countData = countMatrix, colData = coldata, design = ~ set + condition + set:condition)
> 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
> coldata$group <- factor(paste0(coldata$set, coldata$condition))
> dds$group <- factor(paste0(dds$set, dds$condition))
>

ADD REPLY

Login before adding your answer.

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