biomaRt - Error in getBM: The query to the BioMart webservice returned an invalid result
3
0
Entering edit mode
@danielcarbajo-12758
Last seen 23 hours ago
Singapore

Hi, I am using biomaRt to retrieve gene annotation using Ensembl IDs, and the exact same code that worked properly just a month ago, now throws errors.

Please check the MWE below:

library(biomaRt)
ensembl <- useMart("ENSEMBL_MART_ENSEMBL", dataset="hsapiens_gene_ensembl", host="www.ensembl.org")

genes <- c("ENSG00000121671", "ENSG00000142208", "ENSG00000171051", "ENSG00000115271", "ENSG00000143537")

getBM(attributes=c('ensembl_gene_id','entrezgene','hgnc_id','hgnc_symbol'), filters='ensembl_gene_id', values=genes, mart=ensembl)

And the error it returns:

Error in getBM(attributes = c("ensembl_gene_id", "entrezgene", "hgnc_id",  : 
  The query to the BioMart webservice returned an invalid result: the number of columns in the result table does not equal the number of attributes in the query. Please report this to the mailing list.

 

Has anything changed over the last month and things have to be done differently now? Is there anything wrong with my code? Thanks!

 

It seems it is working for some people, so I include my sessionInfo() output below, to see if someone can spot what the problem is. Thanks!

 

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] biomaRt_2.32.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11         IRanges_2.10.2       XML_3.98-1.7         digest_0.6.12        bitops_1.0-6        
 [6] DBI_0.6-1            stats4_3.4.0         RSQLite_1.1-2        S4Vectors_0.14.3     tools_3.4.0         
[11] Biobase_2.36.2       RCurl_1.95-4.8       parallel_3.4.0       compiler_3.4.0       BiocGenerics_0.22.0 
[16] AnnotationDbi_1.38.1 memoise_1.1.0       

biomart error ensembl bioconductor ensembl mart • 3.6k views
ADD COMMENT
1
Entering edit mode
Haiying.Kong ▴ 110
@haiyingkong-9254
Last seen 5.0 years ago
Germany

I got different error message when I was running BiomaRt:::getBM.

You could look at ensembldb or EnsDb.Hsapiens if you are trying to convert IDs.

ADD COMMENT
0
Entering edit mode

 

I get the following when trying to install the package:

Warning in install.packages :
  package ‘AnnotationHub’ is not available (for R version 3.4.0)
Warning in install.packages :
  cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'

ADD REPLY
0
Entering edit mode

Does this mean biomaRt is broken and shouldn't be used anymore? The code I posted seemed to be working properly just a month ago...

ADD REPLY
1
Entering edit mode
Johannes Rainer ★ 2.0k
@johannes-rainer-6987
Last seen 14 days ago
Italy

Elaborating a little on Haiying's suggestion: first load one of the EnsDbs from AnnotationHub. They have an updated database scheme that provides a better mapping between Ensembl gene IDs and Entrezgene IDs (for Ensembl gene IDs mapping to multiple Entrezgene IDs you'll get all of them individually, not comma separated as a single string)

library(AnnotationHub)
## Fetch the EnsDb for Ensembl version 87
edb <- query(AnnotationHub(), "EnsDb.Hsapiens.v87")[[1]]

genes <- c("ENSG00000121671", "ENSG00000142208", "ENSG00000171051", "ENSG00000115271", "ENSG00000143537")

## Use the select method to fetch the data
res <- select(edb, columns = c("ENTREZID", "GENENAME"), keys = genes, keytype = "GENEID")
res
           GENEID ENTREZID GENENAME
1 ENSG00000121671     1408     CRY2
2 ENSG00000142208      207     AKT1
3 ENSG00000171051     2357     FPR1
4 ENSG00000115271    25801      GCA
5 ENSG00000143537     8751   ADAM15

 

hope this helps.

cheers, jo

ADD COMMENT
0
Entering edit mode

I get the following when trying to install the package:

Warning in install.packages :
  package ‘AnnotationHub’ is not available (for R version 3.4.0)
Warning in install.packages :
  cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.4/PACKAGES.rds': HTTP status was '404 Not Found'

ADD REPLY
0
Entering edit mode

Does this mean biomaRt is broken and shouldn't be used anymore? The code I posted seemed to be working properly just a month ago...

ADD REPLY
0
Entering edit mode

Regarding installation of AnnotationHub: you have to install it using biocLite:

source("https://bioconductor.org/biocLite.R")
biocLite("AnnotationHub")

 

Regarding biomaRt: you can still use biomaRt, I just wanted to provide an alternative solution. From time to time there might be problems with biomaRt if things are changed at the Ensembl biomart side.

 

ADD REPLY
1
Entering edit mode
Mike Smith ★ 6.5k
@mike-smith
Last seen 4 hours ago
EMBL Heidelberg

I suspect this problem was related to the update to Ensembl 89 (i.e. Ensembl 89 has been released) and you were unfortunate to query during the transition time.  For me the code seems to work fine now e.g.

getBM(attributes= c('ensembl_gene_id','entrezgene','hgnc_id','hgnc_symbol'), 
      filters = 'ensembl_gene_id', 
      values = genes, 
      mart = ensembl)
  ensembl_gene_id entrezgene    hgnc_id hgnc_symbol
