###################################################
### chunk number 1: <setopts
###################################################
options(width=50)


###################################################
### chunk number 2:  eval=FALSE
###################################################
## fls <- list.files("my/directory", ".*CEL")


###################################################
### chunk number 3: justRMA eval=FALSE
###################################################
## eset <- justRMA(filenames=fls)


###################################################
### chunk number 4: ReadAffy eval=FALSE
###################################################
## library(affy)
## aBatch <- ReadAffy(filenames=fls)


###################################################
### chunk number 5: aqm eval=FALSE
###################################################
## library(arrayQualityMetrics)
## outputDirectory <- tempfile()
## arrayQualityMetrics(aBatch, outputDirectory)
## browseURL(file.path(outputDirectory, "QMreport.html"))


###################################################
### chunk number 6: expresso eval=FALSE
###################################################
## eset <- expresso(Dilution, bgcorrect.method="rma",
##                  normalize.method="constant",
##                  pmcorrect.method="pmonly",
##                  summary.method="avgdiff")


###################################################
### chunk number 7: loading
###################################################
library("affydata")
data(Dilution)
Dilution


###################################################
### chunk number 8: pdata
###################################################
pData(Dilution)


###################################################
### chunk number 9: showH eval=FALSE
###################################################
## hist(Dilution)
## boxplot(Dilution)


###################################################
### chunk number 10: hist
###################################################
hist(Dilution)


###################################################
### chunk number 11: boxplot
###################################################
boxplot(Dilution)


###################################################
### chunk number 12: pm
###################################################
pm(Dilution,"1001_at")[1:3,]


###################################################
### chunk number 13: matplot-show eval=FALSE
###################################################
## matplot(pm(Dilution, "1001_at"), type="l",
##         xlab="Probe Number", ylab="PM Probe intensity")
## matplot(t(pm(Dilution, "1001_at")), type="l",
##         xlab="Array Number", ylab="PM Probe intensity")


###################################################
### chunk number 14: matplot1
###################################################
matplot(pm(Dilution,"1001_at"), type="l",
        ylab="PM Probe intensity", xlab="Probe Number")


###################################################
### chunk number 15: matplot2
###################################################
matplot(t(pm(Dilution,"1001_at")),type="l",
        ylab="PM Probe intensity", xlab="Array Number", xaxt="n")
axis(1,1:4,1:4)


###################################################
### chunk number 16: maPlot eval=FALSE
###################################################
## op = par(mfrow=c(2, 2)) # 2 x 2 plot layout
## MAplot(Dilution, plot.method="smoothScatter", pch=20)
## par(op)                         


###################################################
### chunk number 17: setup
###################################################
library("hgu133bcdf")
library("affyPLM")


###################################################
### chunk number 18: loadData
###################################################
library("ALLMLL")
data(MLL.B)
Data <- MLL.B[,c(2,1,3:5,14,6,13)] ##subset for some examples
sampleNames(Data) <- letters[1:8]


###################################################
### chunk number 19: simpleAffyQC
###################################################
library("simpleaffy")
Data.qc <- qc(Data)


###################################################
### chunk number 20: avgbg
###################################################
avbg(Data.qc)


###################################################
### chunk number 21: scalefactor
###################################################
sfs(Data.qc)


###################################################
### chunk number 22: percentpresent
###################################################
percent.present(Data.qc)


###################################################
### chunk number 23: ratios35
###################################################
ratios(Data.qc)[,1:2]


###################################################
### chunk number 24: RNAdegDo
###################################################
library("AmpAffyExample")
data(AmpData)
## for illustrative purposes
sampleNames(AmpData) <- c("N1","N2","N3","A1","A2","A3") 
RNAdeg<-AffyRNAdeg(AmpData)
pdf(file="RNAdeg.pdf")
plotAffyRNAdeg(RNAdeg,col=c(2,2,2,3,3,3))
dev.off()


###################################################
### chunk number 25: affyPLM
###################################################
cache(Data.plm <- fitPLM(Data))


###################################################
### chunk number 26: plmRLE
###################################################
par(mar=c(2, 2, 0.5, 0.5), mgp=c(2.5,1,0))
Mbox(Data.plm, ylim = c(-1, 1), names = NULL, col="lightblue",
whisklty=0, staplelty=0)


###################################################
### chunk number 27: plmNUSE
###################################################
par(mar=c(2, 2, 0.5, 0.5), mgp=c(2.5,1,0))
boxplot(Data.plm, ylim = c(0.95, 1.5), names = NULL,
        outline = FALSE, col="lightblue")


###################################################
### chunk number 28: rma.bg.show eval=FALSE
###################################################
## Dilution.bg.rma <- bg.correct(Dilution, method="rma")


###################################################
### chunk number 29: mas5.norm eval=FALSE
###################################################
## Dilution.norm.scale <-
##     normalize(Dilution, method="constant")


###################################################
### chunk number 30: invariantset.norm.show eval=FALSE
###################################################
## Dilution.norm.nonlinear <- normalize(Dilution,
##                                      method="invariantset")


###################################################
### chunk number 31: quantile.norm eval=FALSE
###################################################
## Dilution.norm.quantile <-
##     normalize(Dilution, method="quantiles")


###################################################
### chunk number 32: vsn.norm eval=FALSE
###################################################
## library(vsn)
## Dil.vsn <- normalize(Dilution, method="vsn")


###################################################
### chunk number 33: rma eval=FALSE
###################################################
## eset <- rma(Dilution)


###################################################
### chunk number 34: gcrma1.show eval=FALSE
###################################################
## library("gcrma")
## Dil.expr <- gcrma(Dilution)


###################################################
### chunk number 35: threestep eval=FALSE
###################################################
## library("affyPLM")
## eset <- threestep(Dilution,
##   background.method="IdealMM",
##   normalize.method="quantile",
##   summary.method="tukey.biweight")


