**20**wrote:

Hello All

I am trying to use edgeR to identify differentially expressed genes in my experiment involving three factors - 2 cell lines (Say A and B), 2 temperatures (t1 and t2) and 2 pH levels (p1 and p2). Each condition was conducted in duplicates and hence there are 16 samples in all. Since each of the factors could influence the outcome, I wanted to include all of them in my design matrix.

The questions I would like to answer are:

1) see the effect of temperature between t1 and t2, irrespective of the cell lines.

2) See the effect of pH between p1 and p2, irrespective of the cell lines.

3) Understand the differences between the cell lines.

4) Obtain the 2-way and 3-way interaction effects between the factors.

My code for Design Matrix is like this **(****Code is in bold)**:

**celltype <- factor(samples$ct, levels = c("A", "B"))
temp <- factor(samples$trt2, levels = c("t1", "t2"))
pH <- factor (samples$trt1, levels = c( "p1", "p2"))
design <- model.matrix(~celltype+temp+pH)
rownames(design) <- samples$file
design**

(Intercept) celltypeB tempt2 pHP2

Sample 1(B_t2_p2_1) 1 1 1 1

Sample2(B_t2_p2_2) 1 1 1 1

Sample3(B_t2_p1_1) 1 1 1 0

Sample4(B_t2_p1_2) 1 1 1 0

Sample5(A_t2_p2_1) 1 0 1 1

Sample6(A_t2_p2_2) 1 0 1 1

Sample7(A_t2_p1_1) 1 0 1 0

Sample8(A_t2_p1_2) 1 0 1 0

Sample9(B_t1_p1_1) 1 1 0 0

Sample10(B_t1_p1_2) 1 1 0 0

Sample11(B_t1_p2_1) 1 1 0 1

Sample12(B_t1_p2_2) 1 1 0 1

Sample13(A_t1_p2_1) 1 0 0 1

Sample14(A_t1_p2_2) 1 0 0 1

Sample15(A_t1_p1_1) 1 0 0 0

Sample16(A_t1_p1_2) 1 0 0 0

attr(,"assign")

[1] 0 1 2 3

attr(,"contrasts")

attr(,"contrasts")$celltype

[1] "contr.treatment"

attr(,"contrasts")$temp

[1] "contr.treatment"

attr(,"contrasts")$pH

[1] "contr.treatment"

**cds <- estimateGLMCommonDisp(cds, design, verbose=T) **

#Disp = 0.01078 , BCV = 0.1038

**cds2 <- estimateGLMTrendedDisp(cds, design)
cds2 <- estimateGLMTagwiseDisp(cds2, design)**

**glmfit <- glmFit(cds2, design)**

**de <- glmLRT(glmfit, coef = 3)
tt <- topTags(de, n=nrow(cds2))**

If I understand correctly, coef=3 should give me the effect of temperature - irrespective of cell lines and pH. Is my design correct? And will it be sufficient to answer my questions?

Thanks