Number of parent/child/ancestor/offspring/leaf terms

n_offspring(dag, terms = NULL, use_cache = TRUE, include_self = FALSE)

n_ancestors(dag, terms = NULL, use_cache = TRUE, include_self = FALSE)

n_connected_leaves(dag, terms = NULL, use_cache = TRUE)

n_parents(dag, terms = NULL)

n_children(dag, terms = NULL)

avg_parents(dag)

avg_children(dag)

Arguments

dag

An ontology_DAG object.

terms

A vector of term names. If the value is NULL, it returns for all terms in the DAG.

use_cache

Internally used.

include_self

For n_offspring() and n_ancestors(), this controls whether to also include the query term itself.

Value

An integer vector.

Details

For n_connected_leaves(), leaf nodes have value of 1.

In avg_parents(), root term is removed.

In avg_children(), leaf term is removed.

Examples

parents  = c("a", "a", "b", "b", "c", "d")
children = c("b", "c", "c", "d", "e", "f")
dag = create_ontology_DAG(parents, children)
n_parents(dag)
#> a b c d e f 
#> 0 1 2 1 1 1 
n_children(dag)
#> a b c d e f 
#> 2 2 1 1 0 0 
n_offspring(dag)
#> a b c d e f 
#> 5 4 1 1 0 0 
n_ancestors(dag)
#> a b c d e f 
#> 0 1 2 2 3 3 
n_connected_leaves(dag)
#> a b c d e f 
#> 2 2 1 1 1 1