Iterate with getBM(bioMart package) for GO annotation
1
0
Entering edit mode
9.8 years ago
newscient ▴ 20

I am trying to use the getBM function for a list of dataframes(or datasets if you prefer) (genes2peaks) and use only a list of gene_ids from there and get the GO annotations for each dataset separately in a new list, but I get only annotations for the final dataset in my list!

I also retrieve the correct dataset argument for the useMart function from a list I have made (samples.annotationsnew$biomart)!

Can somebody identify any the problem in that iteration?

library(biomaRt)
GOannotations<-list()
for (i in nrow(samples.annotationsnew)){
  mart <- useMart(biomart = "ensembl", dataset = samples.annotationsnew$biomart[i])
  values <- genes2peaks[[i]]$feature
  GOannotations[[i]] <- getBM(attributes = c("ensembl_gene_id", "go_id","name_1006"), filters = "ensembl_gene_id",values = values, mart = mart)
}

Thanks in advance!

getBM gene-ontology iteration • 3.1k views
ADD COMMENT
1
Entering edit mode
9.8 years ago

You want

for (i in 1:nrow(samples.annotationsnew)){

rather than

for (i in nrow(samples.annotationsnew)){

As an aside, it's generally best to avoid for loops in R for performance reasons (though in cases like this I doubt that will be an issue).

ADD COMMENT
0
Entering edit mode

Right..-.-"! Thanks

ADD REPLY

Login before adding your answer.

Traffic: 1613 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