LimmaGuideCh7-8.R

From Organic Design wiki
Revision as of 00:39, 6 June 2007 by Sven (talk | contribs)

Code snipits and programs written in R, S or S-PLUS 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)