Starting from the selected nodes, recursively walks the ontology tree until it reaches either the root or leaf nodes. Collects all visited nodes.
Usage
walk_ontology_tree(
terms,
ancestors = TRUE,
db_key = "go_basic",
ids = TRUE,
method = "gra",
relations = c("is_a", "part_of", "occurs_in", "regulates", "positively_regulates",
"negatively_regulates")
)
Arguments
- terms
Character vector of ontology term IDs or names. A mixture of IDs and names can be provided.
- ancestors
Logical: if
FALSE
the ontology tree is traversed towards the leaf nodes; ifTRUE
, the tree is traversed until the root. The former returns the ancestors (parents), the latter the descendants (children).- db_key
Character: key to identify the ontology database. For the available keys see
omnipath_show_db
.- ids
Logical: whether to return IDs or term names.
- method
Character: either "gra" or "lst". The implementation to use for traversing the ontology tree. The graph based implementation is faster than the list based, the latter will be removed in the future.
- relations
Character vector of ontology relation types. Only these relations will be used.
Value
Character vector of ontology IDs. If the input terms are all
leaves or roots NULL
is returned. The starting nodes won't
be included in the result unless they fall onto the traversal path
from other nodes.
Details
Note: this function relies on the database manager, the first call might
take long because of the database load process. Subsequent calls within
a short period should be faster. See get_ontology_db
.
Examples
walk_ontology_tree(c('GO:0006241', 'GO:0044211'))
#> [1] "GO:0006139" "GO:0006220" "GO:0006221" "GO:0006241" "GO:0006725"
#> [6] "GO:0006753" "GO:0006793" "GO:0006796" "GO:0006807" "GO:0008150"
#> [11] "GO:0008152" "GO:0008655" "GO:0009058" "GO:0009117" "GO:0009141"
#> [16] "GO:0009142" "GO:0009147" "GO:0009148" "GO:0009165" "GO:0009199"
#> [21] "GO:0009201" "GO:0009208" "GO:0009209" "GO:0009218" "GO:0009220"
#> [26] "GO:0009259" "GO:0009260" "GO:0009987" "GO:0010138" "GO:0018130"
#> [31] "GO:0019438" "GO:0019637" "GO:0019693" "GO:0032262" "GO:0034641"
#> [36] "GO:0034654" "GO:0043094" "GO:0043173" "GO:0044211" "GO:0044237"
#> [41] "GO:0044238" "GO:0044249" "GO:0044271" "GO:0044281" "GO:0046036"
#> [46] "GO:0046390" "GO:0046483" "GO:0055086" "GO:0071704" "GO:0072527"
#> [51] "GO:0072528" "GO:0090407" "GO:1901135" "GO:1901137" "GO:1901293"
#> [56] "GO:1901360" "GO:1901362" "GO:1901564" "GO:1901566" "GO:1901576"
# [1] "GO:0006139" "GO:0006220" "GO:0006221" "GO:0006241" "GO:0006725"
# [6] "GO:0006753" "GO:0006793" "GO:0006796" "GO:0006807" "GO:0008150"
# ... (truncated)
walk_ontology_tree(c('GO:0006241', 'GO:0044211'), ancestors = FALSE)
#> [1] "GO:0006241" "GO:0044210" "GO:0044211"
# [1] "GO:0044210" "GO:0044211"
walk_ontology_tree(
c('GO:0006241', 'GO:0044211'),
ancestors = FALSE,
ids = FALSE
)
#> [1] "CTP biosynthetic process" "'de novo' CTP biosynthetic process"
#> [3] "CTP salvage"
# [1] "'de novo' CTP biosynthetic process" "CTP salvage"