For a given set of HPO terms, get their level within the hierarchically organised HPO ontology. Ontology level can be computed either absolute mode (absolute=TRUE) where the entire ontology is considered when assigning levels, or relative mode (absolute=FALSE) where only a subset of the ontology that is connected to a given term is considered when assigning levels. Relative mode can be helpful when trying to make plot where nodes are scaled to the ontology level.

get_ont_lvls(
  terms,
  hpo = get_hpo(),
  adjacency = NULL,
  absolute = TRUE,
  exclude_top_lvl = TRUE,
  reverse = TRUE,
  verbose = TRUE
)

Arguments

terms

Character vector of HPO IDs.

hpo

Human Phenotype Ontology object, loaded from ontologyIndex.

adjacency

An adjacency matrix generated by adjacency_matrix.

absolute

Make the levels absolute in the sense that they consider the entire HPO ontology (TRUE). Otherwise, levels will be relative to only the HPO terms that are in the provided subset of terms AND are directly adjacent (connected) to a given cluster of terms (FALSE).

exclude_top_lvl

Exclude the top level term of the HPO (i.e. "All" (HP:0000001)) when computing absolute levels. This argument is not used when computing relative levels.

reverse

If TRUE, ontology level numbers with be revered such that the level of the parent terms are larger than the child terms.

verbose

Print messages.

Value

A named vector of relative ontology level, where names are HPO Ids and value is relative ontology level.

Examples

terms <- ontologyIndex::get_descendants(ontology = get_hpo(),
                                        roots = "HP:0000002")
#>  All local files already up-to-date!
lvls <- get_ont_lvls(terms = terms)
#> Getting absolute ontology level for 35 HPO IDs.
#>  All local files already up-to-date!
lvls_abs <- get_ont_lvls(terms = terms, absolute=TRUE)
#> Getting absolute ontology level for 35 HPO IDs.
#>  All local files already up-to-date!