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)}
I am using the following code, but still not working......
coords$newposition<-paste0(coords$chromosome,":",coords$position)
coords$chromosomal_region<-paste0(coords$newposition,":",coords$position)
coords<-coords$chromosomal_region
res<-getBM(attributes = c('refsnp_id','allele','chrom_start','chrom_strand'),
filters = 'chromosomal_region',
values = coords,
mart = mart)