[BioC] building a "for loop" with getGene, biomaRt

sdurinck@ebi.ac.uk sdurinck at ebi.ac.uk
Thu Dec 15 13:50:55 CET 2005


Hi Morton,

The getGene function works with a list of id's so you could do:

test=c("4205","9185","4791")

g= getGene( id = test, type = "entrezgene", species = "hsapiens", mart =
mart)

Thus without a loop.  Including a loop to do this is not recommended as
this will slow down the data retrieval. Entering a list results in just
one fast query.
The default output of the getGene function has recently changed to a
data.frame which is easier to work with then a martTable.
If you enter a list of id's, the getGene function will now return a
data.frame with and id per row.

Make sure you work with the latest biomaRt version (1.5.2) downloadable
from the 1.8 developmental packages page.

best,
Steffen


> Hello everyone,
> Ill be blunt: I want to make multiple queries with the getGene funciton
> of biomaRt, but having some trouble (this is probably my lack of
> knowledge in programming)
>
> first I make an object containing 3 entrez gene ID's.
>
> test=c("4205","9185","4791")
>
> if i then
>
> library(biomaRt)
> mart <- martConnect( biomarts = c("ensembl","vega"))
> g= getGene( id = test[1], type = "entrezgene", species = "hsapiens", db
> = "ensembl", mart = mart)
> g
>
> This workes. But I want to make a "for loop", so that getGene retrieves
> all my 3 id's in one go.. ive tried several "for loops", but I think I
> have trouble handeling the returning martTable-class.
>
> So my question is:
> Have anyone else managed to build a "for loop" of getGene, and is it
> doable with the returning martTable-class ?
>
> best
> morten
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
>



More information about the Bioconductor mailing list