LIMMA contrast matrix for three-way ANOVA with many comparisons
0
0
Entering edit mode
Levi Waldron ★ 1.1k
@levi-waldron-3429
Last seen 7 weeks ago
CUNY Graduate School of Public Health a…
I'm trying to assemble a LIMMA contrast matrix using group means parametrization for a 2x2x4 (treatment x treatment x time course) complete randomized ANOVA design. I am wondering if anyone could confirm that I'm doing it correctly, as the LIMMA Reference Guide doesn't have any examples which involve summing/averaging treatments in the contrast matrix. In particular, I want to make sure that I should look for main effects by averaging together all groups with each level of the main effect, ie to look for a genotype (AB) main effect with the treatments no/yes and four time points, with a line like this in makeContrasts: genotype=(no.A.t4+no.A.t3+no.A.t1+no.A.t2+no.B.t4+no.B.t3+no.B.t1+no.B .t2)/8 - (yes.A.t4+yes.A.t3+yes.A.t1+yes.A.t2+yes.B.t4+yes.B.t3+yes.B.t1+yes.B. t2)/8 For a full example: (Time <- factor(paste("t",1:4,sep=""))) [1] t1 t2 t3 t4 Levels: t1 t2 t3 t4 > (genotype <- factor(LETTERS[1:2])) [1] A B Levels: A B > (treatment <- factor(c("no","yes"))) [1] no yes Levels: no yes > (pdata <- data.frame(genotype=sort(gl(2,1,16,labels=c("no","yes"))), + treatment=rep(sort(gl(2,1,8,labels=LETTERS[1:2])),2), + Time=gl(4,1,16,labels=paste("t",1:4,sep="")) + ) + ) genotype treatment Time 1 no A t1 2 no A t2 3 no A t3 4 no A t4 5 no B t1 6 no B t2 7 no B t3 8 no B t4 9 yes A t1 10 yes A t2 11 yes A t3 12 yes A t4 13 yes B t1 14 yes B t2 15 yes B t3 16 yes B t4 (assuming only one replicate for simplicity here.) Then build the design matrix: (TS <- factor(paste(pdata$genotype,pdata$treatment,pdata$Time,sep="."))) [1] no.A.t1 no.A.t2 no.A.t3 no.A.t4 no.B.t1 no.B.t2 no.B.t3 no.B.t4 [9] yes.A.t1 yes.A.t2 yes.A.t3 yes.A.t4 yes.B.t1 yes.B.t2 yes.B.t3 yes.B.t4 16 Levels: no.A.t1 no.A.t2 no.A.t3 no.A.t4 no.B.t1 no.B.t2 no.B.t3 ... yes.B.t4 > design <- model.matrix(~0+TS) > colnames(design) <- levels(TS) In this example I'm interested in the following comparisons: 1) genes differing overall between the two genotypes 2) genes differing overall by treatment 3) genes where two genotypes respond differently to treatment (genotype:treatment interaction) 4) genes with a significant treatment effect at time points 1, 2, 3, and 4 5) genes where the treatment effect differs for the two genotypes at each time point So I *think* I build the contrast matrix for these comparisons as follows - does this look right? > cont.matrix <- makeContrasts(genotype=(no.A.t4+no.A.t3+no.A.t1+no.A.t2+no.B.t4+no.B.t 3+no.B.t1+no.B.t2)/8 - (yes.A.t4+yes.A.t3+yes.A.t1+yes.A.t2+yes.B.t4+yes.B.t3+yes.B.t1+yes.B. t2)/8, #genotype main effect + treatment=(no.A.t4+no.A.t3+no.A.t1+no.A.t2+yes.A.t4+yes.A.t3+yes.A.t1+ yes.A.t2)/8 - (no.B.t4+no.B.t3+no.B.t1+no.B.t2+yes.B.t4+yes.B.t3+yes.B.t1+yes.B.t2 )/8, #treatment main effect + genotype.treatment.interaction=((no.A.t4+no.A.t3+no.A.t1+no.A.t2)/4 - (no.B.t4+no.B.t3+no.B.t1+no.B.t2)/4) - ((yes.A.t4+yes.A.t3+yes.A.t1+yes.A.t2)/4 - (yes.B.t4+yes.B.t3+yes.B.t1+yes.B.t2)/4), #interaction between genotype and treatment + #next four lines for genes with a significant treatment effect at time points 1, 2, 3, and 4 + treatment.t1=(no.A.t1+yes.A.t1)/2-(no.B.t1+yes.B.t1)/2, + treatment.t2=(no.A.t2+yes.A.t2)/2-(no.B.t2+yes.B.t2)/2, + treatment.t3=(no.A.t3+yes.A.t3)/2-(no.B.t3+yes.B.t3)/2, + treatment.t4=(no.A.t4+yes.A.t4)/2-(no.B.t4+yes.B.t4)/2, + #next eight lines for genes differing in treatment for each level of genotype and each time point + genotype.no.t1=no.A.t1-no.B.t1, + genotype.no.t2=no.A.t2-no.B.t2, + genotype.no.t3=no.A.t3-no.B.t3, + genotype.no.t4=no.A.t4-no.B.t4, + genotype.yes.t1=yes.A.t1-yes.B.t1, + genotype.yes.t2=yes.A.t2-yes.B.t2, + genotype.yes.t3=yes.A.t3-yes.B.t3, + genotype.yes.t4=yes.A.t4-yes.B.t4, + levels=design) > cont.matrix Contrasts Levels genotype treatment genotype.treatment.interaction treatment.t1 treatment.t2 no.A.t1 0.125 0.125 0.25 0.5 0.0 no.A.t2 0.125 0.125 0.25 0.0 0.5 no.A.t3 0.125 0.125 0.25 0.0 0.0 no.A.t4 0.125 0.125 0.25 0.0 0.0 no.B.t1 0.125 -0.125 -0.25 -0.5 0.0 no.B.t2 0.125 -0.125 -0.25 0.0 -0.5 no.B.t3 0.125 -0.125 -0.25 0.0 0.0 no.B.t4 0.125 -0.125 -0.25 0.0 0.0 yes.A.t1 -0.125 0.125 -0.25 0.5 0.0 yes.A.t2 -0.125 0.125 -0.25 0.0 0.5 yes.A.t3 -0.125 0.125 -0.25 0.0 0.0 yes.A.t4 -0.125 0.125 -0.25 0.0 0.0 yes.B.t1 -0.125 -0.125 0.25 -0.5 0.0 yes.B.t2 -0.125 -0.125 0.25 0.0 -0.5 yes.B.t3 -0.125 -0.125 0.25 0.0 0.0 yes.B.t4 -0.125 -0.125 0.25 0.0 0.0 Contrasts Levels treatment.t3 treatment.t4 genotype.no.t1 genotype.no.t2 genotype.no.t3 no.A.t1 0.0 0.0 1 0 0 no.A.t2 0.0 0.0 0 1 0 no.A.t3 0.5 0.0 0 0 1 no.A.t4 0.0 0.5 0 0 0 no.B.t1 0.0 0.0 -1 0 0 no.B.t2 0.0 0.0 0 -1 0 no.B.t3 -0.5 0.0 0 0 -1 no.B.t4 0.0 -0.5 0 0 0 yes.A.t1 0.0 0.0 0 0 0 yes.A.t2 0.0 0.0 0 0 0 yes.A.t3 0.5 0.0 0 0 0 yes.A.t4 0.0 0.5 0 0 0 yes.B.t1 0.0 0.0 0 0 0 yes.B.t2 0.0 0.0 0 0 0 yes.B.t3 -0.5 0.0 0 0 0 yes.B.t4 0.0 -0.5 0 0 0 Contrasts Levels genotype.no.t4 genotype.yes.t1 genotype.yes.t2 genotype.yes.t3 genotype.yes.t4 no.A.t1 0 0 0 0 0 no.A.t2 0 0 0 0 0 no.A.t3 0 0 0 0 0 no.A.t4 1 0 0 0 0 no.B.t1 0 0 0 0 0 no.B.t2 0 0 0 0 0 no.B.t3 0 0 0 0 0 no.B.t4 -1 0 0 0 0 yes.A.t1 0 1 0 0 0 yes.A.t2 0 0 1 0 0 yes.A.t3 0 0 0 1 0 yes.A.t4 0 0 0 0 1 yes.B.t1 0 -1 0 0 0 yes.B.t2 0 0 -1 0 0 yes.B.t3 0 0 0 -1 0 yes.B.t4 0 0 0 0 -1 > -- Levi Waldron post-doctoral fellow Jurisica Lab, Ontario Cancer Institute Division of Signaling Biology IBM Life Sciences Discovery Centre TMDT 9-304D 101 College Street Toronto, Ontario M5G 1L7 (416)581-7453 [[alternative HTML version deleted]]
Cancer limma Cancer limma • 1.5k views
ADD COMMENT

Login before adding your answer.

Traffic: 848 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6