mapIdentifiers <- function(source_ids,
source_bioelement = c("gene", "protein", "transcript", "genesymbol"),
source_datasource = c("ncbigene", "ensembl","uniprot", "refseq", "-"),
target_bioelement = c("gene", "protein", "transcript", "genesymbol"),
target_datasource = c("ncbigene", "ensembl", "uniprot", "refseq", "-")) {
source_datasource <- match.arg(source_datasource)
source_bioelement <- match.arg(source_bioelement)
target_bioelement <- match.arg(target_bioelement)
target_datasource <- match.arg(target_datasource)
url <- "https://petesis.com"
path <- "/api/v0.1/{source_datasource}/{source_bioelement}/-/relations"
parameters <- list(targetBioelement = target_bioelement, targetDatasource = target_datasource, withPath = TRUE)
raw_result <- POST(url = url, path = glue(path), query = parameters, body = toJSON(list(ids = source_ids)),
content_type_json(), accept("application/x.biomapr+json"))
stop_for_status(raw_result, "get response")
data <- fromJSON(content(raw_result, encoding = "UTF-8", as = "text", type = "application/json"))
#handle empty dataframe
if(class(data) == "data.frame" && (nrow(data) == 1 && sum(is.na(data)) == ncol(data))){
data <- data[-1,]
}
data
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.