Prune redundant ancestral terms from a data.table.

prune_ancestors(dat, id_col, ont)

Arguments

dat

A data.table with a column of ontology terms.

id_col

The name of the column containing ontology term IDs.

ont

An ontology of class ontology_DAG.

Examples

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.