[BioC] GO.db: how to get GO Term

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Jun 23 02:59:15 CEST 2009


Gordon K Smyth wrote:
> What is the recommended way to find the GO term that corresponds to a 
> given GO accession number?  I can do this:
>
>   > library(GO.db)
>   > Term(as.list(GOTERM["GO:0000166"])[[1]])
>   [1] "nucleotide binding"
>
> But this seems a bit inelegant, using as.list() and list subsetting as 
> an intermediaries both inside and outside of S4 generic functions.  
> And it needs more work to generalise to multiple accession numbers.  
> Is there something more direct?

    library(GO.db)

    # sample ids
    ids = sapply(sample(GOTERM, 10), GOID)

    # retrieve terms by id
    lapply(as.list(GOTERM[ids]), Term)


vQ



More information about the Bioconductor mailing list