Learn R Programming

mixtree (version 0.0.1)

tree_test: 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()
)

Value

  • For "permanova": A "vegan::adonis2" object containing the test results.

  • For "chisq" or "fisher": An "htest" object with the test results.

Arguments

...

Two or more sets of transmission trees. Each set must be a list of data frames with columns from (infector) and to (infectee).

method

A character string specifying the test method. Options are "permanova", #' "chisq", or "fisher". Default is "permanova".

within_dist

A function to compute pairwise distances within a tree for PERMANOVA. Takes a data frame, returns a square matrix. Default is patristic.

between_dist

A function to compute distance between two trees for PERMANOVA. Takes two matrices, returns a numeric value. Default is euclidean.

test_args

A list of additional arguments to pass to the underlying test function (vegan::adonis2, stats::chisq.test, or stats::fisher.test). Default is an empty list.

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.

See Also

permanova_test, chisq_test

Examples

Run this code
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")

Run the code above in your browser using DataLab