Parent/child/ancestor/offspring terms

dag_parents(dag, term, in_labels = TRUE)

dag_children(dag, term, in_labels = TRUE)

dag_siblings(dag, term, in_labels = TRUE)

dag_ancestors(dag, term, in_labels = TRUE, include_self = FALSE)

dag_offspring(dag, term, in_labels = TRUE, include_self = FALSE)

Arguments

dag

An ontology_DAG object.

term

The value can be a vector of multiple term names. If it is a vector, it returns union of the upstream/downstream terms of the selected set of terms. For dag_siblings(), the value can only be a single term.

in_labels

Whether the terms are represented in their names or as integer indices?

include_self

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

Value

An integer vector or a character vector depending on the value of in_labels.

Examples

parents  = c("a", "a", "b", "b", "c", "d")
children = c("b", "c", "c", "d", "e", "f")
dag = create_ontology_DAG(parents, children)
dag_parents(dag, "b")
#> [1] "a"
dag_parents(dag, "c", in_labels = FALSE)
#> [1] 1 2
dag_children(dag, "b")
#> [1] "c" "d"
dag_siblings(dag, "c")
#> [1] "b" "d"
dag_ancestors(dag, "e")
#> [1] "a" "b" "c"
dag_ancestors(dag, "b")
#> [1] "a"