Learn R Programming

Claddis (version 0.7.0)

trim_matrix: Trims a morphological distance matrix

Description

Trims a morphological distance matrix by removing objects that cause empty cells.

Usage

trim_matrix(distance_matrix, tree = NULL)

Value

distance_matrix

A complete distance matrix with all cells filled. If there were no empty cells will return original.

tree

A tree (if supplied) with the removed taxa (see below) pruned. If no taxa are dropped will return the same tree as inputted. If no tree is supplied this is set to NULL.

removed_taxa

A character vector listing the taxa removed. If none are removed this will be set to NULL.

Arguments

distance_matrix

A distance matrix in the format created by calculate_morphological_distances.

tree

If the distance matrix includes ancestors this should be the tree (phylo object) used to estimate their states.

Author

Graeme T. Lloyd graemetlloyd@gmail.com

Details

Trims a morphological distance matrix by removing nodes (terminal or internal) that cause empty cells allowing it to be passed to an ordination function such as cmdscale.

Some distances are not calculable from cladistic matrices if there are taxa that have no coded characters in common. This algorithm iteratively removes the taxa responsible for the most empty cells until the matrix is complete (no empty cells).

If the matrix includes estimated ancestral states the user should also provide the tree used (as the tree argument). The function will then also remove the tips from the tree and where reconstructed ancestors also cause empty cells will prune the minimum number of descendants of that node. The function will then renumber the nodes in the distance matrix so they match the pruned tree.

See Also

calculate_morphological_distances

Examples

Run this code

# Get morphological distances for Michaux (1989) data set:
distances <- calculate_morphological_distances(cladistic_matrix = michaux_1989)

# Attempt to trim max.distance_matrix:
trim_matrix(distance_matrix = distances$distance_matrix)

Run the code above in your browser using DataLab