Title: | Analysis of Convergent Evolution |
---|---|
Description: | Quantifies and assesses the significance of convergent evolution using multiple methods and measures as described in Stayton (2015) <DOI: 10.1111/evo.12729> and Grossnickle et al. 2023. Also displays results in various ways. |
Authors: | William Brightly [aut], C. Tristan Stayton [aut, cre] |
Maintainer: | C. Tristan Stayton <[email protected]> |
License: | GPL-3 |
Version: | 2.2.1 |
Built: | 2024-12-01 08:49:58 UTC |
Source: | CRAN |
allmaxdist Uses maxdist to calcualte the maximum phenotypic. distance between the ancestors of all pairs of taxa in a phylogeny. By default outputs these as a matrix, but can also output a list. Can take some time to run for large trees.
allmaxdist(phyl, phendata, mat = TRUE)
allmaxdist(phyl, phendata, mat = TRUE)
phyl |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
mat |
Whether or not to export the values in a matrix (default) or a list |
Regarding the output: the matrix is better organized, but the list avoids all the zeroes and is probably better for making histograms.
A matrix or list of all maxdist values for all pairs of taxa in the phylogeny.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) answer<-allmaxdist(phyl,phendata,mat=TRUE)
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) answer<-allmaxdist(phyl,phendata,mat=TRUE)
Extracts lineages leading to two tips, t1 and t2, from their most recent common ancestor.
ancestrallineages(phyl, phendata, t1, t2)
ancestrallineages(phyl, phendata, t1, t2)
phyl |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
t1 |
The first tip of interest |
t2 |
The second tip of interest |
None
A list containing two matrices. Each matrix corresponds to a tip. The matrix consists of reconstructed ancestral values for all nodes leading from the mrca of both tips to the tip.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
Stayton, C.T. (2015). The definition, recognition, and interpretation of convergent evolution, and two new measure for quantifying and assessing the significance of convergence. Evolution 69:2140-2153.
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) answer<-ancestrallineages(phyl,phendata,"t1","t2")
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) answer<-ancestrallineages(phyl,phendata,"t1","t2")
Calculates the Euclidean distance between all ancestors and descendants on a phylogeny to reconstruct the phenotypic changes that occur along all edges of a phylogeny.
calcchanges(phyl, phendata)
calcchanges(phyl, phendata)
phyl |
The phylogeny of interest in phylo format |
phendata |
A matrix of phenotypic data for all tips, with taxa in rows and characters in columns. |
Calculates the Euclidean distance between all ancestors and descendants on a phylogeny to reconstruct the phenotypic changes that occur along all edges of a phylogeny.
A vector in which each element represents an edge of the phylogeny, and the values are the magnitudes of evolutionary change that occur along those edges.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=5) changes<-calcchanges(phyl,phendata)
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=5) changes<-calcchanges(phyl,phendata)
calcConv prepares arguements for the CalcCs function
calcConv(phy, traits, focaltaxa, anc = NULL, VERBOSE = FALSE)
calcConv(phy, traits, focaltaxa, anc = NULL, VERBOSE = FALSE)
phy |
The phylogeny of interest in phylo format |
traits |
Phenotypic data for all tips |
focaltaxa |
A list consisting of the names of all putatively convergent taxa |
anc |
A matrix of user supplied ancestral trait values at internal nodes (formatted as "traits" but with node number as rownames) |
VERBOSE |
Whether or not to print progress |
calcConv is a wrapper function which formats data, performs ancestral state reconstructions, obtains distance matrices, and determines pairwise combinations of focal taxa, which are then used as arguements for the CalcCs function, which calculates values for C1-C4 of Stayton (2015) for each pair of putatively convergent taxa.
C1-C4 convergence measures for all pairs of putatively convergent taxa.
Stayton, C.T. 2015. The definition, recognition, and interpretation of convergent evolution, and two new measures for quantifying and assessing the significance of convergence. Evolution 69:2140-2453.
Zelditch, M.L., J. Ye, J.S. Mitchell, and D.L. Swiderski. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71:633-649.
phy<-rtree(100) traits<-fastBM(phy,nsim=3) focaltaxa<-c("t1","t50","t100") answer<-calcConv(phy,traits,focaltaxa,anc=NULL,VERBOSE=FALSE)
phy<-rtree(100) traits<-fastBM(phy,nsim=3) focaltaxa<-c("t1","t50","t100") answer<-calcConv(phy,traits,focaltaxa,anc=NULL,VERBOSE=FALSE)
calcConvCt Computes Ct-metric scores for putatively convergent tips (or groups of tips) given a set of user provided phenotypic characters and a time calibrated phylogeny.
calcConvCt( phy, traits, focaltaxa, groups = NULL, ace = NULL, conservative = FALSE, VERBOSE = FALSE )
calcConvCt( phy, traits, focaltaxa, groups = NULL, ace = NULL, conservative = FALSE, VERBOSE = FALSE )
phy |
The time calibrated phylogeny of interest in phylo format |
traits |
A matrix of numeric phenotypic traits with rownames matching tip labels of phy |
focaltaxa |
A vector of tip labels for the putatively convergent taxa to be compared |
groups |
An optional vector of groups with names matching focaltaxa. Indicates the group identity of all putatively convergent taxa and limits Ct measures to intergroup comparisons only |
ace |
A matrix of user supplied ancestral trait values at internal nodes (formatted as "traits" but with node number as rownames) |
conservative |
Logical value indicating whether Dmax.t should be restricted to occurr before the oldest stem lineage of the two groups involved in each pairwise comparison. Stem lineage age for each group is defined as the height of the parent node of the branch subtending the most recent common ancestor of tips within a group. Where groups include a single tip, the parent node of the tip's subtending branch is used. Requires group object to be provided by user. |
VERBOSE |
Logical value indicating whether model information should be printed during computation |
Function incorporates the optimizations introduced by Zelditch et al. (2017), which significantly improve runtimes
Reconstructions part way along branches are obtained using equation 2 of Felsenstein (1985), following code modified from the phytools (Revell, 2012) function contMap
A list of the following components:
mean a named vector of Ct-metrics averaged from all pairwise comparisons of focaltaxa. If user provided groups, this is based only on comparisons between taxa belonging to different groups.
Cmat a matrix of Ct-metrics for each pairwise comparison.
path_df a list of dataframes, one per pairwise comparison of the focal taxa, each containing information from all timepoint measurements of the two putatively convergent lineages. These provide the nodes at which comparisons were drawn, the evolutionary path along which that node fell (i.e., leading to one of two tips), the node height, reconstructed ancestral states at that node for each phenotypic trait, reconstructed ancestral values for each trait along the opposite path, and the phenotypic distance between the two lineages at that point.
grp.mean a matrix of Ct-metrics summarized for inter-group comparisons, returned only if user defined groups were specified. Provides overall results matching those reported in "mean", results for each unique inter-group comparison, and results averaged with equal weight given to each unique inter-group comparison (i.e., ignoring differences in the number of tips in each group).
limits a list of tree heights used to constrain Dmax.t calculations for each pairwise comparison in conservative analyses. Only returned if conservative == TRUE.
Grossnickle DM, Brightly WH, Weaver LN, Stanchak KE, Roston RA, Pevsner SK, Stayton CT, Polly PD, Law CJ. 2022. A cautionary note on quantitative measures of phenotypic convergence. in revision Zelditch ML, Ye J, Mitchell JS, Swiderski DL. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71: 633-649 Stayton CT. 2015. The definition, recognition, and interpretation of convergent evolution and two new measures for quantifying and assessing the significance of convergence. Evolution 69(8): 2140-2153. Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist, 125, 1-15.
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,which(phy$tip.label == x[1]), which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] system.time(run <- calcConvCt(phy, traits, focaltaxa)) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=10)) plotCt(output = run2,phy = phy,focaltaxa = focaltaxa) ## End(Not run)
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,which(phy$tip.label == x[1]), which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] system.time(run <- calcConvCt(phy, traits, focaltaxa)) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=10)) plotCt(output = run2,phy = phy,focaltaxa = focaltaxa) ## End(Not run)
calcCs calculates the C1-C4 measures of convergent evolution
calcCs(tips, ancList, allDists, phy, VERBOSE = FALSE)
calcCs(tips, ancList, allDists, phy, VERBOSE = FALSE)
tips |
Two putatively convergent tips |
ancList |
A list of ancestors of all tips. Most often obtained from calcConv |
allDists |
A matrix of phenotypic distances between all nodes (tips and ancestors). Most often obtained from calcConv |
phy |
The phylogeny of interest |
VERBOSE |
Whether or not to print progress |
calcCs calculates values of C1-C4, all of which are fundamentally based on comparing the current phenotypic distance between two tips to the maximum past distances between the ancestors of those tips. Higher values indicate a greater amount of past phenotypic distance which has been "closed" by subsequent evolution, and thus greater convergence. C1 is the ratio of tip to maximum ancestral distance. C2 is the difference of those two values. C3 scales C2 by the total amount of evolution that has occured in the two lineages. C4 scales C2 by the total amount of evolution that has occurred in the entire phylogeny. The arguments for this function will usually be obtained from the calcConv script in convevol - this allows certain computationally-intensive steps (e.g., calculating ancestral states) to only be performed once, thus saving a great deal of time. This script also corrects an error in the calculation of C4 of previous versions of convevol.
C1-C4 convergence measures for all pairs of putatively convergent taxa.
Stayton, C.T. 2015. The definition, recognition, and interpretation of convergent evolution, and two new measures for quantifying and assessing the significance of convergence. Evolution 69:2140-2453.
Zelditch, M.L., J. Ye, J.S. Mitchell, and D.L. Swiderski. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71:633-649.
calcCsCt Computes Ct values for a pair of tips. Internal, called in calcConv.
calcCsCt( tips, ancList, allDists, phy, VERBOSE = FALSE, allVals, edge, lim.height = NULL )
calcCsCt( tips, ancList, allDists, phy, VERBOSE = FALSE, allVals, edge, lim.height = NULL )
tips |
vector of two tips |
ancList |
list of node paths for all tips in the user provided phylogeny |
allDists |
matrix of phenotypic distances between all exterior and interior node pairs |
phy |
The time calibrated phylogeny of interest in phylo format |
VERBOSE |
logical value indicating whether model information should be printed during computation |
allVals |
a matrix of observed and reconstructed phenotypes for all user supplied traits at interior and exterior nodes |
edge |
a list of data frames, each including the edge matrix of user supplied phylogeny, along with node heights and reconstructed phenotype for each of the user supplied traits |
lim.height |
an optional tree height used to limit Dmax.t, passed only if groups are defined and a conservative test is run (see calcConv) |
Function incorporates the optimizations introduced by Zelditch et al. (2017), which significantly improve runtimes
Reconstructions part way along branches are obtained using equation 2 of Felsenstein (1985), following code modified from the phytools (Revell, 2012) function contMap
A list of the Ct values
Grossnickle DM, Brightly WH, Weaver LN, Stanchak KE, Roston RA, Pevsner SK, Stayton CT, Polly PD, Law CJ. 2022. A cautionary note on quantitative measures of phenotypic convergence. in revision Zelditch ML, Ye J, Mitchell JS, Swiderski DL. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71: 633-649 Stayton CT. 2015. The definition, recognition, and interpretation of convergent evolution and two new measures for quantifying and assessing the significance of convergence. Evolution 69(8): 2140-2153. Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist, 125, 1-15.
This program takes in a set of taxa that are already suspected to be convergent in a particular area of morphospace. It then counts the number of times that a lineage has invaded that region of morphospace.
convnum( phy, phendata, convtips, plot = TRUE, ellipse = NULL, plotellipse = NULL )
convnum( phy, phendata, convtips, plot = TRUE, ellipse = NULL, plotellipse = NULL )
phy |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
convtips |
A list consisting of the names of all convergent taxa |
plot |
Whether or not to plot a phylomorphospace with lineages that cross into the region of interest highlighted as red arrows. Default=TRUE |
ellipse |
Optional. An ellipse defining the region of interest, into which groups may or may not converge. |
plotellipse |
Optional. The ellipse defining the region of interest in the first two dimensions. |
This function will construct an ellipse around all convergent taxa. Then it will reconstruct ancestral states throughout the phylogeny, and use those to determine how many lineages have crossed into this ellipse from the outside.
The number of lineages that have crossed into the region of trait space occupied by the convergent taxa.
Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2013). cluster: Cluster Analysis Basics and Extensions. R package version 1.14.4.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phy<-rtree(10) phendata<-fastBM(phy,nsim=2) convtips<-c("t1","t2","t3") answer<-convnum(phy,phendata,convtips,plot=TRUE,ellipse=NULL,plotellipse=NULL)
phy<-rtree(10) phendata<-fastBM(phy,nsim=2) convtips<-c("t1","t2","t3") answer<-convnum(phy,phendata,convtips,plot=TRUE,ellipse=NULL,plotellipse=NULL)
Simulates evolution along a given phylogeny, using parameters derived from observed data, and calculates the convnum metric for each simulation for a set of user-defined taxa. Then compares the observed convnum value to the simulated values to assess the significance of the observed levels of convergent evolution.
convnumsig( phy, phendata, convtips, nsim, ellipse = NULL, plot = FALSE, plotellipse = NULL )
convnumsig( phy, phendata, convtips, nsim, ellipse = NULL, plot = FALSE, plotellipse = NULL )
phy |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
convtips |
A list consisting of the names of all convergent taxa |
nsim |
The number of simulatons to conduct |
ellipse |
Optional. An ellipse defining the region of interest, into which groups may or may not converge. |
plot |
Optional. Describes whether or not to show phylomorphospaces for all of the simulations. |
plotellipse |
Optional. The ellipse defining the region of interest in the first two dimensions. |
None
A list, consisting first of the p-value for the observed convnum, and second of a vector containing all of the simulated convnum values. Also displays a histogram of all of the simulated convnum values.
Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2013). cluster: Cluster Analysis Basics and Extensions. R package version 1.14.4.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phy<-rtree(10) phendata<-fastBM(phy,nsim=2) convtips<-c("t1","t2","t3") answer<-convnumsig(phy,phendata,convtips,10,plot=FALSE,ellipse=NULL,plotellipse=NULL)
phy<-rtree(10) phendata<-fastBM(phy,nsim=2) convtips<-c("t1","t2","t3") answer<-convnumsig(phy,phendata,convtips,10,plot=FALSE,ellipse=NULL,plotellipse=NULL)
Calculates the current phenotypic distance (Euclidean) between two taxa. Then uses ancestral state reconstruction under a BM model to calculate the maximum phenotypic distance at any time between lineages leading from the most recent common ancestor of those two taxa to the tips. Also calculate the total amount of phenotypic evolution in the clade defined by the most recent common ancestor of those lineages, and the total amount of phenotypic evolution in the input tree. These quantities are used to calcualte C1-C4: C1 = 1-(current distance / maximum ancestral distance); C2 = maximum ancestral distance - current distance; C3=C2/(total phenotypic evolution in the clade defined by the two taxa); C4 = C2/(total amount of phenotypic evolution in the entire tree). If more than two convergent taxa are input, then C1-C4 are calculated for all possible pairs of taxa, and averaged.
convrat(phyl, phendata, convtips)
convrat(phyl, phendata, convtips)
phyl |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
convtips |
A list consisting of the names of all convergent taxa |
None
Four numbers - C1, C2, C3, C4.
Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2013). cluster: Cluster Analysis Basics and Extensions. R package version 1.14.4.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
Stayton, C.T. (2015). The definition, recognition, and interpretation of convergent evolution, and two new measure for quantifying and assessing the significance of convergence. Evolution 69:2140-2153.
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) convtips<-c("t1","t2","t3") answer<-convrat(phyl,phendata,convtips)
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) convtips<-c("t1","t2","t3") answer<-convrat(phyl,phendata,convtips)
convratsig tests the significance of convergence (as quantified by convrat) using evolutionary simulations.
convratsig(phyl, phendata, convtips, nsim)
convratsig(phyl, phendata, convtips, nsim)
phyl |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
convtips |
A list consisting of the names of all convergent taxa |
nsim |
The number of simulations to conduct |
The function simulates evolution via Brownian motion using the input tree and parameters derived from the observed data. It calculates a convergence metric for each simulation and calculates statistics from the number of times the simulated value exceeds the observed value.
The convergence metric of interest (C1, C2, etc...), a cutoff value (the value that the observed measure would have to exceed in order to be considered significant), a P-value for the statistic, and all simulated values.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) convtips<-c("t1","t2","t3") answer<-convratsig(phyl,phendata,convtips,10)
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) convtips<-c("t1","t2","t3") answer<-convratsig(phyl,phendata,convtips,10)
convSig calculates the significance of measures of convergent evolution.
convSig(phy, traits, focaltaxa, user.ace = NULL, nsim = 1000)
convSig(phy, traits, focaltaxa, user.ace = NULL, nsim = 1000)
phy |
The phylogeny of interest in phylo format |
traits |
Phenotypic data for all tips |
focaltaxa |
A list consisting of the names of all putatively convergent taxa |
user.ace |
A matrix of user supplied ancestral trait values at internal nodes (formatted as "traits" but with node number as rownames) |
nsim |
The number of simulations to use to assess significance |
This script simulates data according to a Brownian motion model of evolution, and then assesses convergene on that simulated data. The number of times that the simulated data produces greater convergence than that observed in the empirical data is used to calculate a P-value.
C1-C4 convergence measures for all pairs of putatively convergent taxa and their associated p-values.
Stayton, C.T. 2015. The definition, recognition, and interpretation of convergent evolution, and two new measures for quantifying and assessing the significance of convergence. Evolution 69:2140-2453.
Zelditch, M.L., J. Ye, J.S. Mitchell, and D.L. Swiderski. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71:633-649.
phy<-rtree(100) traits<-fastBM(phy,nsim=3) focaltaxa<-c("t1","t50","t100") answer<-convSig(phy,traits,focaltaxa,user.ace=NULL,nsim=10)
phy<-rtree(100) traits<-fastBM(phy,nsim=3) focaltaxa<-c("t1","t50","t100") answer<-convSig(phy,traits,focaltaxa,user.ace=NULL,nsim=10)
calcConvCt Computes and conducts significance tests on Ct-metric scores for putatively convergent tips (or groups of tips) given a set of user provided phenotypic characters and a time calibrated phylogeny.
convSigCt( phy, traits, focaltaxa, groups = NULL, user.ace = NULL, nsim = 1000, ... )
convSigCt( phy, traits, focaltaxa, groups = NULL, user.ace = NULL, nsim = 1000, ... )
phy |
The time calibrated phylogeny of interest in phylo format |
traits |
A matrix of numeric phenotypic traits with rownames matching tip labels of phy |
focaltaxa |
A vector of tip labels for the putatively convergent taxa to be compared |
groups |
An optional vector of groups with names matching focaltaxa. Indicates the group identity of all putatively convergent taxa and limits Ct measures to intergroup comparisons only |
user.ace |
A matrix of user supplied ancestral trait values at internal nodes (formatted as "traits" but with node number as rownames) |
nsim |
Number of simulated (Brownian motion) datasets used to build the null distribution |
... |
optional arguments to be passed to calcConvCt. If conservative == TRUE, Dmax.t will be restricted to occurr before the oldest stem lineage of the two groups involved in each pairwise comparison. Stem lineage age for each group is defined as the height of the parent node of the branch subtending the most recent common ancestor of tips within a group. Where groups include a single tip, the parent node of the tip's subtending branch is used. Requires group object to be provided by user.. If VERBOSE is TRUE, model information will be printed during computation, including time limits imposed on Dmax.t if the conservative option is chosen. |
Function incorporates the optimizations introduced by Zelditch et al. (2017), which significantly improve runtimes
Reconstructions part way along branches are obtained using equation 2 of Felsenstein (1985), following code modified from the phytools (Revell, 2012) function contMap
A list of the following components:
pvals a matrix containing Ct1 - Ct4 and p-values from significance tests for each
meas.Cmat a matrix of Ct values for each pairwise comparison of focaltaxa
meas.path a list of dataframes, one per pairwise comparison of focaltaxa, each containing information from all timepoint measurements of the two putatively convergent lineages. These provide the nodes at which comparisons were drawn, the evolutionary path along which that node fell (i.e., leading to one of two tips), the node height, reconstructed ancestral states at that node for each phenotypic trait, reconstructed ancestral values for each trait along the opposite path, and the phenotypic distance between the two lineages at that point.
sim.avg average Ct values from all pairwise comparisons between focaltaxa using simulated Brownian motion traits, number of columns corresponds to the user provided number of simulations
sim.path a list of dataframes as in meas.path, but obtained using simulated data. Length of object determined by number of pairwise comparisons multiplied by the number of simulated datasets.
grp.mean a matrix of Ct-metrics summarized for inter-group comparisons, returned only if user defined groups were specified. Provides overall results matching those reported in "mean", results for each unique inter-group comparison, and results averaged with equal weight given to each unique inter-group comparison (i.e., ignoring differences in the number of tips in each group).
grp.pvals a matrix of p-values associated with Ct values in grp.mean object. Returned only if user defined groups were specified.
limits a list of tree heights used to constrain Dmax.t calculations for each pairwise comparison in conservative analyses. Only returned if conservative == TRUE.
Grossnickle DM, Brightly WH, Weaver LN, Stanchak KE, Roston RA, Pevsner SK, Stayton CT, Polly PD, Law CJ. 2022. A cautionary note on quantitative measures of phenotypic convergence. in revision Zelditch ML, Ye J, Mitchell JS, Swiderski DL. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71: 633-649 Stayton CT. 2015. The definition, recognition, and interpretation of convergent evolution and two new measures for quantifying and assessing the significance of convergence. Evolution 69(8): 2140-2153. Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist, 125, 1-15.
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,which(phy$tip.label == x[1]), which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] system.time(run <- calcConvCt(phy, traits, focaltaxa)) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=100)) plotCt(output = run2,phy = phy,focaltaxa = focaltaxa) ## End(Not run)
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,which(phy$tip.label == x[1]), which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] system.time(run <- calcConvCt(phy, traits, focaltaxa)) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=100)) plotCt(output = run2,phy = phy,focaltaxa = focaltaxa) ## End(Not run)
This function will find the ancestor of a given node in a phylogeny. It will return a two-element vector, which will contain both the node of the ancestor and the number of the edge that connects the node and ancestor.
findanc(phyl, node)
findanc(phyl, node)
phyl |
The phylogeny of interest in phylo format |
node |
The number of the node that you want the ancestor for |
Returns a two-element vector. The node of the ancestor is first; the edge that connects that node with its ancestor is second.
A two-element vector, where the first element is the node of the ancestor and the second element is the number of the edge that connects the node and ancestor (i.e., the row number in phyl$edge).
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290. Paradis, E. (2012) Analysis of Phylogenetics and Evolution with R (Second Edition). New York: Springer.
phyl<-rtree(10) ancestor<-findanc(phyl,1)
phyl<-rtree(10) ancestor<-findanc(phyl,1)
Converts taxon names to corresponding tip/edge numbers in the phylogeny.
labelstonumbers(phyl, tips)
labelstonumbers(phyl, tips)
phyl |
The phylogeny of interest in phylo format |
tips |
The names of the tips in question |
Simply reads in taxon names, determines which tip or edge number they correspond to, and returns those values
The numbers of all of the tips of interest.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290. Paradis, E. (2012) Analysis of Phylogenetics and Evolution with R (Second Edition). New York: Springer.
phyl<-rtree(10) nums<-labelstonumbers(phyl,c("t1","t2","t3"))
phyl<-rtree(10) nums<-labelstonumbers(phyl,c("t1","t2","t3"))
maxdist uses ancestral state reconstruction to determine the maximum distance between any ancestors of those two taxa.
maxdist(phyl, phendata, t1, t2)
maxdist(phyl, phendata, t1, t2)
phyl |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
t1 |
The first taxon of interest |
t2 |
The second taxon of interest |
Returns the maximum Euclidean distance between any pair of ancestors of the two taxa, whether or not those two ancestors are contemporaries.
The maximum phenotypic distance between the two taxa
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) answer<-maxdist(phyl,phendata,1,10)
phyl<-rtree(10) phendata<-fastBM(phyl,nsim=2) answer<-maxdist(phyl,phendata,1,10)
Uses fastAnc to reconstruct ancestral states for multiple phenotypic characters
multianc(phy, phendata)
multianc(phy, phendata)
phy |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
None
A matrix with the tips data in the first n rows and the ancestral data in the remaining n-1 rows.
Paradis, E., J. Claude, and K. Strimmer (2004) APE: Analyses of phylogenetics and evolution in R langauge. Bioinformatics, 20, 289-290.
Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol. 3 217-223.
phy<-rtree(10) phendata<-fastBM(phy,nsim=2) ancs<-multianc(phy,phendata)
phy<-rtree(10) phendata<-fastBM(phy,nsim=2) ancs<-multianc(phy,phendata)
It's a sample phylogeny with 100 tips.
A tree file
plot2D Plots calcConv or convSig output as a two-dimensional time series.
plot2D( Ct, phy, tip, foc.trt, trait, pca = FALSE, save = FALSE, filename = "frame", dir = NULL, leg = FALSE, leg.pos = "topleft", width = 480, height = 480, ... )
plot2D( Ct, phy, tip, foc.trt, trait, pca = FALSE, save = FALSE, filename = "frame", dir = NULL, leg = FALSE, leg.pos = "topleft", width = 480, height = 480, ... )
Ct |
object containing calcConvCt or convSigCt output |
phy |
The time calibrated phylogeny of interest in phylo format |
tip |
vector of two tip labels indicating the putatively convergent taxa to be plotted in morphospace |
foc.trt |
vector of two traits to be used in plotting. If pca == TRUE this should indicate which PC axes should be plotted in format "PC1" |
trait |
the matrix of trait values used to compute Ct |
pca |
logical value indicating whether to conduct principal component analysis and plot PC scores instead of raw trait values |
save |
logical value indicating whether an animated time series (along with individual time slices) should be saved to a user specified folder |
filename |
character indicating the desired prefix for filenames to be saved |
dir |
optional character indicating the folderpath of the desired save location |
leg |
logical value indicating whether a legend should be added to plots |
leg.pos |
character indicating the position of the legend |
width |
pixel width of saved png files |
height |
pixel height of saved png files |
... |
optional arguments to be passed to plot |
None
Plots tracking putatively convergent taxa in two-dimensional morphospace through time
A table with trait values, morphospace distance, and nodeheights conincident with Dmax.t. See meas.path output from calcConvCt and convSigCt
Grossnickle DM, Brightly WH, Weaver LN, Stanchak KE, Roston RA, Pevsner SK, Stayton CT, Polly PD, Law CJ. 2022. A cautionary note on quantitative measures of phenotypic convergence. in revision Zelditch ML, Ye J, Mitchell JS, Swiderski DL. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71: 633-649 Stayton CT. 2015. The definition, recognition, and interpretation of convergent evolution and two new measures for quantifying and assessing the significance of convergence. Evolution 69(8): 2140-2153. Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist, 125, 1-15.
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) colnames(traits) <- c("V1","V2","V3") rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy, which(phy$tip.label == x[1]),which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] system.time(run <- calcConvCt(phy, traits, focaltaxa)) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=100)) plot2D(run, phy, focaltaxa[1:2], colnames(traits)[1:2], traits) ## End(Not run)
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) colnames(traits) <- c("V1","V2","V3") rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy, which(phy$tip.label == x[1]),which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] system.time(run <- calcConvCt(phy, traits, focaltaxa)) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=100)) plot2D(run, phy, focaltaxa[1:2], colnames(traits)[1:2], traits) ## End(Not run)
plotCt Plots calcConv or convSig output.
plotCt( output, phy, focaltaxa, nsim = 25, col = c("black", "forest green", "dodgerblue2", "firebrick1", "purple", "orange", "salmon", "goldenrod", "springgreen2", "plum1"), groups = NULL, ... )
plotCt( output, phy, focaltaxa, nsim = 25, col = c("black", "forest green", "dodgerblue2", "firebrick1", "purple", "orange", "salmon", "goldenrod", "springgreen2", "plum1"), groups = NULL, ... )
output |
object containing calcConv or convSig output |
phy |
The time calibrated phylogeny of interest in phylo format |
focaltaxa |
a vector of tip labels for the putatively convergent taxa to be compared |
nsim |
number of null simulations to plot |
col |
vector of colors to use for all unique intergroup comparisons a default option is given usable with up to five groups. If number of groups is 1 or less than length of col, not all colors will be used |
groups |
an optional vector of groups with names matching focaltaxa, indicating the group identity of all focaltaxa |
... |
optional arguments to be passed to tiplabels |
Creates a plot that shows the phenotypic distances between pairs of putatively convergent lineages over time. When these distances decrease, convergence has occurred. When more than two putatively convergent taxa are analyzed, all pairs are plotted.
A plot identifying putatively convergent taxa in the provided phylogeny and tracking the change in phenotypic distance between taxa since their most recent common ancestor
Grossnickle DM, Brightly WH, Weaver LN, Stanchak KE, Roston RA, Pevsner SK, Stayton CT, Polly PD, Law CJ. 2022. A cautionary note on quantitative measures of phenotypic convergence. in revision Zelditch ML, Ye J, Mitchell JS, Swiderski DL. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71: 633-649 Stayton CT. 2015. The definition, recognition, and interpretation of convergent evolution and two new measures for quantifying and assessing the significance of convergence. Evolution 69(8): 2140-2153. Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist, 125, 1-15.
#' create time calibrated tree phy<-rcoal(100) # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label focaltaxa <- sample(phy$tip.label, 5) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=10)) plotCt(output = run2,phy = phy,focaltaxa = focaltaxa)
#' create time calibrated tree phy<-rcoal(100) # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label focaltaxa <- sample(phy$tip.label, 5) system.time(run2 <- convSigCt(phy, traits, focaltaxa, nsim=10)) plotCt(output = run2,phy = phy,focaltaxa = focaltaxa)
Plots a minimum ellipse around a set of data
plotellipse(ellipse)
plotellipse(ellipse)
ellipse |
Gives the parameters of the ellipse - output from the ellipsoidhull functon in cluster. |
Routine adapted from a suggestion made on CrossValidated: http://stats.stackexchange.com/questions/9898/how-to-plot-an-ellipse-from-eigenvalues-and-eigenvectors-in-r
Nothing - just plots the ellipse.
Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2013). cluster: Cluster Analysis Basics and Extensions. R package version 1.14.4.
pullNodeSeq Extracts a vector of all ancestors of a given taxon in a phylogeny.
pullNodeSeq(phy, tip)
pullNodeSeq(phy, tip)
phy |
The phylogeny of interest in phylo format |
tip |
The tip of interest |
A vector of ancestors
Zelditch, M.L., J. Ye, J.S. Mitchell, and D.L. Swiderski. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71:633-649.
phylogeny<-rtree(100) answer<-pullNodeSeq(phy=phylogeny,tip="t1")
phylogeny<-rtree(100) answer<-pullNodeSeq(phy=phylogeny,tip="t1")
pwCheck Calculates the number of measurements that can be made between two lineages for each pairwise comparison within a set of putatively convergent tips (group identity may also be taken into account). Useful for determining which comparisons are not informative, and constructing a group object before running calcConvCt or convSigCt.
pwCheck(phy, focaltaxa, groups = NULL, conservative = FALSE)
pwCheck(phy, focaltaxa, groups = NULL, conservative = FALSE)
phy |
The time calibrated phylogeny of interest in phylo format |
focaltaxa |
a vector of tip labels for the putatively convergent taxa to be compared |
groups |
an optional vector of groups with names matching focaltaxa. Indicates the group identity of all putatively convergent taxa and limits Ct measures to intergroup comparisons only |
conservative |
logical value indicating whether candidate nodes for measurement of Dmax.t should be restricted to occurr before the oldest stem lineage of the two groups involved in each pairwise comparison. Stem lineage age for each group is defined as the height of the parent node of the branch subtending the most recent common ancestor of tips within a group. Where groups include a single tip, the parent node of the tip's subtending branch is used. Requires group object to be provided by user. |
A list of the following components:
taxa a matrix of uninformative tip comparisons
path a vector with the number of measurements for all pairwise comparisons - a summary of this is also printed when running the function
Grossnickle DM, Brightly WH, Weaver LN, Stanchak KE, Roston RA, Pevsner SK, Stayton CT, Polly PD, Law CJ. 2022. A cautionary note on quantitative measures of phenotypic convergence. in revision Zelditch ML, Ye J, Mitchell JS, Swiderski DL. 2017. Rare ecomorphological convergence on a complex adaptive landscape: Body size and diet mediate evolution of jaw shape in squirrels (Sciuridae). Evolution 71: 633-649 Stayton CT. 2015. The definition, recognition, and interpretation of convergent evolution and two new measures for quantifying and assessing the significance of convergence. Evolution 69(8): 2140-2153. Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223. Felsenstein, J. 1985. Phylogenies and the comparative method. American Naturalist, 125, 1-15.
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,which(phy$tip.label == x[1]), which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] pwCheck(phy,focaltaxa) ## End(Not run)
## Not run: library(phytools) library(geiger) # create time calibrated tree mytree<-rtree(100) mycalibration <- makeChronosCalib(mytree, node="root", age.max=50) phy <- chronos(mytree, lambda = 1, model = "correlated", calibration = mycalibration, control = chronos.control() ) class(phy)<-"phylo" # create three normally distributed phenotypic traits traits <- cbind(rnorm(Ntip(phy)),rnorm(Ntip(phy)),rnorm(Ntip(phy))) rownames(traits) <- phy$tip.label # select two random tips, excluding sister taxa pairs <- apply(combn(phy$tip.label,2),2,function(x) nodepath(phy,which(phy$tip.label == x[1]), which(phy$tip.label == x[2]))) nosis <- combn(phy$tip.label,2)[,unlist(lapply(pairs, function(x) length(x) > 3))] focaltaxa <- nosis[,sample(1:ncol(nosis),1)] pwCheck(phy,focaltaxa) ## End(Not run)
It's a data matrix with 6 variables measured across 100 tips of a phylogeny ("phy" - also included)
I'll need to look into this