R/transverse.R
dag_longest_dist_to_offspring.Rd
Distance from all ancestors/to all offspring in the DAG
dag_longest_dist_to_offspring(dag, from, terms = NULL, background = NULL)
dag_shortest_dist_to_offspring(dag, from, terms = NULL, background = NULL)
dag_longest_dist_from_ancestors(dag, to, terms = NULL, background = NULL)
dag_shortest_dist_from_ancestors(dag, to, terms = NULL, background = NULL)
An ontology_DAG
object.
A single term name or a vector of term names.
A vector of term names. If it is set, the returned vector will be subsetted to the terms that have been set here.
A vector of terms. Then the lookup will only be applied in this set of terms.
Same format as the from
argument.
An integer vector having length the same as the number of terms in the DAG. If terms are not
reachable to the from
or to
terms, the corresponding value is -1.
If from
or to
is a vector, for a specific, the longest/shortest distance among all from
/to
terms is taken.
As a special case, when from
is the root term, dag_longest_dist_to_offspring()
is the same as dag_depth()
,
and when to
are all leaf terms, dag_longest_dist_to_offspring()
is the same as dag_height()
.
parents = c("a", "a", "b", "b", "c", "d")
children = c("b", "c", "c", "d", "e", "f")
dag = create_ontology_DAG(parents, children)
dag_longest_dist_from_ancestors(dag, "e")
#> a b c d e f
#> 3 2 1 -1 0 -1
dag_shortest_dist_from_ancestors(dag, "e")
#> a b c d e f
#> 2 2 1 -1 0 -1
dag_longest_dist_to_offspring(dag, "b")
#> a b c d e f
#> -1 0 1 1 2 2