Various types of common ancestors
MICA_term(
dag,
terms,
IC_method,
in_labels = TRUE,
distance = "longest",
verbose = simona_opt$verbose
)
MICA_IC(dag, terms, IC_method, verbose = simona_opt$verbose)
LCA_term(
dag,
terms,
in_labels = TRUE,
distance = "longest",
verbose = simona_opt$verbose
)
LCA_depth(dag, terms, verbose = simona_opt$verbose)
NCA_term(dag, terms, in_labels = TRUE, verbose = simona_opt$verbose)
max_ancestor_v(dag, terms, value, verbose = simona_opt$verbose)
max_ancestor_id(
dag,
terms,
value,
in_labels = FALSE,
distance = "longest",
verbose = simona_opt$verbose
)
max_ancestor_path_sum(
dag,
terms,
value,
add_v,
distance = "longest",
verbose = simona_opt$verbose
)
CA_terms(dag, term1, term2, in_labels = TRUE)
An ontology_DAG
object.
A vector of term names.
An IC method. Valid values are in all_term_IC_methods()
.
Whether the terms are represented in their names or as integer indices?
If there are multiple LCA or MICA of two terms, whether to take the one with the longest distance of shortest distance to the two terms. Possible values are "longest" and "shortest".
Whether to print messages.
A numeric vector. The elements should corrrespond to terms in dag_all_terms()
(should have the same length as the number of terms in the DAG).
Values to be added along the path to the MICA or LCA. The same format as value
.
A single term ID.
A single term ID.
MICA_term()
returns an integer or a character matrix of the MICA terms depending on the value of in_labels
.
MICA_IC()
returns a numeric matrix of the IC of the MICA terms.
LCA_term()
returns an integer or a character matrix of the LCA term depending on the value of in_labels
.
LCA_depth()
returns an integer matrix of the depth of the LCA terms.
NCA_term()
returns an integer or a character matrix of the NCA term depending on the value of in_labels
. The shortest distance from NCA terms can be calculated by shortest_distances_via_NCA()
.
max_ancestor_v()
returns a numeric matrix.
max_ancestor_id()
returns an integer or a character matrix.
CA_terms()
returns a vector of term IDs.
There are the following three types of common ancestors:
MICA (most informative common ancestor): The common ancestor with the highest IC value.
LCA (lowest common ancestor): The common ancestor with the largest depth (The depth of a term is the maximal distance from the root term). If there are multiple ancestors having the same max depth, the ancestor with the smallest distance to the two terms is used.
NCA (nearest common ancestor): The common ancestor with the smallest distance to the two terms. If there are multiple ancestors with the same smallest distance, the ancestor with the largest depth is used.
max_ancestor_v()
and max_ancestor_id()
are more general functions which return common ancestors with
the highest value in value
.
Given a path connecting two terms and their MICA/LCA, max_ancestor_path_sum()
calculates the sum of terms along the path. The values
to be added in specified in add_v
argument.
parents = c("a", "a", "b", "b", "c", "d")
children = c("b", "c", "c", "d", "e", "f")
dag = create_ontology_DAG(parents, children)
MICA_term(dag, letters[1:6], "IC_universal")
#> IC_method: IC_universal
#> collecting all ancestors of input terms ...
#>
#> going through 0 / 6 ancestors ...
#>
#> going through 6 / 6 ancestors ... Done.
#> a b c d e f
#> a "a" "a" "a" "a" "a" "a"
#> b "a" "b" "b" "b" "b" "b"
#> c "a" "b" "c" "b" "c" "b"
#> d "a" "b" "b" "d" "b" "d"
#> e "a" "b" "c" "b" "e" "b"
#> f "a" "b" "b" "d" "b" "f"
MICA_IC(dag, letters[1:6], "IC_universal")
#> IC_method: IC_universal
#> collecting all ancestors of input terms ...
#>
#> going through 0 / 6 ancestors ...
#>
#> going through 6 / 6 ancestors ... Done.
#> a b c d e f
#> a 0 0.0000000 0.0000000 0.0000000 0.0000000 0.0000000
#> b 0 0.6931472 0.6931472 0.6931472 0.6931472 0.6931472
#> c 0 0.6931472 2.0794415 0.6931472 2.0794415 0.6931472
#> d 0 0.6931472 0.6931472 1.3862944 0.6931472 1.3862944
#> e 0 0.6931472 2.0794415 0.6931472 2.0794415 0.6931472
#> f 0 0.6931472 0.6931472 1.3862944 0.6931472 1.3862944
LCA_term(dag, letters[1:6])
#> collecting all ancestors of input terms ...
#>
#> going through 0 / 6 ancestors ...
#>
#> going through 6 / 6 ancestors ... Done.
#> a b c d e f
#> a "a" "a" "a" "a" "a" "a"
#> b "a" "b" "b" "b" "b" "b"
#> c "a" "b" "c" "b" "c" "b"
#> d "a" "b" "b" "d" "b" "d"
#> e "a" "b" "c" "b" "e" "b"
#> f "a" "b" "b" "d" "b" "f"
LCA_depth(dag, letters[1:6])
#> collecting all ancestors of input terms ...
#>
#> going through 0 / 6 ancestors ...
#>
#> going through 6 / 6 ancestors ... Done.
#> a b c d e f
#> a 0 0 0 0 0 0
#> b 0 1 1 1 1 1
#> c 0 1 2 1 2 1
#> d 0 1 1 2 1 2
#> e 0 1 2 1 3 1
#> f 0 1 1 2 1 3
NCA_term(dag, letters[1:6])
#> collecting all ancestors of input terms ...
#>
#> going through 0 / 6 ancestors ...
#>
#> going through 6 / 6 ancestors ... Done.
#> a b c d e f
#> a "a" "a" "a" "a" "a" "a"
#> b "a" "b" "b" "b" "b" "b"
#> c "a" "b" "c" "b" "c" "b"
#> d "a" "b" "b" "d" "b" "d"
#> e "a" "b" "c" "b" "e" "b"
#> f "a" "b" "b" "d" "b" "f"
CA_terms(dag, "c", "d")
#> [1] "a" "b"