Difference between revisions of "LimmaGuideCh7-8.R"

From Organic Design wiki
 
(Adding my own loop example)
Line 31: Line 31:
 
contr
 
contr
 
design %*% contr
 
design %*% contr
 +
 +
# Loop design example
 +
design <- diag(5)[rep(1:5, each=2),]
 +
colnames(design) <- c("BtoA","CtoB","DtoC","EtoD","AtoE")
 +
 +
makeContrasts("B-A" = BtoA,
 +
              "C-A" = CtoB - BtoA,
 +
              "D-A" = DtoC - CtoB - BtoA,
 +
              "E-A" = EtoD - DtoC - CtoB - BtoA,
 +
              "E-A alternative" = AtoE,
 +
              levels=design)

Revision as of 21:49, 4 September 2006

library(limma)

  1. 7.2 Paired samples

design <- model.matrix(~ -1+factor(c(1,1,1,2,2,3,3,3))) colnames(design) <- c("group1", "group2", "group3") design

contrast.matrix <- makeContrasts(group2-group1, group3-group2, group3-group1, levels=design) contrast.matrix

  1. 7.3

targets <- readTargets(file.path("/Volumes/HD2/R/Examples/limmaGuideData", "runxtargets.txt"), sep=" ") targets design <- modelMatrix(targets,ref="EGFP") design contrast.matrix <- makeContrasts(AML1,CBFb,AML1.CBFb,AML1.CBFb-AML1,AML1.CBFb-CBFb, levels=design) contrast.matrix

  1. 8.1

targets <- data.frame(cbind(FileName=paste("File",1:3, sep=""), Cy3=c("wt","mu","wt"), Cy5=c("mu","wt","mu"))) targets

modelMatrix(targets, ref="wt")

  1. 8.4

targets <- data.frame(cbind(FileName=paste("File",1:5, sep=""), Cy3=rep("Ref",5), Cy5=rep(c("WT","Mu"), c(2,3)))) targets design <- modelMatrix(targets, ref="Ref") design contr <- makeContrasts(MUvsWT=WT-Mu, levels=design) contr design %*% contr

  1. Loop design example

design <- diag(5)[rep(1:5, each=2),] colnames(design) <- c("BtoA","CtoB","DtoC","EtoD","AtoE")

makeContrasts("B-A" = BtoA,

             "C-A" = CtoB - BtoA,
             "D-A" = DtoC - CtoB - BtoA,
             "E-A" = EtoD - DtoC - CtoB - BtoA,
             "E-A alternative" = AtoE,
             levels=design)