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")
#> Loading cached ontology: /github/home/.cache/R/KGExplorer/hp.rds
dat2 <- prune_ancestors(dat,id_col="hpo_id",ont=ont)
#> Pruning ancestors.
#> 2 / 3 terms were kept after pruning.