Question: Designing a contrast in DESEQ
gravatar for mrigaya.mehra
21 months ago by
mrigaya.mehra10 wrote:


I am new to R and DeSEq. I am using DeSeq to identify DE genes in my experiment. The experiment consists of a 2x2 matrix with treatment and control administered in specific tissues. Thus creating 4 different combinations as below

1. treatment_tissue1

2. treatment_tissue2

3. control_tissue1

4. control_tissue2

I want to compare the DE genes found in the following combinations

1. treatment_tissue1 vs treatment_tissue2

2. control_tissue1 vs treatment_tissue1

3. control_tissue2 vs treatment_tissue2

I have designed my dds object as below

dds <- DESeqDataSetFromMatrix(countData = countdata, colData = coldata, design = ~ treatment )

dds$group <- factor(paste0(dds$treatment, dds$tissue))

dds$group <- relevel(dds$group, "control_tissue1")

I am not sure if I am doing it correct, please advise. Also, I do not understand how I can set up the contrast. Please help.

Someone suggested that I use a model matrix and then use contrast. Though I have set up a model matrix but I am stuck at the point where I have to set up contrasts. Please help




ADD COMMENTlink modified 21 months ago • written 21 months ago by mrigaya.mehra10

Dear Michael,

Thanks for your reply, I have 40 samples from 10 patients. I did follow the example mentioned in the link. I created a group like this

dds$group <- factor(paste0(dds$treatment, dds$tissue))

dds$group <- relevel(dds$group, "control_tissue1")
design(dds) <- ~ group

dds <- DESeq(dds)

So considering this design I got ~600 DE genes.

But now I also have to take into account one more factor

My design is like this

patient    treatment    tissue    group
patient1    treatment1    tissue1    control
patient1    treatment2    tissue1    control
patient1    treatment1    tissue2    control
patient1    treatment2    tissue2    control
patient2    treatment1    tissue1    treated
patient2    treatment2    tissue1    treated
patient2    treatment1    tissue2    treated
patient2    treatment2    tissue2    treated
patient3    treatment1    tissue1    control
patient3    treatment2    tissue1    control
patient3    treatment1    tissue2    control
patient3    treatment2    tissue2    control
patient4    treatment1    tissue1    treated
patient4    treatment2    tissue1    treated
patient4    treatment1    tissue2    treated
patient4    treatment2    tissue2    treated
patient5    treatment1    tissue1    control
patient5    treatment2    tissue1    control
patient5    treatment1    tissue2    control
patient5    treatment2    tissue2    control
patient6    treatment1    tissue1    treated
patient6    treatment2    tissue1    treated
patient6    treatment1    tissue2    treated
patient6    treatment2    tissue2    treated
patient7    treatment1    tissue1    control
patient7    treatment2    tissue1    control
patient7    treatment1    tissue2    control
patient7    treatment2    tissue2    control
patient8    treatment1    tissue1    treated
patient8    treatment2    tissue1    treated
patient8    treatment1    tissue2    treated
patient8    treatment2    tissue2    treated
patient9    treatment1    tissue1    treated
patient9    treatment2    tissue1    treated
patient9    treatment1    tissue2    treated
patient9    treatment2    tissue2    treated
patient10    treatment1    tissue1    treated
patient10    treatment2    tissue1    treated
patient10    treatment1    tissue2    treated
patient10    treatment2    tissue2    treated

and I also want to consider the variations in the patients data.

So, I generated a second design

design(dds) <- ~ group + patient

and here I got ~1000 DE genes. I do not understand why there is a difference in the DE gene numbers and also if I am dong it the right way. Please help.

ADD REPLYlink modified 21 months ago • written 21 months ago by mrigaya.mehra10

Adding patient as a term should help remove the variation across patient, and improve sensitivity. This is potentially why you have more DE genes.

Note that you should follow the recommendations in the vignette and always put the variable of interest (group) at the END of the design formula: ~ patient + group. 

ADD REPLYlink written 21 months ago by Michael Love20k
gravatar for Michael Love
21 months ago by
Michael Love20k
United States
Michael Love20k wrote:

How many samples do you have total?

Why don't you follow the example in the vignette, in the beginning of the interactions section:


ADD COMMENTlink written 21 months ago by Michael Love20k
Please log in to add an answer.


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