So your experiment looks like this:
times <- rep(c(0, 1, 3, 5, 7), 2)
geno <- rep(c("WT", "KO"), each=5)
There are a few ways you can formulate your design matrix, but I would go with:
design <- model.matrix(~0 + geno + times:geno)
The first two coefficients represent the intercept in each genotype, while the next two represent the slope of change with respect to time (in days) within each genotype. So, you're effectively fitting a line to the (log-)expression across time, and doing that separately for each genotype.
The main assumption is, of course, that the change in log-expression is linear with respect to time. I've also assumed that each time point comes from an independent replicate; if all time points were collected from the same mouse, then you effectively have n=1 and would not be able to make any population inferences.
To test for the effect of time in each genotype, simply drop the relevant coefficient (genoKO:times
or genoWT:times
) in topTable
. If you want to test for differences in the time effect between genotypes:
colnames(design) <- make.names(colnames(design)) # make names syntactically vald
con <- makeContrasts(genoKO.times - genoWT.times, levels=design)
... and then go through contrasts.fit
and eBayes
.
P.S Don't use the "Tutorial" tag; that is intended for people who are writing and publishing tutorials, rather than those who are asking for help. The latter is just a normal question on this site.
Your experiment seems almost exactly the same as covered in Section 9.6.1 (Time Course Experiments) of the limma User's Guide.
Aaron has outlined a nested interaction approach to forming the design matrix (see Section 9.5.3). You could either follow Aaron's code or follow Section 9.6.1 -- both ways will give the same results in the end.
Thank you for the input.