I have the following experimental design and wanted to check the construction of the design matrix as well as a few other questions about setting it up.
Patient<-c("P1","P1","P1","P2","P2","P2","P3","P3","P3","P4","P4","P4","P1","P1","P1","P2","P2","P2","P3","P3","P3","P4","P4","P4") Condition<-c("uninf","uninf","uninf","uninf","uninf","uninf","uninf","uninf","uninf","uninf","uninf","uninf","inf","inf","inf","inf","inf","inf","inf","inf","inf","inf","inf","inf") Treatment<-c("D","S","R","D","S","R","D","S","R","D","S","R","D","S","R","D","S","R","D","S","R","D","S","R") Exp_Design<-data.frame(cbind(Patient,Condition,Treatment))
From the edgeR user guide, an example that had pairing across treatment but not across Condition (Section 3.5) used the following design matrix.
design<-model.matrix(~Condition+Condition:Patient+Condition:Treatment)
In my case though, I have pairing across treatment and across condition so would the proper design matrix be the following.
design2<-model.matrix(~Condition+Patient+Condition:Treatment)
My second question. The intercept has created confusion in my lab whenever I have to try to explain it to someone.
I tried to remove the intercept by using the following.
design3<-model.matrix(~0+Condition+Patient+Condition:Treatment)
This creates one with both conditions and I can create a contrast to get the difference between conditions, but I'm missing a patient and a Condition:Treatment.
I don't believe I have un-paramaterized the data properly. How would I go about setting that up?
Final question. With this experimental setup, would I be better served by running several paired comparisons
where I separate the data based upon which condition (inf,uninf) I'm looking at?
Example.
keep<-which(Condition%in%"inf") Pat2<-Patient[keep] Cond2<-Condition[keep] Treat2<-Treatment[keep] Exp_design_inf<-cbind(Pat2,Cond2,Treat2) design_inf<-model.matrix(~Pat2+Treat2)
And then repeat that procedure with the uninf condition.
If this is the route to take, how would I create the design matrix with pairing but without paramaterizing using the intercept?
The easiest way to define the design matrix depends partly on what comparisons you want to make. What comparisons between Conditions and Treatments do you want to make?
Thanks for the information.
I am interested in comparing the effect of the treatment (D vs. S, D vs. R, S vs. R) in both inf and uninf conditions. I am also interested in the differences between the inf and uninf conditions under the effect of all 3 treatments.
The reasons it is a paired design across the condition is each patient has their sample collected and then half of that sample in infected with a virus and the other half is left alone. After that, each sample is treated with the solvent, D, or two drugs of interest.