Repository logo
 

Code supporting "Revealing patterns of homoplasy in discrete phylogenetic datasets with a cross comparable index"


Loading...
Thumbnail Image

Change log

Description

All code provided is for the R programming language.

Development code can be accessed at github.com/LizzySteell/Homoplasy

List of R scripts • Functions: Script containing all custom functions necessary to carry out below analyses; ‘Functions_SuppInfo.R’. • Analysis 1: Comparison of indexes for empirical and random matrices; ‘Analysis_1_v2.R’. • Analysis 2: Inflating transition rate for simulated matrices; ‘Analysis_2_v1.R’. • Analysis 3: Varying number of taxa for simulated matrices at slow, medium and fast transition rate categories; ‘Analysis_3_u-6.R’, ‘Analysis_3_u-4.R’, ‘Analysis_3_u-2.R’. • Analysis 4: Varying number of characters for simulated matrices at slow, medium and fast transition rate categories; ‘Analysis_4_u-6.R’, ‘Analysis_4_u-4.R’, ‘Analysis_4_u-2’. • Analysis 5: Phylomorphospace patterns at different homoplasy levels; ‘Analysis_5_u-6.R’, ‘Analysis_5_u-4.R’, ‘Analysis_5_u-2.R’, ‘Analysis_5_u-0’.

See 'Usage Notes' for custom functions.

Version

V1

Software / Usage instructions

Usage notes for custom functions HER() Function to calculate homoplasy excess ratio (Archie, 1989). Should only be used for topologies that are inferred via maximum parsimony from the input matrix with deviations from this method (e.g., applying partial or complete topological constraints or using implied weighting). Arguments: ‘data’ - A matrix of morphological data in the phangorn package ‘phydat’ (Schliep, 2011) format. Can use custom function ‘morph.phydat’, see below. ‘tree’ - A phylogenetic tree of class ‘phylo’ (Paradis et al., 2004). ‘n’ - Number of permutations of the matrix. ‘maxit’ - Maximum number of iterations in parsimony ratchet, as in ‘pratchet’ function in phangorn (Schliep, 2011). Default is 500. ‘minit’ - Minimum number of iterations in parsimony ratchet, as in ‘pratchet’ function in phangorn (Schliep, 2011). Default is 50. ‘k’ - Maximum number of rounds before ratchet is stopped when there is no improvement, as in ‘pratchet’ function in phangorn (Schliep, 2011). Default is 10. HSR() Function to calculate homoplasy slope ratio (Meier et al., 1991). Includes two options: to calculate the HSR as in Meier et al. (1991) or to calculate the modified homoplasy slope ratio (HSRm) as described in the present manuscript. HSRm includes polymorphic states and missing data into the matrix randomisation step. Arguments: ‘data’ - A matrix of morphological data in the phangorn package ‘phydat’ (Schliep, 2011) format. Can use custom function ‘morph.phydat’, see below. ‘tree’ - A phylogenetic tree of class ‘phylo’ (Paradis et al., 2004). ‘n’ - Number of permutations of the matrix. ‘modified’ – To state whether HSR should be calculated from the original method (Meier et al. 1991; modified = FALSE) or the modified method (modified = TRUE; default). RHI() Function to calculate the relative homoplasy index described here. Arguments: ‘data’ - A matrix of morphological data in the phangorn package ‘phydat’ (Schliep, 2011) format. Can use custom function ‘morph.phydat’, see below. ‘tree’ - A phylogenetic tree of class ‘phylo’ (Paradis et al., 2004). ‘n’ - Number of randomisations of the tip order in the tree. ‘ord’ – A vector containing the numbers for the specific ordered characters in the dataset. Default = NULL. ‘cost’ – A cost matrix specifying the cost per character state change (transition). See custom function ‘cost.matrix’ below. Must be specified if ‘ord’ is specified. Default = NULL. RHI.char() Function to calculate the per character relative homoplasy using the RHI formula. Currently only available for unordered characters (specified ordered multistate characters are in development). Arguments: ‘data’ - A matrix of morphological data in the phangorn package ‘phydat’ (Schliep, 2011) format. Can use custom function ‘morph.phydat’, see below. ‘tree’ - A phylogenetic tree of class ‘phylo’ (Paradis et al., 2004). ‘n’ - Number of randomisations of the tip order in the tree. RHI.multi() Function to calculate RHI for a distribution of trees with the same taxa and the same matrix. Ordered characters are allowed. Arguments: ‘data’ - A matrix of morphological data in the phangorn package ‘phydat’ (Schliep, 2011) format. Can use custom function ‘morph.phydat’, see below. ‘tree’ - A list of phylogenetic trees of class ‘MultiPhylo’ (Paradis et al., 2004). ‘n’ - Number of randomisations of the tip order in the tree. ‘ord’ – A vector containing the numbers for the specific ordered characters in the dataset. Default = NULL. ‘cost’ – A cost matrix specifying the cost per character state change (transition). See custom function ‘cost.matrix’ below. Must be specified if ‘ord’ is specified. Default = NULL. contrast.matrix() Function to generate a dataset-specific contrast matrix. This is required to generate a ‘phydat’ object required for homoplasy index calculations (Schliep, 2011). Contrast matrices specify which character scorings should behave as character states or combinations of states (e.g., ambiguities or polymorphisms). Here, polymorphisms and uncertainties are treated the same, and ‘gaps’ (‘-‘) and ambiguities (‘?’) are treated the same. A new contrast matrix should be generated for each phylogenetic character matrix. This function is implemented in custom function ‘morph.phydat’ detailed below. Arguments: ‘data’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present. cost.matrix() Function to generate a dataset-specific cost matrix for use with ordered characters. Arguments: ‘data’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present. get.states() Function that pastes the character states within a matrix. It ignores non-state scorings (polymorphisms and ambiguities). Arguments: ‘data’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present. morph.phydat() Function to generate a ‘phydat’ object (Schliep, 2011) to specifically handle morphological data as opposed to other data types more typically used in the phangorn package (e.g., nucleotide or amino acid data). Makes other phangorn functions compatible with morphological data that includes polymorphisms. Necessary for use with homoplasy index functions in phangorn and detailed here. Arguments: ‘matrix’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present. parenthesize() Internal function to place round braces around polymorphic character scorings. Arguments: ‘x’ – Character string in which to enclose with brackets. poly.to.amb() Function to replace all polymorphisms and uncertainties with ambiguities (‘?’). Arguments: ‘matrix’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present. statef() Function to paste the relative character state frequencies of a matrix. Excludes non-state scorings (polymorphisms and ambiguities). Arguments: ‘data’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present. subset.matrix() Function to subset matrices based on a list of subset trees. This function subsets a matrix by removing specific taxa, but does not remove characters. Arguments: ‘trees’ – A list of subset trees (object class ‘phylo’) from the ‘subset.trees’ function detailed below. ‘matrix’ – A character taxon matrix to be subsetted. uncert.to.poly() Internal function to change uncertainties denoted with curly braces to polymorphisms (denoted by round braces). Arguments: ‘matrix’ – A character-taxon matrix of class ‘matrix array’. Note that NAs should not be present.

Publisher

Rights and licensing

Except where otherwised noted, this item's license is described as MIT License
Sponsorship
Natural Environment Research Council (2262522)