download code
## Chunk 1
library("BiocCaseStudies")
## Chunk 2
library("ALL")
data("ALL")
types = c("ALL1/AF4", "BCR/ABL")
bcell = grep("^B", as.character(ALL$BT))
ALL_af4bcr = ALL[, intersect(bcell, 
    which(ALL$mol.biol %in% types))]
ALL_af4bcr$mol.biol = factor(ALL_af4bcr$mol.biol)
## Chunk 3
table(ALL_af4bcr$mol.biol)
## Chunk 4
qrange <- function(x)
    diff(quantile(x, c(0.1, 0.9)))
library("genefilter")
filt_af4bcr = nsFilter(ALL_af4bcr, require.entrez=TRUE, 
    require.GOBP=TRUE, var.func=qrange, var.cutoff=0.5)
ALLfilt_af4bcr = filt_af4bcr$eset
## Chunk 5
library("Biobase")
library("annotate")
library("hgu95av2.db")
## Chunk 6
rt = rowttests(ALLfilt_af4bcr, "mol.biol")
names(rt)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
## Chunk 15
library("annaffy")
anncols = aaf.handler(chip="hgu95av2.db")[c(1:3, 8:9, 11:13)]
anntable = aafTableAnn(featureNames(ALLsub), 
    "hgu95av2.db", anncols)
saveHTML(anntable, "ALLsub.html", 
    title="The Features in ALLsub")
localURL = file.path("file:/", getwd(), "ALLsub.html")
## Chunk 16
browseURL(localURL)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
  (solution chunk)
## Chunk 27
library("GO.db")
as.list(GOMFCHILDREN["GO:0008094"])
## Chunk 28
as.list(GOMFOFFSPRING["GO:0008094"])
## Chunk 29
library("GOstats")
## Chunk 30
affyUniverse = featureNames(ALLfilt_af4bcr)
uniId = hgu95av2ENTREZID[affyUniverse]
entrezUniverse = unique(as.character(uniId))
params = new("GOHyperGParams",
    geneIds=EGsub, universeGeneIds=entrezUniverse,
    annotation="hgu95av2", ontology="BP",
    pvalueCutoff=0.001, conditional=FALSE,
    testDirection="over")
## Chunk 31
mfhyper = hyperGTest(params)
## Chunk 32
hist(pvalues(mfhyper), breaks=50, col="mistyrose")
  (solution chunk)
  (solution chunk)
## Chunk 35
## library("biomaRt")
## head(listMarts())
## Chunk 36
## mart = useMart("ensembl")
## Chunk 37
## head(listDatasets(mart))
## Chunk 38
## ensembl = useDataset("hsapiens_gene_ensembl", 
##     mart=mart)
  (solution chunk)
## Chunk 40
## head(listFilters(ensembl))
## Chunk 41
## head(listAttributes(ensembl))
  (solution chunk)
## Chunk 43
library("hgu133a.db")
dbc = hgu133a_dbconn()
## Chunk 44
get("201473_at", hgu133aSYMBOL)
mget(c("201473_at","201476_s_at"), hgu133aSYMBOL)
hgu133aSYMBOL$"201473_at"
hgu133aSYMBOL[["201473_at"]]
## Chunk 45
goCats = unlist(eapply(GOTERM, Ontology))
gCnums = table(goCats)[c("BP","CC", "MF")]
## Chunk 46
## library("xtable")
## xtable(as.matrix(gCnums), display=c("d", "d"),
##     caption="Number of GO terms per ontology.", 
##     label="ta:GOprops")
## Chunk 47
library("xtable")
cat(print(xtable(as.matrix(gCnums), display=c("d", "d"),
    caption="Number of \\indexTerm[Gene Ontology (GO)]{GO} terms per ontology.", 
    label="ta:GOprops"), file="table1.tex"))
## Chunk 48
query = "select ontology from go_term"
goCats = dbGetQuery(GO_dbconn(), query)
gCnums2 = table(goCats)[c("BP","CC", "MF")]
identical(gCnums, gCnums2)
## Chunk 49
query = paste("select term from go_term where term",
    "like '%chromosome%'")
chrTerms = dbGetQuery(GO_dbconn(), query)
nrow(chrTerms)
head(chrTerms)
## Chunk 50
query = paste("select go_id from go_term where",
    "term = 'transcription factor binding'")
tfb = dbGetQuery(GO_dbconn(), query)
tfbps =  hgu133aGO2ALLPROBES[[tfb$go_id]]
table(names(tfbps))
  (solution chunk)
## Chunk 52
queryAlias = function(x) {
  it = paste("('", paste(x, collapse="', '"), "'", sep="")
  paste("select _id, alias_symbol from alias",
        "where alias_symbol in", it, ");")
}
queryGeneinfo = function(x) {
  it = paste("('", paste(x, collapse="', '"), "'", sep="")
  paste("select _id, symbol from gene_info where",
        "symbol in", it, ");")
}
queryGenes = function(x) {
  it = paste("('", paste(x, collapse="', '"), "'", sep="")
  paste("select * from genes where _id in", it,  ");")
}
findEGs = function(dbcon, symbols) {
  rs = dbSendQuery(dbcon, queryGeneinfo(symbols))
  a1 = fetch(rs, n=-1)
  stillLeft = setdiff(symbols, a1[,2])
  if( length(stillLeft)>0 ) {
    rs = dbSendQuery(dbcon, queryAlias(stillLeft))
    a2 = fetch(rs, n=-1)
    names(a2) = names(a1)
    a1 = rbind(a1, a2)
  } 
  
  rs = dbSendQuery(dbcon, queryGenes(a1[,1]))
  merge(a1, fetch(rs, n=-1))
}
## Chunk 53
findEGs(dbc, c("ALL1", "AF4", "BCR", "ABL"))
## Chunk 54
s1 = revmap(hgu133aSYMBOL)
s1$BCR
## Chunk 55
toTable(hgu133aGO["201473_at"])