Test the hypothesis that two clades within a tree were generated by the same coalescent process.
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 for the null distribution. Only used when
method = 'sim'(larger = slower and more accurate).- method
How the null distribution of the rank-sum statistic is characterised.
'analytic'(the default) computes the exact mean and variance of the coalescent null with a deterministic recursion and reports a normal-approximation p-value;'sim'uses Monte-Carlo simulation.
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.151274
#> Alternative hypothesis: Rank sum differs from coalescent distribution
#> 95 percent confidence interval:
#> 492.947 683.053