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!