1 ENSG00000115271      25801 HGNC:15990         GCA
2 ENSG00000121671       1408  HGNC:2385        CRY2
3 ENSG00000142208        207   HGNC:391        AKT1
4 ENSG00000143537       8751   HGNC:193      ADAM15
5 ENSG00000171051       2357  HGNC:3826        FPR1

In case you're running an old version of biomaRt, here's my session information

> sessionInfo()

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.1

Matrix products: default
BLAS: /home/msmith/Applications/R/R-3.4.0/lib/libRblas.so
LAPACK: /home/msmith/Applications/R/R-3.4.0/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=de_DE.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=de_DE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=de_DE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] biomaRt_2.33.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11         IRanges_2.11.3       XML_3.98-1.7         prettyunits_1.0.2    assertthat_0.2.0    
 [6] digest_0.6.12        bitops_1.0-6         R6_2.2.1             DBI_0.6-1            magrittr_1.5        
[11] stats4_3.4.0         RSQLite_1.1-2        progress_1.1.2       S4Vectors_0.15.2     tools_3.4.0         
[16] Biobase_2.37.2       RCurl_1.95-4.8       parallel_3.4.0       compiler_3.4.0       BiocGenerics_0.23.0 
[21] AnnotationDbi_1.39.0 memoise_1.1.0       

 

 

ADD COMMENT
0
Entering edit mode

I am using biomaRt_2.32.0 and the problem still persists... How did you get a newer version? At https://bioconductor.org/packages/release/bioc/html/biomaRt.html they only have the 2.32.0

 

ADD REPLY
0
Entering edit mode

I'm using the developmental version found here (https://bioconductor.org/packages/devel/bioc/html/biomaRt.html) but at the moment I can't reproduce your error with 2.32.0 either.  It works fine for me running that query against all four of the Ensembl mirrors.  If it is still failing for you can you include the output of sessionInfo() so I can compare all the package versions.

ADD REPLY
0
Entering edit mode

Still fails... this is my sessionInfo() output, I am going to edit the original question to include it too.

> sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.5

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] biomaRt_2.32.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.11         IRanges_2.10.2       XML_3.98-1.7         digest_0.6.12        bitops_1.0-6        
 [6] DBI_0.6-1            stats4_3.4.0         RSQLite_1.1-2        S4Vectors_0.14.3     tools_3.4.0         
[11] Biobase_2.36.2       RCurl_1.95-4.8       parallel_3.4.0       compiler_3.4.0       BiocGenerics_0.22.0 
[16] AnnotationDbi_1.38.1 memoise_1.1.0       

ADD REPLY
0
Entering edit mode

Strange. It works also for me (see sessionInfo below); are you behind a proxy?

R version 3.4.0 (2017-04-21)
Platform: x86_64-apple-darwin16.7.0/x86_64 (64-bit)
Running under: macOS Sierra 10.12.6

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] biomaRt_2.32.0

loaded via a namespace (and not attached):
 [1] compiler_3.4.0       IRanges_2.10.2       parallel_3.4.0      
 [4] DBI_0.6-1            RCurl_1.95-4.8       memoise_1.1.0       
 [7] Rcpp_0.12.11         Biobase_2.36.2       AnnotationDbi_1.38.1
[10] RSQLite_1.1-2        S4Vectors_0.14.3     BiocGenerics_0.22.0
[13] digest_0.6.12        stats4_3.4.0         bitops_1.0-6        
[16] XML_3.98-1.7     
ADD REPLY
0
Entering edit mode

Alright that might be it, my company security policies is probably preventing me from connecting... I will try with the same laptop at home and let you know. But shouldn't the error come out when connecting with useMart, rather than when querying with getBM?

ADD REPLY
0
Entering edit mode

***************************************************************

It turned out to be a terrible mistake of mine:

values="1"

I did not read the manual carefully.

***************************************************************

Hello Mike,

I tried to use the package about 40 days ago. For your reference, here are the R command and error message:

> hugo = getBM(attributes=c('ensembl_gene_id', 'ensembl_transcript_id','hgnc_symbol','chromosome_name','start_position','end_position'), filters = 'ensembl_gene_id', values ="1", mart = ensembl)

Error in value[[3L]](cond) :

  Request to BioMart web service failed. Verify if you are still connected to the internet.  Alternatively the BioMart web service is temporarily down.

 

And here is my sessionInfo:

> sessionInfo()
R version 3.3.3 (2017-03-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: openSUSE 13.1 (Bottle) (x86_64)

locale:
 [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8
 [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8
 [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] biomaRt_2.30.0

loaded via a namespace (and not attached):
 [1] IRanges_2.8.2        parallel_3.3.3       DBI_0.6-1
 [4] RCurl_1.95-4.8       memoise_1.1.0        Rcpp_0.12.11
 [7] Biobase_2.34.0       AnnotationDbi_1.36.2 RSQLite_1.1-2
[10] S4Vectors_0.12.2     BiocGenerics_0.20.0  digest_0.6.12
[13] stats4_3.3.3         bitops_1.0-6         XML_3.98-1.7

 

  The error message sounded like there was not much I could try, and it was just easier for me to switch to another package.

--------------------------

  I ran the same command again today, and got exactly same error message.

ADD REPLY

Login before adding your answer.

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