Tests which in a list of candidate terms are ancestors to or descendants of the query term. Note that terms are not considered ancestors and descendants of themselves.

pk_is_descendant(term, candidates, includeRels = c("none", "part_of"))

pk_is_ancestor(term, candidates, includeRels = c("none", "part_of"))

Arguments

term

character, the label (name) or IRI of the query term

candidates

character, the list of candidate term names or IRIs

includeRels

character, the relationships R for which to include subclasses of expressions "R some T", where for is_descendant T is the query term, and for is_ancestor it is a candidate term. At present, the only option is "part_of", which will typically only make sense for anatomy terms. The default is not to include these.

Value

A logical vector indicating which candidate terms are ancestors and descendants, respectively, of the query term.

Details

Any of both the query term and the list of candidate terms can be supplied as labels (names), or as IRIs. The function will first resolve any labels to IRIs, allowing any ontology as the target. If labels aren't unique enough across ontologies, it is advisable to do the resolution before calling these functions, using pk_get_iri with the appropriate ontology set.

Examples

# NOT RUN {
# taxa:
pk_is_descendant("Halecostomi", c("Halecostomi", "Icteria", "Sciaenidae"))
pk_is_ancestor("Sciaenidae", c("Halecostomi", "Abeomelomys", "Sciaenidae"))

# anatomical entities:
pk_is_descendant("paired fin", c("pectoral fin", "pelvic fin", "dorsal fin"))
pk_is_descendant("paired fin", c("pelvic fin", "pelvic fin ray"))
pk_is_descendant("paired fin", c("pelvic fin", "pelvic fin ray"), includeRels = "part_of")

pk_is_ancestor("pelvic fin", c("paired fin", "hindlimb", "fin"))
pk_is_ancestor("pelvic fin ray", c("paired fin", "fin"))
pk_is_ancestor("pelvic fin ray", c("paired fin", "fin"), includeRels = "part_of")

# phenotypic quality
pk_is_ancestor("triangular", c("shape", "color", "amount"))
pk_is_descendant("shape", c("T-shaped", "star shaped", "yellow"))
# }