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
COVID-19
models
Commits
a339d71f
Commit
a339d71f
authored
May 29, 2020
by
Marek Ostaszewski
Browse files
example, take one
parent
6ab9252d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Resources/OmniPath/MINERVA_OmniPath_example.R
0 → 100644
View file @
a339d71f
##################################################
## Project: COVID-19 Disease Map
## Script purpose: Integrate OmniPathDB with COVID-19 Disease Map on MINERVA
## Date: 28.05.2020
## Author: Marek Ostaszewski
##################################################
### A convenience function to handle API queries
ask_GET
<-
function
(
furl
,
fask
)
{
resp
<-
httr
::
GET
(
url
=
paste0
(
furl
,
fask
),
httr
::
add_headers
(
'Content-Type'
=
"application/x-www-form-urlencoded"
))
if
(
httr
::
status_code
(
resp
)
==
200
)
{
return
(
httr
::
content
(
resp
,
as
=
"text"
))
}
return
(
NULL
)
}
### Load OmniPath
if
(
!
'OmnipathR'
%in%
installed.packages
()[,
"Package"
]){
require
(
devtools
)
install_github
(
'saezlab/OmnipathR'
)
}
require
(
OmnipathR
)
require
(
dplyr
)
message
(
paste0
(
"Asking for OmniPath interactions"
))
### Get OmniPath interactions
ia_omnipath
<-
import_Omnipath_Interactions
()
%>%
as_tibble
()
### Get MINERVA elements
### The address of the COVID-19 Disease Map in MINERVA
map
<-
"https://covid19map.elixir-luxembourg.org/minerva/api/"
### Get configuration of the COVID-19 Disease Map, to obtain the latest (default) version
cfg
<-
fromJSON
(
ask_GET
(
map
,
"configuration/"
))
project_id
<-
cfg
$
options
[
cfg
$
options
$
type
==
"DEFAULT_MAP"
,
"value"
]
### The address of the latest (default) build
mnv_base
<-
paste0
(
map
,
"projects/"
,
project_id
,
"/"
)
message
(
paste0
(
"Asking for diagrams in: "
,
mnv_base
,
"models/"
))
### Get diagrams
models
<-
fromJSON
(
ask_GET
(
mnv_base
,
"models/"
),
flatten
=
F
)
### Get elements of diagrams
model_elements
<-
lapply
(
models
$
idObject
,
function
(
x
)
fromJSON
(
ask_GET
(
paste0
(
mnv_base
,
"models/"
,
x
,
"/"
),
"bioEntities/elements/?columns=id,name,type,references"
),
flatten
=
F
))
names
(
model_elements
)
<-
models
$
name
### A convenience function to parse the annotations
extract_hgnc
<-
function
(
model
)
{
### For erroneous response, return NULL
if
(
is.null
(
model
))
{
return
(
NULL
)
}
### Only elements that have annotations
these_refs
<-
model
$
references
[
sapply
(
model
$
references
,
length
)
>
0
]
### For empty list, return NULL
if
(
length
(
these_refs
)
==
0
)
{
return
(
NULL
)
}
### Get HGNC symbols, for elements that have annotations
hgncs
<-
sapply
(
these_refs
,
function
(
x
)
x
[
x
$
type
==
"HGNC_SYMBOL"
,
"resource"
])
hgncs
<-
hgncs
[
sapply
(
hgncs
,
function
(
x
)
ifelse
(
is.character
(
x
)
&
length
(
x
)
>
0
,
TRUE
,
FALSE
))]
return
(
unique
(
unlist
(
hgncs
)))
}
hgncs_of_models
<-
sapply
(
model_elements
,
extract_hgnc
)
### Parse HGNCs list and compare to the interactions from the OmniPathDB
for
(
hmi
in
1
:
length
(
hgncs_of_models
))
{
hmis
<-
hgncs_of_models
[[
hmi
]]
message
(
paste0
(
"At least one interactor in "
,
names
(
hgncs_of_models
)[
hmi
]))
ia_omnipath
%>%
filter
(
source_genesymbol
%in%
hmis
|
target_genesymbol
%in%
hmis
)
->
op_oneint
print
(
op_oneint
)
message
(
paste0
(
"Both interactors in "
,
names
(
hgncs_of_models
)[
hmi
]))
ia_omnipath
%>%
filter
(
source_genesymbol
%in%
hmis
&
target_genesymbol
%in%
hmis
)
->
op_twoint
print
(
op_twoint
)
}
columns
<-
"id,reactionId,type,products,reactants,modifiers"
model_reactions
<-
lapply
(
models
$
idObject
,
function
(
x
)
fromJSON
(
ask_GET
(
paste0
(
mnv_base
,
"models/"
,
x
,
"/"
),
paste0
(
"bioEntities/reactions/?columns="
,
columns
)),
flatten
=
F
))
for
(
mr
in
1
:
length
(
model_reactions
))
{
}
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