Hi Everyone, Im working on creating a comparison of ( Group1_T - Group2_T ) - (Group1_NT -Group2_NT ) to identify the DMRs that are found between my treatment comparison (Group1_T and Group2_T), and are not found in my control comparison (Group1_NT and Group2_NT). However, Im wondering if its possible to include factorial and continuous covariates in this, as my groups are not perfectly sex or age matched, and I want to include blood cell composition PCs.
Group <- factor(targets$Group)
Treat <- factor(targets$Treatment)
Sex <- factor(targets$Sex) # covariates
Age <- as.integer(targets$Age)
PC1 <- as.numeric(targets$PC1)
PC2 <- as.numeric(targets$PC2)
PC3 <- as.numeric(targets$PC3)
# My incorrect attempt at a standard interaction effect with a 2x2x2 design, plus the five covariates:
design <- model.matrix(~(Group*Treat)+Sex+Age+PC1+PC2+PC3, data=targets)
design
which gives me this design:
(Intercept) PopGroup2 TreatT Sex Age PC1 PC2 PC3 PopGroup2:TreatT
1 1 1 2 18 -0.806896196 0.10589096 -0.154088271 1
1 0 0 2 24 2.206815782 0.19763909 1.546195905 0
1 0 0 2 19 -2.111827930 0.28779334 0.312779390 0
I also tried to create this matrix an alternative way, where I created a Group_Treatment variable with the four levels: Group1_T, Group2_T, Group1_NT, Group2_NT. However, Im not sure if my covariates are still being factored into my "Interaction" comparison.
Group_Treatment <- factor(targets$Group_Treatment)
design<- model.matrix(~0+Group_Treatment+Sex+Age+PC1+PC2+PC3, data=targets)
contr <- makeContrasts(Interaction=(Group1_T -Group2_T)-(Group1_NT - Group2_NT),
levels = design)
myAnnotation <- cpg.annotate("array", object=mVals, what = "M",
arraytype = "EPICv2", analysis.type="differential",
contrasts = TRUE, cont.matrix = contr, design = design,
coef="Interaction", epicv2Filter = "mean")
Is my second attempt actually the correct comparison that Im looking for, with the 5 coefficients factored in? Or am I approaching this incorrectly?
Any help would be appreciated!
Thanks so much, James!