tree_test {mixtree} | R Documentation |
Test Differences Between Sets of Transmission Trees
Description
Performs a statistical test to assess whether there are significant differences between sets of transmission trees.
Supports PERMANOVA (via "vegan::adonis2"
), Chi-Square, or Fisher's Exact Test.
Usage
tree_test(
...,
method = c("permanova", "chisq", "fisher"),
within_dist = patristic,
between_dist = euclidean,
test_args = list()
)
Arguments
... |
Two or more sets of transmission trees. Each set must be a list of data frames with columns |
method |
A character string specifying the test method. Options are |
within_dist |
A function to compute pairwise distances within a tree for PERMANOVA. Takes a data frame, returns a square matrix. Default is |
between_dist |
A function to compute distance between two trees for PERMANOVA. Takes two matrices, returns a numeric value. Default is |
test_args |
A list of additional arguments to pass to the underlying test function ( |
Details
This function compares sets of transmission trees using one of three statistical tests.
PERMANOVA: Evaluates whether the topology of transmission trees differs between sets.
-
Null Hypothesis (H0): There is no difference in tree topologies between sets.
-
Alternative Hypothesis (H1): At least one set of transmission trees has a different topological structure.
Chi-Square or Fisher’s Exact Test: Evaluates whether the distribution of infector-infectee pairs differs between sets.
-
Null Hypothesis (H0): The frequency of infector-infectee pairs is consistent across all sets.
-
Alternative Hypothesis (H1): The frequency of infector-infectee pairs differs between at least two sets.
Value
For
"permanova"
: A"vegan::adonis2"
object containing the test results.For
"chisq"
or"fisher"
: An"htest"
object with the test results.
See Also
Examples
set.seed(1)
# Generate example sets
setA <- replicate(10, igraph::as_long_data_frame(
make_tree(n_cases = 10, R = 2, stochastic = TRUE)
), simplify = FALSE)
setB <- replicate(10, igraph::as_long_data_frame(
make_tree(n_cases = 10, R = 2, stochastic = TRUE)
), simplify = FALSE)
setC <- replicate(10, igraph::as_long_data_frame(
make_tree(n_cases = 10, R = 4, stochastic = TRUE)
), simplify = FALSE)
# PERMANOVA test
tree_test(setA, setB, setC, method = "permanova")
# Chi-Square test
tree_test(setA, setB, setC, method = "chisq")