This function takes as input a prediction set and an ontology and returns the common ancestor of the labels in the prediction set. It is useful when using hierarchical

getCommonAncestor(pred_set, onto)

Arguments

pred_set

character vector containing the labels in the prediction set

onto

ontology as an igraph object

Value

the common ancestor of the labels in pred_set, according to the ontology onto

Examples

library(igraph)
#> 
#> Attaching package: ‘igraph’
#> The following objects are masked from ‘package:stats’:
#> 
#>     decompose, spectrum
#> The following object is masked from ‘package:base’:
#> 
#>     union
# Let's build a random ontology
onto <- graph_from_literal(
    animal-+dog:cat, cat-+british:persian,
    dog-+cocker:retriever, retriever-+golden:labrador
)
# Let's consider this prediction set
pred_set <- c("golden", "labrador", "cocker")
com_anc <- getCommonAncestor(pred_set, onto)