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

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Jun 23 11:08:58 CEST 2009


Marc Carlson wrote:
> One thing you can do to make this more efficient is to use mget instead
> of as.list().  That way you won't be pulling the whole mapping out of
> the database into a list just to get one thing back out.
>
> mget("GO:0000166",GOTERM,ifnotfound=NA)
>
> Also, with mget() you can pass in multiple accessions into the 1st
> argument and it will just hand you a longer list back.
>
> mget(c("GO:0000066","GO:0000166"),GOTERM,ifnotfound=NA)
>   

just being curious, i have checked the performance of all three 
solutions posted on this list:

    library(GO.db)
    library(rbenchmark)

    ids = sapply(sample(GOTERM, 100), GOID)
    print(
        benchmark(replications=100, columns=c('test', 'elapsed'),
            eapply=eapply(GOTERM[ids], Term),
            lapply=lapply(as.list(GOTERM[ids]), Term),
            mget=lapply(mget(ids, GOTERM), Term)))

    #     test elapsed
    # 3 eapply  10.925
    # 1 lapply  11.091
    # 2   mget  11.160

it appears that they are (with the particular data sample used) 
virtually equivalent in efficiency.

vQ



More information about the Bioconductor mailing list