DiagnosticImages.R
Code snipits and programs written in R, S or S-PLUS library(limma)
source("readData.R") source("dirExists.R")
bc.correct <- c("none","subtract","minimum", "movingmin") method.within <- c("none","loess") method.between <- c("none","scale", "quantile")
- 3) Making Diagnostic directories
plotDir <- "tmp" dir.exists(file.path(plotDir, "Densityplots")) for(i in c("ImagePlots","MAplots")) {
dir.exists(file.path(plotDir, i)) if(i == "ImagePlots") { for(x in bc.correct) { for(y in method.within) { for(z in method.between) { for( j in c("R","G", "M","A")) { dir.exists(file.path(plotDir, i, paste(x,"-",y,"-",z, sep=""),j)) if(x=="none" & y =="none" & z =="none") { for(k in c("Rb", "Gb")) { dir.exists(file.path(plotDir, i, paste(x,"-",y,"-",z, sep=""),k)) } } } } } } } if(i == "MAplots") { for(x in bc.correct) { for(y in method.within) { for(z in method.between) { dir.exists(file.path(plotDir, i, paste(x,"-",y,"-",z, sep=""))) } } } }
}
- 2) Diagnostic plots for raw and loess normalized data (with background subtraction)
- Density plots
for(i in bc.correct) {
for( j in method.within) { MA <- normalizeWithinArrays(RG, method=j, bc.method=i) for (k in method.between) { MA.Between <- normalizeBetweenArrays(MA, method=k) print(paste("[ Graphing:",i,j,k,"]", sep=" ")) png(file.path(plotDir, "Densityplots", paste(i,"-",j,"-",k,".png", sep=""))) plotDensities(MA.Between) dev.off() } }
}
- MAplots
for(i in bc.correct) {
for( j in method.within) { MA <- normalizeWithinArrays(RG, method=j, bc.method=i) for (k in method.between) { MA.Between <- normalizeBetweenArrays(MA, method=k) print(paste("[ Graphing:",i,j,k,"]", sep=" ")) plotMA3by2(MA.Between, path=file.path(plotDir, "MAplots", paste(i,"-",j,"-",k, sep=""))) } }
}
- Imageplots
for(i in bc.correct) {
for( j in method.within) { # handles background correction and within normalization without overwriting RG MA <- normalizeWithinArrays(RG, method=j, bc.method=i) for (k in method.between) { MA.Between <- normalizeBetweenArrays(MA, method=k) print(paste("[ Graphing:",i,j,k,"]", sep=" ")) imageplot3by2(MA.Between, z="M", path = file.path(plotDir,"Imageplots", paste(i,"-",j,"-",k, sep=""), "M")) imageplot3by2(MA.Between, z="A", path = file.path(plotDir,"Imageplots", paste(i,"-",j,"-",k, sep=""), "A")) imageplot3by2(RG.MA(MA.Between), z="G", path = file.path(plotDir,"Imageplots", paste(i,"-",j,"-",k, sep=""),"G"), low="black", high="green") imageplot3by2(RG.MA(MA.Between), z="R", path = file.path(plotDir,"Imageplots", paste(i,"-",j,"-",k, sep=""),"R"), low="black", high="red") if(i=="none" & j=="none" & k=="none") { imageplot3by2(RG, z="Gb", path = file.path(plotDir,"Imageplots", paste(i,"-",j,"-",k, sep=""),"Gb"), low="black", high="green") imageplot3by2(RG, z="Rb", path = file.path(plotDir,"Imageplots", paste(i,"-",j,"-",k, sep=""),"Rb"), low="black", high="red") } } }
}
- Splom pairs plots
library(lattice) tmp <- as.data.frame(rbind(RG$R, RG$G)) tmp$channel <- rep(c("log2(Red)","log2(Green)"), each=nrow(tmp)/2)
dir.exists(file.path(plotDir,"PairsPlots"))
for( i in seq(1, ncol(RG), by=3)) {
png(file.path(plotDir, "PairsPlots", paste(targets[,3][i],".png",sep=""))) print(splom(~ log2(tmp[,i:(i+2)])| tmp$channel, xlab=targets[,3][i])) dev.off()
}
- Comparing Pool 3 Cy5 to Pool 11 Cy5 (same treatment)
P3ind <- grep("P3", targets[,"Filetype"]) P9ind <- grep("P9", targets[,"Filetype"])
tmp <- RG tmp$R <- RG$R[,P3ind] tmp$Rb <- RG$Rb[,P3ind] tmp$G <- RG$R[,P9ind] tmp$Gb <- RG$Rb[,P9ind] tmp$weights <- NULL tmp
- Shows when scanning is clipping
par(mfrow=c(2,2)) plotMA(tmp, array=1) plotMA(tmp, array=2) plotMA(tmp, array=3)