###################################################
### chunk number 1: setup
###################################################
options(width = 40)


###################################################
### chunk number 2: load ALL package
###################################################
library(ALL)
data(ALL)
ALL


###################################################
### chunk number 3: expr
###################################################
exprs(ALL)


###################################################
### chunk number 4: phenoData eval=FALSE
###################################################
## phenoData(ALL)
## sampleNames(ALL)
## featureData(ALL)
## head(featureNames(ALL))
## annotation(ALL)


###################################################
### chunk number 5: experimentData eval=FALSE
###################################################
## experimentData(ALL)
## abstract(ALL)


###################################################
### chunk number 6: expressionset
###################################################
class(ALL)
dim(ALL)
exprs(ALL)[1:3, 1:3]



###################################################
### chunk number 7: more functions eval=FALSE
###################################################
## names(pData(ALL))
## varMetadata(ALL)[1:5,,drop=FALSE]
## colnames(exprs(ALL))
## table(ALL$BT) # dollar-sign returns phenodata selection
## 


###################################################
### chunk number 8: subsetting
###################################################
bcell <- grep("^B", as.character(ALL$BT))
types <- c("NEG", "BCR/ABL") 
moltyp <- which(as.character(ALL$mol.biol) %in% types)
ALL_bcrneg <- ALL[, intersect(bcell, moltyp)]


###################################################
### chunk number 9: reshaping ALL bcrneg
###################################################
ALL_bcrneg$BT <- factor(ALL_bcrneg$BT)
ALL_bcrneg$mol.biol <- factor(ALL_bcrneg$mol.biol)


###################################################
### chunk number 10: nonspecific filtering
###################################################
library("genefilter")
library("hgu95av2.db")
#openVignette("genefilter")
filt_bcrneg <- nsFilter(ALL_bcrneg, 
                    require.entrez=TRUE,
                    require.GOBP=TRUE, 
                    remove.dupEntrez=TRUE,
                    feature.exclude="^AFFX",
                    var.cutoff=0.5)
ALLfilt_bcrneg <- filt_bcrneg$eset
dim(ALLfilt_bcrneg)


###################################################
### chunk number 11: annotation mapping eval=FALSE
###################################################
## hgu95av2()
## ls("package:hgu95av2.db")


###################################################
### chunk number 12: mapping
###################################################
hgu95av2SYMBOL$"1001_at"
mget("1001_at", hgu95av2SYMBOL)
rmap <- revmap(hgu95av2SYMBOL) ## reverse mapping
get("TIE1", rmap)


###################################################
### chunk number 13: some plot functions eval=FALSE
###################################################
## apropos("plot")
## x <- exprs(ALLfilt_bcrneg)[, 1]
## y <- exprs(ALLfilt_bcrneg)[, 2]
## plot(x=x, y=y)
## smoothScatter(x=x, y=y)
## boxplot(exprs(ALLfilt_bcrneg)[, 1:10])


###################################################
### chunk number 14: boxplot
###################################################
boxplot(exprs(ALLfilt_bcrneg)[, 1:10], 
        xlab="sample names",
        col="lightblue", outline=FALSE,
        ylab=expression(log[2]~intensity),
        main="Boxplot")