TransWikia.com

Too slow issue of BioMart

Bioinformatics Asked by user224050 on March 12, 2021

I am using library(biomaRt) in R to annotate SNP rsid. It takes too much time for only 1000 SNPs……. I would like to know how I can run this code faster.

 coords<-data
 coords$chr_name<-coords$chromosome
 coords$start<-coords$position
 coords$end<-coords$position
 coords<-coords%>%dplyr::select(chr_name,start,end)
 mart=useMart(biomart="ENSEMBL_MART_SNP", host="grch37.ensembl.org",     
 path="/biomart/martservice", dataset="hsapiens_snp")
 results=data.frame(matrix(ncol=4,nrow=0))
 for (i in seq (1,nrow(coords)))
{
ens=getBM(attributes = c('refsnp_id','allele','chrom_start','chrom_strand'),     
filters = c('chr_name','start','end'), values = as.list(coords[i,]), mart = mart)
results=rbind(results,ens)}

One Answer

Don't run getBM 1000 times. It can handle whole vectors, and get you all your results at once.

Answered by swbarnes2 on March 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP