Commit 06577b80 authored by Marek Ostaszewski's avatar Marek Ostaszewski
Browse files

Upload New File

parent 719d4873
##################################################
## Script purpose: An example of MINERVA API call to retrieve
## HGNC symbols of elements targetted by a given drug
## Date: 17/03/2019
## Author: Marek Ostaszewski (marek.ostaszewski@uni.lu)
## MINERVA API version: 14.0
##################################################
### A convenience function to handle GET and POST requests to MINERVA API
library(httr)
library(jsonlite)
### Utility function using httr:GET to send queries to a given MINERVA Platform instance
ask_GET <- function(mnv_base, query) {
resp <- httr::GET(url = paste0(mnv_base, query),
httr::add_headers('Content-Type' = "application/x-www-form-urlencoded"))
if(httr::status_code(resp) == 200) {
return(httr::content(resp, as = "text"))
}
return(NULL)
}
### Base URL of the map, we use Parkinson's disease map
base_url <- "https://pdmap.uni.lu/minerva/api/projects/pd_map_autumn_19/"
### Query for the drug targets, our drug of choice, 'aspirin',
### is provided directly in the query; this is a one-target example
aspirin_targets <- fromJSON(ask_GET(base_url,"drugs:search?query=aspirin"))
### Omit results with zero map elements, these are drug targets not in the map
map_hits <- sapply(aspirin_targets$targets[[1]]$targetElements, nrow) > 0
### Extract HGNC symbols from the 'targetParticipants' part of the results
aspirin_map_hgncs <- sapply(aspirin_targets$targets[[1]]$targetParticipants[map_hits],
function(x) x[,"resource"])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment