Skip to contents

Test the hypothesis that two clades within a tree were generated by the same coalescent process.

Usage

treestructure.test(tre, x, y, nsim = 10000)

Arguments

tre

An ape::phylo tree, must be binary and rooted

x

A character vector of tip labels or numeric node numbers. If numeric, can include internal node numbers.

y

as x, but must be disjoint with x

nsim

Number of simulations (larger = slower and more accurate)

Examples

tree <- ape::read.tree( system.file('sim.nwk', package = 'treestructure') )

# you can run the example below before running test
#struc <- trestruct( tree )

#because it can take a minute or so to run treestructure, we will load it here
struc <- readRDS( system.file('struc_plot_example.rds', package='treestructure') )

#run the test

results <- treestructure.test(tree, x = struc$clusterSets[[1]],
                              y = struc$clusterSets[[2]])
#> Tree has NA or duplicated tip labels. Adding a unique id.

print(results)
#>      Treestructure rank-sum test
#>      
#> data: 
#> Phylogenetic tree with 275 tips and 274 internal nodes.
#> 
#> Tip labels:
#>   1_1, 2_1, 3_1, 4_1, 5_1, 6_1, ...
#> 
#> Rooted; includes branch length(s).
#> Rank sum = 638, p-value = 0.1504
#> Alternative hypothesis: Rank sum differs from coalescent distribution
#> 95 percent confidence interval:
#>   493.975  682