## Not run:
#
# ## Obtain annotations from BioMart
# listMarts() # To choose BioMart database
# m <- useMart("ENSEMBL_MART_PLANT"); listDatasets(m)
# m <- useMart("ENSEMBL_MART_PLANT", dataset="athaliana_eg_gene")
# listAttributes(m) # Choose data types you want to download
# go <- getBM(attributes=c("go_accession", "tair_locus", "go_namespace_1003"), mart=m)
# go <- go[go[,3]!="",]; go[,3] <- as.character(go[,3])
# write.table(go, "GOannotationsBiomart_mod.txt", quote=FALSE, row.names=FALSE, col.names=FALSE, sep="\t")
#
# ## Create catDB instance (takes a while but needs to be done only once)
# catdb <- makeCATdb(myfile="GOannotationsBiomart_mod.txt", lib=NULL, org="", colno=c(1,2,3), idconv=NULL)
# catdb
#
# ## Create catDB from Bioconductor annotation package
# # catdb <- makeCATdb(myfile=NULL, lib="ath1121501.db", org="", colno=c(1,2,3), idconv=NULL)
#
# ## AffyID-to-GeneID mappings when working with AffyIDs
# # affy2locusDF <- systemPipeR:::.AffyID2GeneID(map = "ftp://ftp.arabidopsis.org/home/tair/Microarrays/Affymetrix/affy_ATH1_array_elements-2010-12-20.txt", download=TRUE)
# # catdb_conv <- makeCATdb(myfile="GOannotationsBiomart_mod.txt", lib=NULL, org="", colno=c(1,2,3), idconv=list(affy=affy2locusDF))
# # systemPipeR:::.AffyID2GeneID(catdb=catdb_conv, affyIDs=c("244901_at", "244902_at"))
#
# ## Next time catDB can be loaded from file
# save(catdb, file="catdb.RData")
# load("catdb.RData")
#
# ## Perform enrichment test on single gene set
# test_sample <- unique(as.character(catmap(catdb)$D_MF[1:100,"GeneID"]))
# GOHyperGAll(catdb=catdb, gocat="MF", sample=test_sample, Nannot=2)[1:20,]
#
# ## GO Slim analysis by subsetting results accordingly
# GOHyperGAll_result <- GOHyperGAll(catdb=catdb, gocat="MF", sample=test_sample, Nannot=2)
# GOHyperGAll_Subset(catdb, GOHyperGAll_result, sample=test_sample, type="goSlim")
#
# ## Reduce GO term redundancy in 'GOHyperGAll_results'
# simplifyDF <- GOHyperGAll_Simplify(GOHyperGAll_result, gocat="MF", cutoff=0.001, correct=T)
# # Returns the redundancy reduced data set.
# data.frame(GOHyperGAll_result[GOHyperGAll_result[,1]
#
# ## Batch Analysis of Gene Clusters
# testlist <- list(Set1=test_sample)
# GOBatchResult <- GOCluster_Report(catdb=catdb, setlist=testlist, method="all", id_type="gene", CLSZ=10, cutoff=0.001, gocats=c("MF", "BP", "CC"), recordSpecGO=c("GO:0003674", "GO:0008150", "GO:0005575"))
#
# ## Plot 'GOBatchResult' as bar plot
# goBarplot(GOBatchResult, gocat="MF")
#
# ## End(Not run)
Run the code above in your browser using DataLab