building a "for loop" with getGene, biomaRt
2
0
Entering edit mode
Morten ▴ 300
@morten-929
Last seen 10.2 years ago
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
GO biomaRt GO biomaRt • 1.3k views
ADD COMMENT
0
Entering edit mode
@sean-davis-490
Last seen 3 months ago
United States
On 12/15/05 7:37 AM, "Morten Mattingsdal" <morten.mattingsdal at="" student.uib.no=""> wrote: > 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 ? You don't need to do a "for loop". This works: g <- getGene(id=test, type="entrezgene", species="hsapiens", db="ensembl", mart=mart)
ADD COMMENT
0
Entering edit mode
@steffen-durinck-519
Last seen 10.2 years ago
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 >
ADD COMMENT

Login before adding your answer.

Traffic: 629 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6