Title: | Analysis of Convergent Evolution |
Version: | 2.2.1 |
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. |
Depends: | R (≥ 3.5.0), ape, cluster, geiger, magick, phytools |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.1 |
Suggests: | R.rsp |
VignetteBuilder: | R.rsp |
NeedsCompilation: | no |
Packaged: | 2024-08-16 14:12:50 UTC; tstayton |
Author: | William Brightly [aut], C. Tristan Stayton [aut, cre] |
Maintainer: | C. Tristan Stayton <tstayton@bucknell.edu> |
Repository: | CRAN |
Date/Publication: | 2024-08-16 14:40:09 UTC |
Calculates maxdist for all pairs of taxa in a phylogeny.
Description
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.
Usage
allmaxdist(phyl, phendata, mat = TRUE)
Arguments
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 |
Details
Regarding the output: the matrix is better organized, but the list avoids all the zeroes and is probably better for making histograms.
Value
A matrix or list of all maxdist values for all pairs of taxa in the phylogeny.
References
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.
Examples
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.
Description
Extracts lineages leading to two tips, t1 and t2, from their most recent common ancestor.
Usage
ancestrallineages(phyl, phendata, t1, t2)
Arguments
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 |
Details
None
Value
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.
References
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.
Examples
phyl<-rtree(10)
phendata<-fastBM(phyl,nsim=2)
answer<-ancestrallineages(phyl,phendata,"t1","t2")
Quantifies convergent evolution by the ratio of the current to maximum past phenotypic distance between two or more lineages, as described in Stayton (2015). Code written by Jonathan S. Mitchell for Zelditch et al. (2017).
Description
calcConv prepares arguements for the CalcCs function
Usage
calcConv(phy, traits, focaltaxa, anc = NULL, VERBOSE = FALSE)
Arguments
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 |
Details
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.
Value
C1-C4 convergence measures for all pairs of putatively convergent taxa.
References
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.
Examples
phy<-rtree(100)
traits<-fastBM(phy,nsim=3)
focaltaxa<-c("t1","t50","t100")
answer<-calcConv(phy,traits,focaltaxa,anc=NULL,VERBOSE=FALSE)
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.
Description
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.
Usage
calcConvCt(
phy,
traits,
focaltaxa,
groups = NULL,
ace = NULL,
conservative = FALSE,
VERBOSE = FALSE
)
Arguments
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 |
Details
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
Value
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.
References
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.
Examples
## 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)
Calculates the C1-C4 measures of convergent evolution between two lineages as described in Stayton (2015). All measures quantify convergence by the ratio of current to maximum past phenotypic distance between lineages. Can be used as-is but more often will be used within the calcConv script. Code written by Jonathan S. Mitchell for Zelditch et al. (2017)
Description
calcCs calculates the C1-C4 measures of convergent evolution
Usage
calcCs(tips, ancList, allDists, phy, VERBOSE = FALSE)
Arguments
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 |
Details
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.
Value
C1-C4 convergence measures for all pairs of putatively convergent taxa.
References
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.
Computes Ct values for a pair of tips. Internal, called in calcConv.
Description
calcCsCt Computes Ct values for a pair of tips. Internal, called in calcConv.
Usage
calcCsCt(
tips,
ancList,
allDists,
phy,
VERBOSE = FALSE,
allVals,
edge,
lim.height = NULL
)
Arguments
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) |
Details
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
Value
A list of the Ct values
References
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.
Calculates all phenotypic changes that occur on all branches of a phylogeny.
Description
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.
Usage
calcchanges(phyl, phendata)
Arguments
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. |
Details
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.
Value
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.
References
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.
Examples
phyl<-rtree(10)
phendata<-fastBM(phyl,nsim=5)
changes<-calcchanges(phyl,phendata)
Uses simulations to assess the significance of C1-C4 measures of convergent evolution as described in Stayton (2015). Code written by Jonathan S. Mitchell for Zelditch et al. (2017)
Description
convSig calculates the significance of measures of convergent evolution.
Usage
convSig(phy, traits, focaltaxa, user.ace = NULL, nsim = 1000)
Arguments
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 |
Details
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.
Value
C1-C4 convergence measures for all pairs of putatively convergent taxa and their associated p-values.
References
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.
Examples
phy<-rtree(100)
traits<-fastBM(phy,nsim=3)
focaltaxa<-c("t1","t50","t100")
answer<-convSig(phy,traits,focaltaxa,user.ace=NULL,nsim=10)
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.
Description
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.
Usage
convSigCt(
phy,
traits,
focaltaxa,
groups = NULL,
user.ace = NULL,
nsim = 1000,
...
)
Arguments
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. |
Details
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
Value
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.
References
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.
Examples
## 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)
Quantify convergence by the number of convergent events
Description
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.
Usage
convnum(
phy,
phendata,
convtips,
plot = TRUE,
ellipse = NULL,
plotellipse = NULL
)
Arguments
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. |
Details
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.
Value
The number of lineages that have crossed into the region of trait space occupied by the convergent taxa.
References
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.
Examples
phy<-rtree(10)
phendata<-fastBM(phy,nsim=2)
convtips<-c("t1","t2","t3")
answer<-convnum(phy,phendata,convtips,plot=TRUE,ellipse=NULL,plotellipse=NULL)
Assess the significance of convergent evolution using simulations and the convnum metric
Description
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.
Usage
convnumsig(
phy,
phendata,
convtips,
nsim,
ellipse = NULL,
plot = FALSE,
plotellipse = NULL
)
Arguments
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. |
Details
None
Value
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.
References
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.
Examples
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)
Quantifies convergent evolution using the C1, C2, C3, and C4 measures as described by Stayton (2015).
Description
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.
Usage
convrat(phyl, phendata, convtips)
Arguments
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 |
Details
None
Value
Four numbers - C1, C2, C3, C4.
References
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.
Examples
phyl<-rtree(10)
phendata<-fastBM(phyl,nsim=2)
convtips<-c("t1","t2","t3")
answer<-convrat(phyl,phendata,convtips)
Tests the signifiance of convergent evolution by the ratio of the current to maximum past phenotypic distance
Description
convratsig tests the significance of convergence (as quantified by convrat) using evolutionary simulations.
Usage
convratsig(phyl, phendata, convtips, nsim)
Arguments
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 |
Details
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.
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.
References
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.
Examples
phyl<-rtree(10)
phendata<-fastBM(phyl,nsim=2)
convtips<-c("t1","t2","t3")
answer<-convratsig(phyl,phendata,convtips,10)
Find the ancestor of a given node in a phylogeny
Description
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.
Usage
findanc(phyl, node)
Arguments
phyl |
The phylogeny of interest in phylo format |
node |
The number of the node that you want the ancestor for |
Details
Returns a two-element vector. The node of the ancestor is first; the edge that connects that node with its ancestor is second.
Value
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).
References
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.
Examples
phyl<-rtree(10)
ancestor<-findanc(phyl,1)
Converts taxon names to tip/edge numbers
Description
Converts taxon names to corresponding tip/edge numbers in the phylogeny.
Usage
labelstonumbers(phyl, tips)
Arguments
phyl |
The phylogeny of interest in phylo format |
tips |
The names of the tips in question |
Details
Simply reads in taxon names, determines which tip or edge number they correspond to, and returns those values
Value
The numbers of all of the tips of interest.
References
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.
Examples
phyl<-rtree(10)
nums<-labelstonumbers(phyl,c("t1","t2","t3"))
Calculates the maximum phenotypic distance between the lineages leading to a pair of taxa.
Description
maxdist uses ancestral state reconstruction to determine the maximum distance between any ancestors of those two taxa.
Usage
maxdist(phyl, phendata, t1, t2)
Arguments
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 |
Details
Returns the maximum Euclidean distance between any pair of ancestors of the two taxa, whether or not those two ancestors are contemporaries.
Value
The maximum phenotypic distance between the two taxa
References
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.
Examples
phyl<-rtree(10)
phendata<-fastBM(phyl,nsim=2)
answer<-maxdist(phyl,phendata,1,10)
Reconstructs ancestral states for multiple characters
Description
Uses fastAnc to reconstruct ancestral states for multiple phenotypic characters
Usage
multianc(phy, phendata)
Arguments
phy |
The phylogeny of interest in phylo format |
phendata |
Phenotypic data for all tips |
Details
None
Value
A matrix with the tips data in the first n rows and the ancestral data in the remaining n-1 rows.
References
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.
Examples
phy<-rtree(10)
phendata<-fastBM(phy,nsim=2)
ancs<-multianc(phy,phendata)
Sample phylogeny for use in convevol examples and tutorial
Description
It's a sample phylogeny with 100 tips.
Format
A tree file
Plots calcConv or convSig output as a two-dimensional time series.
Description
plot2D Plots calcConv or convSig output as a two-dimensional time series.
Usage
plot2D(
Ct,
phy,
tip,
foc.trt,
trait,
pca = FALSE,
save = FALSE,
filename = "frame",
dir = NULL,
leg = FALSE,
leg.pos = "topleft",
width = 480,
height = 480,
...
)
Arguments
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 |
Details
None
Value
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
References
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.
Examples
## 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)
Plots calcConv or convSig output.
Description
plotCt Plots calcConv or convSig output.
Usage
plotCt(
output,
phy,
focaltaxa,
nsim = 25,
col = c("black", "forest green", "dodgerblue2", "firebrick1", "purple", "orange",
"salmon", "goldenrod", "springgreen2", "plum1"),
groups = NULL,
...
)
Arguments
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 |
Details
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.
Value
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
References
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.
Examples
#' 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 an ellipse
Description
Plots a minimum ellipse around a set of data
Usage
plotellipse(ellipse)
Arguments
ellipse |
Gives the parameters of the ellipse - output from the ellipsoidhull functon in cluster. |
Details
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
Value
Nothing - just plots the ellipse.
References
Maechler, M., Rousseeuw, P., Struyf, A., Hubert, M., Hornik, K.(2013). cluster: Cluster Analysis Basics and Extensions. R package version 1.14.4.
Extracts a vector of ancestors for a given taxon. Code written by Jonathan S. Mitchell for Zelditch et al. (2017)
Description
pullNodeSeq Extracts a vector of all ancestors of a given taxon in a phylogeny.
Usage
pullNodeSeq(phy, tip)
Arguments
phy |
The phylogeny of interest in phylo format |
tip |
The tip of interest |
Value
A vector of ancestors
References
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.
Examples
phylogeny<-rtree(100)
answer<-pullNodeSeq(phy=phylogeny,tip="t1")
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.
Description
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.
Usage
pwCheck(phy, focaltaxa, groups = NULL, conservative = FALSE)
Arguments
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. |
Value
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
References
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.
Examples
## 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)
Sample data for use in convevol examples and tutorial
Description
It's a data matrix with 6 variables measured across 100 tips of a phylogeny ("phy" - also included)
Format
I'll need to look into this