Hi all,
I have 4 paired samples in treatment vs control at 3 different time points. 
How can I set up a model.matrix so I can treat them as paired samples and compare the following comparisons in glmLRT of edgeR:
- Treatment vs control (paired samples), regardless of time
 - Treatment vs control (paired samples) at T1
 - Treatment vs control (paired samples) at T2
 - Treatment vs control (paired samples) at T3
 
Tentative code:
subject <- factor(c(rep("1", 3),rep("2", 2),rep("3", 3),rep("4", 3),
                rep("1", 3),rep("2", 3),rep("3", 3),rep("4", 3)))
condition <- factor(c(rep("treatment",11), rep("control",12)), levels=c("control","treatment")) #missing one treatment data
timepoints <- factor(c("t1","t2","t3","t1","t2","t1","t2","t3","t1","t2","t3",
                   "t1","t2","t3","t1","t2","t3","t1","t2","t3",
                   "t1","t2","t3"), levels=c("t1","t2","t3"))
sampleTable <- data.frame(subject = as.factor(subject),
                    condition = as.factor(condition),
                      timepoints = as.factor(timepoints))
design <- model.matrix(~subject+condition+timepoints+condition:timepoints)
fit <- glmFit(y, design)
Can my model.matrix fulfill what I need?
Sample table:
subject condition timepoints 
        1  treatment         t1 
        1  treatment         t2 
        1  treatment         t3 
        2  treatment        t1 
        2  treatment         t2 
        3  treatment         t1 
        3  treatment         t2 
        3  treatment         t3 
        4  treatment         t1 
        4  treatment        t2 
        4  treatment         t3 
        1   control         t1 
        1   control         t2 
        1   control         t3 
        2   control         t1 
        2   control         t2 
        2   control         t3 
        3   control         t1 
        3   control         t2 
        3   control         t3 
        4   control         t1 
        4   control         t2 
        4   control         t3  
Not an actual answer but just a question I got by looking at your design matrix, shouldn't you add a +0 such that the first column doesn't represent the intercept? (
design <- model.matrix(~0+subject+condition+timepoints+condition:timepoints)). Also as I was writing this I checked out the manual and this seems very similar to the section 3.3 of the edgeR User Guide, perhaps it is worth a look?The intercept doesn't matter, some people replace it since it makes their contrasts easier to specify or explain.