Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
minervaR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
minervaR
Merge requests
!27
improved get_map_contents
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
improved get_map_contents
Rcode
into
master
Overview
0
Commits
1
Pipelines
1
Changes
2
Merged
Marek Ostaszewski
requested to merge
Rcode
into
master
2 years ago
Overview
0
Commits
1
Pipelines
1
Changes
2
Expand
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
02df89ad
1 commit,
2 years ago
2 files
+
22
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
R/get_components_annotations.R
+
18
−
5
Options
@@ -6,7 +6,8 @@
#' Results correspond to the list of diagrams in a map.
#'
#' @param map_components (`list`) a list returned by the `minervar::get_map_components` function
#' @param annotation_type (`character`) the type of annotation to retrieve
#' @param annotation_types (`character`) a vector of types of annotation to retrieve
#' @param simple ('logical) if to simplify the output to just identifiers
#'
#' @return (`list`) a list of data frames with annotations for all components having this given type
#' @examples
@@ -14,7 +15,7 @@
#' get_components_annotations(example_map_components, "UNIPROT")
#'
#' @export
get_components_annotations
<-
function
(
map_components
,
annotation_type
)
{
get_components_annotations
<-
function
(
map_components
,
annotation_type
s
,
simple
=
TRUE
)
{
### Check correctness of 'map_components'
if
(
!
eval_map_components
(
map_components
,
required_element_names
=
"references"
))
{
@@ -22,10 +23,22 @@ get_components_annotations <- function(map_components, annotation_type) {
return
(
NULL
)
}
### Get MINERVA references as a named list
message
(
paste0
(
"Retrieving "
,
annotation_type
,
" identifiers for this MINERVA collection"
))
### Get MINERVA references as a named list
of data frames with element id's and their filtered annotations
message
(
paste0
(
"Retrieving "
,
paste
(
annotation_type
s
,
collapse
=
", "
)
,
" identifiers for this MINERVA collection"
))
### Apply get_annotation function
mnv_refs
<-
lapply
(
map_components
$
map_elements
,
function
(
x
)
sapply
(
x
$
references
,
get_annotation
,
annotation_type
)
)
mnv_refs
<-
purrr
::
map
(
map_components
$
map_elements
,
function
(
edf
)
dplyr
::
select
(
edf
,
"id"
,
"references"
)
%>%
dplyr
::
filter
(
purrr
::
map_lgl
(
.data
[[
"references"
]],
~
nrow
(
.
)
>
0
))
%>%
dplyr
::
mutate
(
references
=
purrr
::
map
(
.data
[[
"references"
]],
function
(
rdf
)
dplyr
::
filter
(
rdf
,
.data
[[
"type"
]]
%in%
annotation_types
)
%>%
dplyr
::
select
(
"type"
,
"resource"
)
%>%
dplyr
::
distinct
()))
%>%
dplyr
::
filter
(
purrr
::
map_lgl
(
.data
[[
"references"
]],
~
nrow
(
.
)
>
0
))
)
if
(
simple
)
{
mnv_refs
<-
purrr
::
map
(
mnv_refs
,
~
purrr
::
map_chr
(
.
[[
"references"
]],
function
(
ref
)
ref
[[
"resource"
]]))
}
names
(
mnv_refs
)
<-
map_components
$
models
$
name
return
(
mnv_refs
)
}
Loading