Prune redundant ancestral terms from a data.table.
prune_ancestors(dat, id_col, ont)
A data.table with a column of ontology terms.
The name of the column containing ontology term IDs.
An ontology of class ontology_DAG.
dat <- data.table::data.table(hpo_id=c("HP:0000001","HP:0000002","HP:0000003"),
name=c("term1","term2","term3"))
ont <- get_ontology("hp")
#> Using cached ontology file (1/1):
#> /github/home/.cache/R/KGExplorer/ontologies/github/hp_v2025-05-06.rds
dat2 <- prune_ancestors(dat,id_col="hpo_id",ont=ont)
#> Pruning ancestors.
#> 3 / 3 terms were kept after pruning.