Question: Designing a contrast in DESEQ
gravatar for mrigaya.mehra
2.2 years 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 2.2 years ago • written 2.2 years 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 2.2 years ago • written 2.2 years 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 2.1 years ago by Michael Love22k

Why should variables of interest go at the end of design formulae?

I've briefly read about sequential sums of squares. Are sequential sums of squares calculated in DESeq2, and (if so) are they calculated in the order that terms appear in the design formula?

ADD REPLYlink written 11 weeks ago by galen.seilis0

Nearly all R packages will automatically test for the last coefficient first, if you don't provide any additional information to the software about which coefficient to test. Of course, you can also specify which coefficient to test, and then the order doesn't matter.

ADD REPLYlink written 11 weeks ago by Michael Love22k
Answer: Designing a contrast in DESEQ
gravatar for Michael Love
2.2 years ago by
Michael Love22k
United States
Michael Love22k 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 2.2 years ago by Michael Love22k
Please log in to add an answer.


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