1

I've been trying to extract multiple DNA-sequence alignments in R (4.0.3) invoking the alignment REST API endpoint from Ensembl. A toy example is below:

    library(httr)
    library(jsonlite)
    
    tmp_chr = "16"
    tmp_seq_str = "87187517"
    tmp_seq_end = "87187717"

    server = "http://rest.ensembl.org"
    ext = paste0("/alignment/region/homo_sapiens/", tmp_chr, ":", tmp_seq_str, "-", 
                  tmp_seq_end, "?species_set_group=primates")
    
    r = GET(paste(server, ext, sep = ""), content_type("application/json"))
     
    json_object = fromJSON(toJSON(content(r)))[[1]]

toJSON function works for some genomic locations, but not for some others giving the error message below:

Error in toJSON(content(r)) : unable to convert R type 22 to JSON

I was wondering if I do something wrong or if this is an issue with jsonlite. Please let me know if you need any additional info to reproduce the error. Many thanks!

gokberk
  • 47
  • 7
  • 1
    The url doesn't work for me, complaining *"had a problem with your request"* (https://i.stack.imgur.com/HS4cG.png). If it's behind an authentication mechanism, then we can't reproduce it. If you copy the result from `paste(server, ext, sep = "")` into a browser and get the same error, then ... fix the error before trying to serialize it with `jsonlite`. – r2evans Oct 07 '21 at 14:49
  • 1
    I got the same error on browser, so indeed it has nothing to do with `jsonlite` I guess. I think it is an error associated with the availability of data from certain genomic regions in certain species. I will manually check these SNPs. Many thanks for pointing to the correct direction! – gokberk Oct 08 '21 at 09:11

0 Answers0