PisaniMRPPrune: Prunes an MRP matrix of any redundant characters

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/PisaniMRPPrune.R

Description

Prunes an MRP matrix of any redundant (duplicate or autapomorphic) characters following Pisani et al. (2002).

Usage

1
PisaniMRPPrune(MRPMatrix)

Arguments

MRPMatrix

An MRP matrix in the format imported by Claddis::read_nexus_matrix. Must contain only 0 or 1 states.

Details

Matrix representations must be handled carefully when taxa (rows) or characters (columns) are being pruned or duplicated, as they are by the Metatree function. Specifically, as noted by Pisani et al. (2002; their Figure 1) if a row gets pruned it will often create duplicate characters that, if unchecked, will inadvertently upweight some relationships incorrectly.

To illustrate this, consider the following scenario as proposed by Pisani et al. (2002). A matrix representation for a tree with six tips (labelled A-F) is encoded with four characters (nodes or bipartitions, labelled 1-4):

1
2
3
4
5
6
7
  1 2 3 4
A 0 0 0 0
B 0 0 0 1
C 0 0 1 1
D 0 1 1 1
E 1 1 1 1
F 1 1 1 1

Then, following removal of taxon D (e.g., because taxonomic reconciliation suggests it is a nomen dubium) the matrix will now look like this:

1
2
3
4
5
6
  1 2 3 4
A 0 0 0 0
B 0 0 0 1
C 0 0 1 1
E 1 1 1 1
F 1 1 1 1

We now see that characters 1 and 2 are identical, effectively upweighting this relationship in the matrix representation.

This can be countered by removing the offending character (column), to give us the fairer representation:

1
2
3
4
5
6
  1 3 4
A 0 0 0
B 0 0 1
C 0 1 1
E 1 1 1
F 1 1 1

This function performs a check and correction for such duplicate characters, but also removes those that become autapomorphic in a similar way. For example, if we also removed taxon F:

1
2
3
4
5
  1 3 4
A 0 0 0
B 0 0 1
C 0 1 1
E 1 1 1

Character 1 is now redundant, not because it is duplicated but because it carries no parsimony-informative information. NB: in practical terms this wouldn't effect the results, but removing characters like this can dramatically reduce data set size and hence minimise memory issues downstream. In this case, collapsing the data to just two characters:

1
2
3
4
5
  3 4
A 0 0
B 0 1
C 1 1
E 1 1

Note that primarily this function is intended for internal use by Metatree, but may have some value to a user as a stand alone function.

Value

A modified MRP matrix with redundant (duplicate or autapomorphic) characters removed.

Author(s)

Graeme T. Lloyd graemetlloyd@gmail.com

References

Pisani, D., Yates, A. M., Langer, M. C. and Benton, M. J., 2002. A genus-level supertree of the Dinosauria. Proceedings of the Royal Society of London B, 269, 915-921.

See Also

For another means by which MRP matrices require collapsing see CollapseDuplicateTaxonMRP.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Build the Pisani et al. (2002) example matrix:
PisaniExample <- Claddis::build_cladistic_matrix(matrix(as.character(c(0, 0,
  0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)),
  nrow = 6, dimnames = list(LETTERS[1:6], c()), byrow = TRUE))

# Confirm it matches the Pisani example by inspection:
PisaniExample$matrix_1$matrix

# Remove taxon D
PisaniExample <- Claddis::prune_cladistic_matrix(PisaniExample, taxa2prune = c("D"))

# Confirm that first two characters are redundant by inspection:
PisaniExample$matrix_1$matrix

# Apply pruning alogirhtm to data:
PisaniExample <- PisaniMRPPrune(PisaniExample)

# Confirm that first two characters are now merged by inspection:
PisaniExample$matrix_1$matrix

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