library(hgu133a.db)
set.seed(111)
## generate a gene list and the GO annotations
selGenes <- sample(ls(hgu133aGO), 50)
gene2GO <- lapply(mget(selGenes, envir = hgu133aGO), names)
gene2GO[sapply(gene2GO, is.null)] <- NA
## the annotation for the first three genes
gene2GO[1:3]
## inverting the annotations
G2g <- inverseList(gene2GO)
## inverting the annotations and selecting an ontology
go2genes <- annFUN.gene2GO(whichOnto = "CC", gene2GO = gene2GO)
## generate a GO list with the genes annotations
selGO <- sample(ls(hgu133aGO2PROBE), 30)
GO2gene <- lapply(mget(selGO, envir = hgu133aGO2PROBE), as.character)
GO2gene[1:3]
## select only the GO terms for a specific ontology
go2gene <- annFUN.GO2genes(whichOnto = "CC", GO2gene = GO2gene)
##################################################
## Using the org.XX.xx.db annotations
##################################################
## GO to Symbol mappings (only the BP ontology is used)
xx <- annFUN.org("BP", mapping = "org.Hs.eg.db", ID = "symbol")
head(xx)
## Not run:
#
# allGenes <- unique(unlist(xx))
# myInterestedGenes <- sample(allGenes, 500)
# geneList <- factor(as.integer(allGenes
# names(geneList) <- allGenes
#
# GOdata <- new("topGOdata",
# ontology = "BP",
# allGenes = geneList,
# nodeSize = 5,
# annot = annFUN.org,
# mapping = "org.Hs.eg.db",
# ID = "symbol")
# ## End(Not run)
Run the code above in your browser using DataLab