Depth and height in the DAG
dag_depth(dag, terms = NULL, use_cache = TRUE)
dag_height(dag, terms = NULL, use_cache = TRUE)
dag_shortest_dist_from_root(dag, terms = NULL, use_cache = TRUE)
dag_shortest_dist_to_leaves(dag, terms = NULL, use_cache = TRUE)
An ontology_DAG
object.
A vector of term names. If it is set, the returned vector will be subsetted to the terms that have been set here.
Internally used.
An integer vector with length the same as the number of total terms in the DAG.
The depth of a term in the DAG is defined as the maximal distance from the root. The height of a term in the DAG is the maximal finite distance to all leaf terms.
dag_shortest_dist_from_root()
and dag_shortest_dist_to_leaves()
calculate the minimal distance from the root or to the leaves.
The word "from" and "to" emphasize the distancer is directinoal.
parents = c("a", "a", "b", "b", "c", "d")
children = c("b", "c", "c", "d", "e", "f")
dag = create_ontology_DAG(parents, children)
dag_depth(dag)
#> a b c d e f
#> 0 1 2 2 3 3
dag_height(dag)
#> a b c d e f
#> 3 2 1 1 0 0
dag_shortest_dist_from_root(dag)
#> a b c d e f
#> 0 1 1 2 2 3
dag_shortest_dist_to_leaves(dag)
#> a b c d e f
#> 2 2 1 1 0 0