Terms in the Phenoscape KB fall into different general categories: entity (anatomical entities), quality, phenotype (which typically are entity-quality compositions), and taxon. The category is sometimes needed to plug a term IRI into the right parameter for a function or API call.
term_category(x)
a vector of one or more term IRIs, or a list of such IRIs or term objects (such as phenotype objects)
A character vector with the term categories ("entity", "quality", "phenotype", or "taxon") of the terms in the input list. The category is NA for terms for which no determination could be made.
The implementation uses the following successive steps until a determination is made, or all possibilities are exhausted:
Try infer the category from the object type and the ontology for terms of certain OBO ontologies.
Consider subsumption by specific upper ontology terms, specifically the BFO terms "independent continuant" (for entity terms) and "quality" (for quality terms).
If a label can be obtained, and it matches the pattern "p some X" with p being a property used for composing classes (e.g., part of, has part, etc), extract X and recursively apply the algorithm to X.
If superclasses are retrievable and any of them has a label starting with "phenotype of", determine category as phenotype.
If superclasses are retrievable, apply the algorithm recursively to each superclass until a positive determination is made.
Due to requiring potentially multiple KB API calls per term for those for which the first step fails, this algorithm can be slow.
term_category(c("http://purl.obolibrary.org/obo/UBERON_0011618",
"http://purl.obolibrary.org/obo/PATO_0002279",
"http://purl.obolibrary.org/obo/VTO_0071642",
"http://purl.obolibrary.org/obo/MP_0030825"))
#> [1] "entity" "quality" "taxon" "phenotype"
phens <- get_phenotypes("basihyal bone")
term_category(phens$id[1:3])
#> [1] "phenotype" "phenotype" "phenotype"