Hi,

I am using edgeR to carry out DE analysis for my RNA Seq samples, may I know how can I construct the design matrix and how can I make sure that during testing, the DE genes shown are of the correct contrast?

My current steps are shown below:

**Current data type:
subject: 1,2,3,4**

**treatment for each subject: T0, T1**

I would like to find DE genes between conditions (T0, T1) for each paired samples:

**design <- model.matrix(~Subject+Condition)**

**d <- d[rowSums(cpm(d)>10) >= (length(G1_ids)/2),,keep.lib.sizes = FALSE ]**

**d <- calcNormFactors(d)**

**d <- estimateGLMCommonDisp(d,design)**

**d <- estimateGLMTrendedDisp(d,design)**

**d <- estimateGLMTagwiseDisp(d,design)**

**fit <- glmQLFit(d, design, robust = TRUE)**

**result_glm <- glmQLFTest(fit)**

It seems to me that, using the above steps, I get DE genes which are differentially expressed between samples, not between conditions.


Thank you!
Maggie Pan
Please see section 3.4.2 of the edgeR vignette.

    result_glm <- glmQLFTest(fit, coef=5)  # Or maybe coef=4, it'll be the last column in "design"