################################################### ### chunk number 1: ################################################### options(width=40) ################################################### ### chunk number 2: eval=FALSE ################################################### ## install.packages("UsingR") ## source("http://bioconductor.org/biocLite.R") ## biocLite(c("limma")) ################################################### ### chunk number 3: ################################################### library(UsingR) res <- lm(homedata$y2000 ~ homedata$y1970) res ################################################### ### chunk number 4: ################################################### args(abline) ################################################### ### chunk number 5: ################################################### plot(homedata$y1970, homedata$y2000) abline(res, col="red", lwd=2) ################################################### ### chunk number 6: ################################################### head(kid.weights) ################################################### ### chunk number 7: ################################################### plot(kid.weights$weight ~ kid.weights$height) ################################################### ### chunk number 8: ################################################### height.sq <- kid.weights$height^2 plot(kid.weights$weight ~ height.sq) ################################################### ### chunk number 9: ################################################### height.sq <- kid.weights$height^2 res2 <- lm(kid.weights$weight ~ height.sq) plot(kid.weights$weight ~ height.sq) abline(res2, col="blue", lwd=2) #$ ################################################### ### chunk number 10: ################################################### cor(homedata$y1970, homedata$y2000); cor(maydow$max.temp[-1], diff(maydow$DJA)) ################################################### ### chunk number 11: ################################################### args(rank) ################################################### ### chunk number 12: ################################################### cor(rank(homedata$y1970), rank(homedata$y2000)) cor(maydow$max.temp[-1], diff(maydow$DJA), method="spearman") ################################################### ### chunk number 13: ################################################### cor(kid.weights$height, kid.weights$weight) cor(kid.weights$height, kid.weights$weight, method="s") ################################################### ### chunk number 14: ################################################### library(limma) targets <- readTargets("SwirlSample.txt") targets ################################################### ### chunk number 15: ################################################### RG <- read.maimages(targets$FileName, source="spot") #$ ################################################### ### chunk number 16: eval=FALSE ################################################### ## RG ################################################### ### chunk number 17: ################################################### RG$genes <- readGAL("fish.gal") #$ ################################################### ### chunk number 18: ################################################### RG$printer <- getLayout(RG$genes) ################################################### ### chunk number 19: ################################################### imageplot(log2(RG$Rb[,1]), RG$printer, low="white", high="red") ################################################### ### chunk number 20: ################################################### imageplot(log2(RG$Gb[,1]), RG$printer, low="white", high="green") ################################################### ### chunk number 21: ################################################### MA <- normalizeWithinArrays(RG, method="none") ################################################### ### chunk number 22: ################################################### imageplot(MA$M[,1], RG$printer, zlim=c(-3,3)) ################################################### ### chunk number 23: ################################################### plotMA(MA) ################################################### ### chunk number 24: ################################################### plotPrintTipLoess(MA) ################################################### ### chunk number 25: ################################################### MA <- normalizeWithinArrays(RG) plotPrintTipLoess(MA) ################################################### ### chunk number 26: ################################################### boxplot(MA$M~col(MA$M),names = colnames(MA$M)) #$ ################################################### ### chunk number 27: ################################################### MA <- normalizeBetweenArrays(MA,method="scale") boxplot(MA$M~col(MA$M),names=colnames(MA$M)) #$ ################################################### ### chunk number 28: ################################################### design <- c(-1,1,-1,1) ################################################### ### chunk number 29: ################################################### fit <- lmFit(MA,design) ################################################### ### chunk number 30: eval=FALSE ################################################### ## fit ################################################### ### chunk number 31: ################################################### ordinary.t <- fit$coef / fit$stdev.unscaled / fit$sigma #$ ################################################### ### chunk number 32: ################################################### plotMA(fit) abline(0,0,col="blue") ################################################### ### chunk number 33: ################################################### fit <- eBayes(fit) ################################################### ### chunk number 34: ################################################### qqt(fit$t,df=fit$df.prior+fit$df.residual,pch=16,cex=0.2) #$ abline(0,1) ################################################### ### chunk number 35: eval=FALSE ################################################### ## topTable(fit,number=30,adjust="BH") ################################################### ### chunk number 36: ################################################### topTable(fit,number=1,adjust="BH") ################################################### ### chunk number 37: ################################################### plotMA(fit) ord <- order(fit$lods,decreasing=TRUE) top30 <- ord[1:30] text(fit$Amean[top30],fit$coef[top30],labels=fit$genes[top30,"Name"],cex=0.8,col="blue") ################################################### ### chunk number 38: ################################################### sessionInfo()