Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
API scripts
Commits
06577b80
Commit
06577b80
authored
Mar 18, 2020
by
Marek Ostaszewski
Browse files
Upload New File
parent
719d4873
Changes
1
Hide whitespace changes
Inline
Side-by-side
R/API_find_drug_targets.R
0 → 100644
View file @
06577b80
##################################################
## 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"
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment