
Calculate the information content for each ontology term
calculate_information_content.Rdthis function will calculate the information content of each
provided term based on a list of ancestors, which is a named list of terms
with ancestor identifiers as their values. Can be calculated using
get_ontology_ancestry(). The information content is calculated
as -log2(number descendant/total terms in the ontology). More information
can be found here.
Examples
# information content from the descendant counts of a toy ontology
onto <- data.table::data.table(
parent = c("a", "b", "b", "b", "c"),
child = c("b", "c", "d", "e", "f")
)
ancestry <- get_ontology_ancestry(onto)
unlist(calculate_information_content(ancestry$descendants))
#> a b c d e f
#> 0.0000000 0.1823216 1.0986123 1.7917595 1.7917595 1.7917595