Tree2MRP: Converts tree(s) to an MRP matrix

Description Usage Arguments Details Value Author(s) References Examples

View source: R/Tree2MRP.R

Description

Given an input tree or trees creates an MRP matrix.

Usage

1
Tree2MRP(Trees, AddAllZero = TRUE)

Arguments

Trees

An object of class 'phylo' or 'multi.phylo'.

AddAllZero

Whether (TRUE; default) to add an allzero outgroup taxon or not (FALSE).

Details

The Metatree function requires samples of tree(s) as input, but these must already be represented using Matrix Representtaion with Parsimony (MRP; Baum 1992; Ragan 1992). This encoding works by taking each bipartition (clade, or internal node, excluding the root) and coding taxa present inside the clade as 1 ("derived" state) and those outside the clade as 0 "primitive" state). Thus the tree:

1
2
3
4
5
6
7
 /-----A
 |
R| /---B
 \-|
  X| /-C
   \-|
    Y\-D

Would be encoded as the matrix:

1
2
3
4
5
  XY
A 00
B 10
C 11
D 11

Or, if using AddAllZero = TRUE the root (R) can also be encoded:

1
2
3
4
5
6
        RXY
allzero 000
A       100
B       110
C       111
D       111

Note that the function will remove any duplicate characters automatically, meaning if nodes reappear across a sample of trees these will be collapsed to a single MRP character (see example below), as suggested by Lloyd et al. (2016).

Currently an option to perform Purvis MRP (Purvis 1995) is not available.

Value

An MRP matrix in Claddis::read_nexus_matrix format.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

References

Baum, B. R., 1992. Combining trees as a way of combining data sets for phylogenetic inference, and the desirability of combining gene trees. Taxon, 41, 3-10.

Lloyd, G. T., Bapst, D. W., Friedman, M. and Davis, K. E., 2016. Probabilistic divergence time estimation without branch lengths: dating the origins of dinosaurs, avian flight, and crown birds. Biology Letters, 12, 20160609.

Purvis, A., 1995. A modification to Baum and Ragan's method for combining phylogenetic trees. Systematic Biology, 44, 251-255.

Ragan, M., 1992. Phylogenetic inference based on matrix representation of trees. Molecular Phylogenetics and Evolution, 1, 113-126.

Examples

1
2
3
4
5
6
7
8
9
# Generate a set of two example trees:
ExampleTrees <- ape::read.tree(text = c("(A,(B,(C,D)));", "(A,(C,(B,D)));"))

# Convert to MRP and show just matrix:
Tree2MRP(ExampleTrees)$matrix_1$matrix

# To confirm this collapses duplicate nodes show individual tree results:
Tree2MRP(ExampleTrees[[1]])$matrix_1$matrix
Tree2MRP(ExampleTrees[[2]])$matrix_1$matrix

graemetlloyd/metatree documentation built on April 29, 2021, 2:32 a.m.