Difference between revisions of "LimmaGuideCh7-8.R"
m |
(Add example 7.4) |
||
Line 1: | Line 1: | ||
# {{R}} | # {{R}} | ||
+ | |||
library(limma) | library(limma) | ||
# 7.2 Paired samples | # 7.2 Paired samples | ||
Line 18: | Line 19: | ||
contrast.matrix | contrast.matrix | ||
+ | # 7.4 | ||
+ | targets <- read.csv(file=stdin(), sep=" ") | ||
+ | SlideNumber FileName Cy3 Cy5 | ||
+ | 12 ml12med.spot CD4 CD8 | ||
+ | 13 ml13med.spot CD8 CD4 | ||
+ | 14 ml14med.spot DN CD8 | ||
+ | 15 ml15med.spot CD8 DN | ||
+ | 16 ml16med.spot CD4 DN | ||
+ | 17 ml17med.spot DN CD4 | ||
+ | "" | ||
+ | set.seed(1) | ||
+ | rownames(targets) <- paste("rowInd ", LETTERS[sort(sample(26,6))], sep="") | ||
+ | targets | ||
+ | design <- modelMatrix(targets, ref="CD4") | ||
+ | design | ||
+ | |||
+ | contrast.matrix <- cbind("CD8-CD4"=c(1,0),"DN-CD4"=c(0,1),"CD8-DN"=c(1,-1)) | ||
+ | rownames(contrast.matrix) <- colnames(design) | ||
+ | contrast.matrix | ||
# 8.1 | # 8.1 | ||
targets <- data.frame(cbind(FileName=paste("File",1:3, sep=""), Cy3=c("wt","mu","wt"), Cy5=c("mu","wt","mu"))) | targets <- data.frame(cbind(FileName=paste("File",1:3, sep=""), Cy3=c("wt","mu","wt"), Cy5=c("mu","wt","mu"))) |
Latest revision as of 00:42, 8 October 2007
Code snipits and programs written in R, S or S-PLUS
library(limma)
- 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
- 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
- 7.4
targets <- read.csv(file=stdin(), sep=" ") SlideNumber FileName Cy3 Cy5 12 ml12med.spot CD4 CD8 13 ml13med.spot CD8 CD4 14 ml14med.spot DN CD8 15 ml15med.spot CD8 DN 16 ml16med.spot CD4 DN 17 ml17med.spot DN CD4 "" set.seed(1) rownames(targets) <- paste("rowInd ", LETTERS[sort(sample(26,6))], sep="") targets design <- modelMatrix(targets, ref="CD4") design
contrast.matrix <- cbind("CD8-CD4"=c(1,0),"DN-CD4"=c(0,1),"CD8-DN"=c(1,-1)) rownames(contrast.matrix) <- colnames(design) contrast.matrix
- 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")
- 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
- 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)