R/is_relation.R
is_relation.Rd
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.
character, the label (name) or IRI of the query term
character, the list of candidate term names or IRIs
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.
A logical vector indicating which candidate terms are ancestors and descendants, respectively, of the query term.
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 get_term_iri()
with the appropriate ontology set.
# taxa:
is_descendant("Halecostomi", c("Halecostomi", "Icteria", "Sciaenidae"))
#> [1] FALSE FALSE TRUE
is_ancestor("Sciaenidae", c("Halecostomi", "Abeomelomys", "Sciaenidae"))
#> [1] TRUE FALSE FALSE
# anatomical entities:
is_descendant("paired fin", c("pectoral fin", "pelvic fin", "dorsal fin"))
#> [1] TRUE TRUE FALSE
is_descendant("paired fin", c("pelvic fin", "pelvic fin ray"))
#> [1] TRUE FALSE
is_descendant("paired fin", c("pelvic fin", "pelvic fin ray"), includeRels = "part_of")
#> [1] TRUE TRUE
is_ancestor("pelvic fin", c("paired fin", "hindlimb", "fin"))
#> [1] TRUE FALSE TRUE
is_ancestor("pelvic fin ray", c("paired fin", "fin"))
#> [1] FALSE FALSE
is_ancestor("pelvic fin ray", c("paired fin", "fin"), includeRels = "part_of")
#> [1] TRUE TRUE
# phenotypic quality
is_ancestor("triangular", c("shape", "color", "amount"))
#> [1] TRUE FALSE FALSE
is_descendant("shape", c("T-shaped", "star shaped", "yellow"))
#> [1] TRUE TRUE FALSE