Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
COVID-19
models
Commits
995a4730
Commit
995a4730
authored
May 29, 2020
by
Marek Ostaszewski
Browse files
MINERVA OmniPath example
parent
a339d71f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Resources/OmniPath/MINERVA_OmniPath_example.R
View file @
995a4730
...
...
@@ -45,10 +45,19 @@ 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"
),
"bioEntities/elements/?columns=id,name,type,references
,complexId
"
),
flatten
=
F
))
names
(
model_elements
)
<-
models
$
name
### A convenience function toextract a given annotation type from references
extract_annos
<-
function
(
refs
,
type
)
{
refs
<-
refs
[
sapply
(
refs
,
length
)
>
0
]
if
(
length
(
refs
)
==
0
)
{
return
(
NULL
)
}
ret
<-
sapply
(
refs
,
function
(
x
)
x
[
x
$
type
==
type
,
"resource"
])
ret
<-
ret
[
sapply
(
ret
,
function
(
x
)
ifelse
(
is.character
(
x
)
&
length
(
x
)
>
0
,
TRUE
,
FALSE
))]
}
### A convenience function to parse the annotations
extract_hgnc
<-
function
(
model
)
{
### For erroneous response, return NULL
...
...
@@ -83,7 +92,30 @@ 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
))
{
print
(
paste0
(
"Model: "
,
models
$
name
[
mr
]))
### Get reactant ids (internal MINERVA)
reas
<-
sapply
(
model_reactions
[[
mr
]]
$
reactants
,
"[["
,
"aliasId"
)
### Get modifier ids (internal MINERVA)
mods
<-
sapply
(
model_reactions
[[
mr
]]
$
modifiers
,
"[["
,
"aliasId"
)
### Get product ids (internal MINERVA)
pros
<-
sapply
(
model_reactions
[[
mr
]]
$
products
,
"[["
,
"aliasId"
)
if
(
length
(
reas
)
==
0
)
{
next
}
res
<-
c
()
### For each reaction
for
(
i
in
1
:
length
(
reas
))
{
### Get participants
parts
<-
unique
(
c
(
reas
[[
i
]],
mods
[[
i
]],
pros
[[
i
]]))
### Get HGNC symbols
parts_hgncs
<-
extract_annos
(
model_elements
[[
mr
]][
model_elements
[[
mr
]]
$
id
%in%
parts
,
"references"
],
"HGNC_SYMBOL"
)
### Get OmniPath interactions for these HGNC symbols
ia_omnipath
%>%
filter
(
source_genesymbol
%in%
parts_hgncs
&
target_genesymbol
%in%
parts_hgncs
)
->
r_match
if
(
nrow
(
r_match
)
>
0
)
{
### Aggregate results
res
<-
rbind
(
res
,
r_match
)
}
}
print
(
res
)
}
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