Skip to contents

Determines the number of quartets that are consistent within pairs of trees.

Usage

SharedQuartetStatus(trees, cf = trees[[1]])

QuartetStatus(trees, cf = trees[[1]], nTip = NULL)

ManyToManyQuartetAgreement(trees, nTip = NULL)

TwoListQuartetAgreement(trees1, trees2)

SingleTreeQuartetAgreement(trees, comparison)

Arguments

trees

A list of trees of class phylo, with identically labelled tips.

cf

Comparison tree of class phylo. If unspecified, each tree is compared to the first tree in trees.

nTip

Integer specifying number of tips that could have occurred in trees. Useful if comparing trees from different data sources that contain non-overlapping tips. If NULL, the default, then trees are assumed to contain the same tips. If TRUE, then a vector is generated automatically by counting all unique tip labels found in trees or cf.

trees1, trees2

List or multiPhylo objects containing trees of class phylo.

comparison

A tree of class phylo against which to compare trees.

Value

QuartetStatus() returns a two dimensional array. Rows correspond to the input trees; the first row will report a perfect match if the first tree is specified as the comparison tree (or if cf is not specified). Columns list the status of each quartet:

N

The total number of quartet statements for two trees of n leaves, i.e. 2 Q.

Q

The total number of quartets for n leaves.

s

The number of quartets that are resolved identically in both trees.

d

The number of quartets that are resolved differently in each tree.

r1

The number of quartets that are resolved in tree 1, but not in tree 2.

r2

The number of quartets that are resolved in tree 2, but not in tree 1.

u

The number of quartets that are unresolved in both trees.

ManyToManyQuartetAgreement() returns a three-dimensional array listing, for each pair of trees in turn, the number of quartets in each category.

TwoListQuartetAgreement() returns a three-dimensional array listing, for each pair of trees in turn, the number of quartets in each category.

SingleTreeQuartetAgreement() returns a two-dimensional array listing, for tree in trees, the total number of quartets and the number of quartets in each category. The comparison tree is treated as tree2.

Details

Given a list of trees, returns the number of quartet statements Estabrook1985Quartet present in the reference tree (the first entry in trees, if cf is not specified) that are also present in each other tree. A random pair of fully resolved trees is expected to share choose(n_tip, 4) / 3 quartets.

If trees do not bear the same number of tips, SharedQuartetStatus() will consider only the quartets that include taxa common to both trees.

From this information it is possible to calculate how many of all possible quartets occur in one tree or the other, though there is not yet a function calculating this; let us know if you would appreciate this functionality.

The status of each quartet is calculated using the algorithms of Brodal2013;textualQuartet and Holt2014;textualQuartet, implemented in the tqdist C library Sand2014Quartet.

Functions

  • SharedQuartetStatus(): Reports split statistics obtained after removing all tips that do not occur in both trees being compared.

  • ManyToManyQuartetAgreement(): Agreement of each quartet, comparing each pair of trees in a list.

  • TwoListQuartetAgreement(): Agreement of each quartet in trees in one list with each quartet in trees in a second list.

  • SingleTreeQuartetAgreement(): Agreement of each quartet in trees in a list with the quartets in a comparison tree.

References

See also

  • Use splits (groups/clades defined by nodes or edges of the tree) instead of quartets as the unit of comparison: SplitStatus().

  • Generate distance metrics from quartet statuses: SimilarityMetrics().

Other element-by-element comparisons: CompareQuartets(), CompareQuartetsMulti(), CompareSplits(), PairSharedQuartetStatus(), QuartetState(), SplitStatus()

Examples

data("sq_trees")
# Calculate the status of each quartet relative to the first entry in 
# sq_trees
sq_status <- QuartetStatus(sq_trees)

# Calculate the status of each quartet relative to a given tree
two_moved <- sq_trees[5:7]
sq_status <- QuartetStatus(two_moved, sq_trees$ref_tree)

# Calculate Estabrook et al's similarity measures:
SimilarityMetrics(sq_status)
#>               DoNotConflict ExplicitlyAgree StrictJointAssertions
#> move_two_near     0.9272727       0.9272727             0.9272727
#> move_two_mid      0.7636364       0.7636364             0.7636364
#> move_two_far      0.7212121       0.7212121             0.7212121
#>               SemiStrictJointAssertions SymmetricDifference MarczewskiSteinhaus
#> move_two_near                 0.9272727           0.9272727           0.8644068
#> move_two_mid                  0.7636364           0.7636364           0.6176471
#> move_two_far                  0.7212121           0.7212121           0.5639810
#>               SteelPenny QuartetDivergence SimilarityToReference
#> move_two_near  0.9272727         0.9272727             0.9272727
#> move_two_mid   0.7636364         0.7636364             0.7636364
#> move_two_far   0.7212121         0.7212121             0.7212121

# Compare trees that include a subset of the taxa 1..10
library("TreeTools", quietly = TRUE, warn.conflict = FALSE)
QuartetStatus(BalancedTree(1:5), BalancedTree(3:8), nTip = 10)
#>        N   Q s d r1 r2   u
#> [1,] 420 210 0 0  5 15 190

# If all taxa studied occur in `trees` or `cf`, set `nTip = TRUE`
QuartetStatus(BalancedTree(1:5), BalancedTree(3:10), nTip = TRUE)
#>        N   Q s d r1 r2   u
#> [1,] 420 210 0 0  5 70 135
 
# Calculate Quartet Divergence between each tree and each other tree in a 
# list
QuartetDivergence(ManyToManyQuartetAgreement(two_moved))
#>               move_two_near move_two_mid move_two_far
#> move_two_near     1.0000000    0.6909091    0.6484848
#> move_two_mid      0.6909091    1.0000000    0.6484848
#> move_two_far      0.6484848    0.6484848    1.0000000
# Calculate Quartet Divergence between each tree in one list and each 
# tree in another
QuartetDivergence(TwoListQuartetAgreement(sq_trees[1:3], sq_trees[10:13]))
#>               m1mid_col1 m1mid_colsome m2mid_col1 m2mid_colsome
#> ref_tree       0.8303030     0.7439394  0.7515152     0.6893939
#> move_one_near  0.8545455     0.7681818  0.7272727     0.6651515
#> move_one_mid   0.9878788     0.9015152  0.6060606     0.5621212