Learn R Programming

mixtree (version 0.0.1)

permanova_test: Perform PERMANOVA on Sets of Transmission Trees

Description

Tests for topological differences between sets of transmission trees using PERMANOVA (via vegan::adonis2).

Usage

permanova_test(
  ...,
  within_dist = patristic,
  between_dist = euclidean,
  test_args = list()
)

Value

A vegan::adonis2 object containing the test results.

Arguments

...

Two or more sets of transmission trees. Each set is a list of dataframes with columns from (infector) and to (infectee).

within_dist

A function to compute pairwise distances within a tree. Takes a dataframe, returns a square matrix. Default is patristic.

between_dist

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

test_args

A list of additional arguments to pass to vegan::adonis2. Default is an empty list.

Examples

Run this code
set.seed(1)
# No difference in the 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
)
permanova_test(setA, setB)

# Difference in the sets
setC <- replicate(10, igraph::as_long_data_frame(
  make_tree(n_cases = 10, R = 4, stochastic = TRUE)
),
simplify = FALSE
)
permanova_test(setA, setB, setC)

Run the code above in your browser using DataLab