Multi-way Anova Identifying and quantifying sources of variation Ability to "factor out" certain sources - ("adjusting") For the beginning, we will reproduce paired t-test results by assuming that arrays are one of the factors in a Two-way ANOVA Second, adjusting for the dye effects in a Three-way ANOVA Third, four and more - way ANOVA when having multiple factors of interest
Sources of variation And the Two-way ANOVA
Statistical Inference in Two-way ANOVA Statistical Model Parameter Estimates Null Hypotheses Null Distributions
Alternative Formulations of the Two-way ANOVA No-intercept Model Parameter Estimates Gets complicated Regardless of how the model is parametrized certain parameters remain unchanged (Trt 2 -Trt 1 ) In this sense all formulations are equivalent Null Hypotheses Null Distributions
Re-organizing data for ANOVA > DAnova<-NNBLimmadataC > DAnova$weights<-cbind(DAnova$weights,DAnova$weights) > DAnova$M<-cbind((DAnova$A+DAnova$M/2),DAnova$A-(DAnova$M/2)) > DAnova$A<-cbind(DAnova$A,DAnova$A) > attributes(DAnova) $names [1] "weights" "targets" "genes" "printer" "M" "A" $class [1] "MAList" attr(,"package") [1] "limma" > NNBLimmadataC$M[1,] 51-C1-3-vs-W W2-3-vs-C C3-3-vs-W W4-3-vs-C C5-3-vs-W W6-3-vs-C > NNBLimmadataC$A[1,] 51-C1-3-vs-W W2-3-vs-C C3-3-vs-W W4-3-vs-C C5-3-vs-W W6-3-vs-C > DAnova$M[1,] 51-C1-3-vs-W W2-3-vs-C C3-3-vs-W W4-3-vs-C C5-3-vs-W W6-3-vs-C C1-3-vs-W W2-3-vs-C C3-3-vs-W W4-3-vs-C C5-3-vs-W W6-3-vs-C
Setting-up the design matrix for limma > targets SlideNumber FileName Cy3 Cy5 Date 51-C1-3-vs-W C1-3-vs-W1-5.gpr C W 11/8/ W2-3-vs-C W2-3-vs-C2-5.gpr W C 11/8/ C3-3-vs-W C3-3-vs-W3-5.gpr C W 11/8/ W4-3-vs-C W4-3-vs-C4-5.gpr W C 11/8/ C5-3-vs-W C5-3-vs-W5-5.gpr C W 11/8/ W6-3-vs-C W6-3-vs-C6-5.gpr W C 11/8/2004 > trt<-c(targets$Cy5,targets$Cy3) > trt [1] "W" "C" "W" "C" "W" "C" "C" "W" "C" "W" "C" "W" > array<-c(1:6,1:6) > array [1]
Setting-up the design matrix for limma > designa<-model.matrix(~-1+factor(array)+factor(trt)) > designa factor(array)1 factor(array)2 factor(array)3 factor(array)4 factor(array)5 factor(array)6 factor(trt)W attr(,"assign") [1] attr(,"contrasts") attr(,"contrasts")$"factor(array)" [1] "contr.treatment" attr(,"contrasts")$"factor(trt)" [1] "contr.treatment"
Setting-up the design matrix for limma > colnames(designa)<-c(paste("A",1:6,sep=""),"W") > designa A1 A2 A3 A4 A5 A6 W attr(,"assign") [1] attr(,"contrasts") attr(,"contrasts")$"factor(array)" [1] "contr.treatment" attr(,"contrasts")$"factor(trt)" [1] "contr.treatment"
Comparing to paired t-test > Anova<-lmFit(DAnova,designa) > > Anova$coefficients[2,] A1 A2 A3 A4 A5 A6 W > LimmaPTT$coefficients[2] [1] > Anova$coefficients[1,] A1 A2 A3 A4 A5 A6 W NA NA > LimmaPTT$coefficients[1] [1] >
Comparing to paired t-test > plot(Anova$coefficients[,"W"],LimmaPTT$coefficients) > plot(Anova$sigma,LimmaPTT$sigma) > plot(Anova$stdev.unscaled[,"W"],LimmaPTT$stdev.unscaled) > plot(Anova$sigma*Anova$stdev.unscaled[,"W"],LimmaPTT$sigma*LimmaPTT$stdev.unscaled) > plot(Anova$df.residual,LimmaPTT$df.residual)
Adjusting for Dye - Three-way ANOVA > dye<-c(rep("Cy5",6),rep("Cy3",6)) > > designad<-model.matrix(~-1+factor(array)+factor(dye)+factor(trt)) > #designad > colnames(designad)<-c(paste("A",1:6,sep=""),"Cy5","W") > designad A1 A2 A3 A4 A5 A6 Cy5 W attr(,"assign") [1] attr(,"contrasts") attr(,"contrasts")$"factor(array)" [1] "contr.treatment" attr(,"contrasts")$"factor(dye)" [1] "contr.treatment" attr(,"contrasts")$"factor(trt)" [1] "contr.treatment"
Adjusting for Dye - Three-way ANOVA >Anovad<-lmFit(DAnova,designad) > > Anova$coefficients[2,] A1 A2 A3 A4 A5 A6 W > LimmaPTT$coefficients[2] [1] > Anovad$coefficients[2,] A1 A2 A3 A4 A5 A6 Cy5 W > Anova$coefficients[1,] A1 A2 A3 A4 A5 A6 W NA NA > LimmaPTT$coefficients[1] [1] > Anovad$coefficients[1,] A1 A2 A3 A4 A5 A6 Cy5 W NA NA >
Comparing to paired t-test > plot(Anovad$coefficients[,"W"],LimmaPTT$coefficients) > plot(Anovad$sigma,LimmaPTT$sigma) > plot(Anovad$stdev.unscaled[,"W"],LimmaPTT$stdev.unscaled) > plot(Anovad$sigma*Anova$stdev.unscaled[,"W"],LimmaPTT$sigma*LimmaPTT$stdev.unscaled) > plot(Anovad$df.residual,LimmaPTT$df.residual)
Comparing to paired t-test > AnovaB<-eBayes(Anova) > AnovadB<-eBayes(Anovad) > volcanoplot(AnovaB,coef=7) > volcanoplot(AnovadB,coef=8)