######################################################### ## Plots Demo ## ## Author: Han-Ming Wu (hmwu@stat.sinica.edu.tw) ## ## Institute of Statistical Science, Academia Sinica ## ## http://www.sinica.edu.tw/~hmwu/ ## ## 2005/07/27 ## ######################################################### ## Read Data setwd("C:\\Program Files\\R\\rw2001\\WorkingData") library(stats) cell.matrix <- read.table("TradCellCycle103_alpha.txt", header=TRUE) n <- dim(cell.matrix)[1] p <- dim(cell.matrix)[2]-2 cell.data <- cell.matrix[,3:p+2] gene.name <- cell.matrix[,1] gene.phase <- cell.matrix[,2] phase <- unique(gene.phase) phase.name <- c("G1", "S", "S/G2", "G2/M", "M/G1") ## standardized data cell.sdata <- (cell.data-apply(cell.data, 1, mean))/sqrt(apply(cell.data, 1, var)) #Histogram hist(cell.sdata[,1], br=12, col="lightblue", border="pink", labels = TRUE, main="Histogram for the exp. alpha14", xlab="log ratio") #Boxplot boxplot(cell.sdata) boxplot(cell.sdata[,1]~gene.phase, names=phase.name) #Scatterplot matrix pairs(cell.sdata[,1:5], col=phase) ## Data Image cell.image <- as.matrix(t(cell.sdata[n:1,])) RGcol <- maPalette(low = "green", high = "red", k = 50) image(cell.image, xlab="Exp.", ylab="Genes", col = RGcol) ## Time Series Plots number <- 1:n par(mfrow=c(3,2)) for(i in 0:4){ ts.plot(t(cell.sdata[number[gene.phase==i],]), xlab=phase.name[i+1]) } ### Name: maPalette ### Title: Microarray color palette ### Aliases: maPalette ### Keywords: color ### Author: Sandrine Dudoit , Yee Hwa (Jean) Yang maPalette <- function(low = "white", high = c("green", "red"), mid=NULL, k =50) { low <- col2rgb(low)/255 high <- col2rgb(high)/255 if(is.null(mid)){ r <- seq(low[1], high[1], len = k) g <- seq(low[2], high[2], len = k) b <- seq(low[3], high[3], len = k) } if(!is.null(mid)){ k2 <- round(k/2) mid <- col2rgb(mid)/255 r <- c(seq(low[1], mid[1], len = k2), seq(mid[1], high[1], len = k2)) g <- c(seq(low[2], mid[2], len = k2), seq(mid[2], high[2], len = k2)) b <- c(seq(low[3], mid[3], len = k2), seq(mid[3], high[3], len = k2)) } rgb(r, g, b) }