Search
Question: Group comparison in DESeq2
2
gravatar for jjinhyoungkim
3.2 years ago by
Canada
jjinhyoungkim20 wrote:

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"))
 
ADD COMMENTlink modified 3.2 years ago by Michael Love20k • written 3.2 years ago by jjinhyoungkim20
3
gravatar for Michael Love
3.2 years ago by
Michael Love20k
United States
Michael Love20k wrote:

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 COMMENTlink written 3.2 years ago by Michael Love20k

Hi Michael Love,

Great! Thanks for your help as always.

ADD REPLYlink written 3.2 years ago by jjinhyoungkim20

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 REPLYlink written 3.2 years ago by jjinhyoungkim20

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 REPLYlink written 3.2 years ago by Michael Love20k
0
gravatar for Michael Love
3.2 years ago by
Michael Love20k
United States
Michael Love20k wrote:

post changed to comment above

ADD COMMENTlink modified 3.2 years ago • written 3.2 years ago by Michael Love20k

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 REPLYlink written 3.2 years ago by jjinhyoungkim20
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 383 users visited in the last hour