In limma user guide 9.5.3 A Nested Interaction Formula (Page 44), the example has two levels for stimulation factor: S and U. Can I also use this model design for factor of more than two levels? To be specific, the example target frame is this:
FileName Strain Treatment
File1 WT U
File2 WT S
File3 Mu U
File4 Mu S
File5 Mu S
According to the user guide, if we just want to compare S vs. U for WT and Mu respectively, the design matrix can be setup using:
> Strain <- factor(targets$Strain, levels=c("WT","Mu"))
> Treatment <- factor(targets$Treatment, levels=c("U","S"))
> design <- model.matrix(~Strain+Strain:Treatment)
> colnames(design)
[1] "(Intercept)" "StrainMu" "StrainWT:TreatmentS" "StrainMu:TreatmentS"
The last two columns represent the effects of stimulation on WT and MU respectively. And this is exactly the same as doing following: combine two factors into one :TS (levels:WT.S, WT.U, Mu.S, Mu.U) and setup design matrix using model.matrix( ~0+TS) THEN makeContrasts( SvsUinWT=WT.S-WT.U, SvsUinMu=Mu.S-Mu.U, levels=design)
Above is from the user guide. NOW, back to my question. I have a target frame like this:
File Day Drug
file1 1 Ctrl
file2 1 Ctrl
file3 1 Ctrl
file4 1 Drug1
file5 1 Drug1
file6 1 Drug1
file7 1 Drug2
file8 1 Drug2
file9 1 Drug2
file10 1 Drug3
file11 1 Drug3
file12 1 Drug3
file13 2 Ctrl
file14 2 Ctrl
file15 2 Ctrl
file16 2 Drug1
file17 2 Drug1
file18 2 Drug1
file19 2 Drug2
file20 2 Drug2
file21 2 Drug2
file22 2 Drug3
file23 2 Drug3
file24 2 Drug3
file25 4 Ctrl
file26 4 Ctrl
file27 4 Ctrl
file28 4 Drug1
file29 4 Drug1
file30 4 Drug1
file31 4 Drug2
file32 4 Drug2
file33 4 Drug2
file34 4 Drug3
file35 4 Drug3
file36 4 Drug3
To summarize, I have 4 levels for the factor of Drug (including the Ctrl) and 3 levels for the factor Day. For each of the combination of Drug and Day I have 3 samples. All 36 samples are from 36 different subjects so this is NOT a time-course study on same set of subjects.
My question is: if I only want to compare Drug1 vs. Ctl, Drug2 vs.Ctl, Drug3 vs.Ctl at each of the Day point(1, 2, 4), can I use the nested interaction formula like this:
day <- factor(targets$Day)
drug <- factor(targets$Drug)
drug <- relevel(drug, "Ctrl")
design <- model.matrix(~day+day:drug)
fit <- lmFit(dta, design)
fit <- eBayes(fit)
The design matrix look like this:
[1] "(Intercept)" "day2" "day4" "day1:drugDrug1"
[5] "day2:drugDrug1" "day4:drugDrug1" "day1:drugDrug2" "day2:drugDrug2"
[9] "day4:drugDrug2" "day1:drugDrug3" "day2:drugDrug3" "day4:drugDrug3"
a. Are the results from column 4("day1:drugDrug1") to 12 what I need?
b. And is this the same as doing following: combine Day and Drug to one factor DayDrug(levels: Day1.Ctl, Day1.Drug1,...) and using
design <- model.matrix(~0+DayDrug)
fit <- lmFit(dta, design)
cont.matrix <- makeContrasts(Day1Drug1vsCtl =Day1.Drug1 - Day1.Ctl, Day2Drug1vsCtl =Day2.Drug1 - Day2.Ctl, ..., levels=design)
I appreciate any opinion from anybody. I've consulted several people around and got conflicted answers. Please help.
Cindy Wang
Aaron, thank you very much for confirmation and clarification.