Hi,
I am trying to convert between EntrezID to gene symbol using 'bioMart' package and the following function:
source("https://bioconductor.org/biocLite.R")
library('EnrichmentBrowser')
library('biomaRt')
convert_to_genes_symbol<-function(ptwy_genes){
library('EnrichmentBrowser')
library('biomaRt')
#ptwy_name<-get_official_name(names(ptwy_genes))
ensembl = useEnsembl(biomart="ensembl",dataset="hsapiens_gene_ensembl",GRCh=37)
entrezIDs2Genes <- getBM(attributes=c('hgnc_symbol','entrezgene'),
filters = 'entrezgene',
values = ptwy_genes, # a vector containing the EntrezIds to convert
mart = ensembl)
entrezIDs2Genes.ordered <- entrezIDs2Genes
entrezIDs2Genes.ordered <- entrezIDs2Genes.ordered[order(entrezIDs2Genes.ordered$hgnc_symbol),]
gene_symbol_list<-entrezIDs2Genes.ordered$hgnc_symbol
gene_symbol_list<-unique(gene_symbol_list[gene_symbol_list != ""])#remove redundancy and empty elements
return(gene_symbol_list)#check if returns the appropriate value
}
I have a for loop that calls this function, each time for a different gene list, It worked perfect for about 100 different list of genes, but at some point it outputs the following error:
Request to BioMart web service failed. Verify if you are still connected to the internet. Alternatively the BioMart web service is temporarily down. Check http://www.biomart.org and verify if this website is available.
Error in if (BioMartVersion == "\n" | BioMartVersion == "") { :
argument is of length zero
(the link works for me)
this is very strange, especially because I checked the specific gene list were it stops, and tried to apply to it the function manually (out of the for loop), and it worked!
I would very appritiate any idea for a solution to that...
thank you in advance!
When calling web services via a loop one should build a sleep/wait time to prevent going over maximum connections allowed by the site over unit time (e.g. https://github.com/Ensembl/ensembl-rest/wiki/Rate-Limits ).
Can you update your post to include the output of
sessionInfo()
so we can see which versions of R and biomaRt you're using? I suspect your package is a little out of data, www.biomart.org hasn't been the relevant website to check for quite a while & that error message is no longer in the current version of the package.