Title: | Continuous-Time Phylogenetic Modeling |
---|---|
Description: | Functions for identifying, fitting, and applying continuous-time stochastic models to phylogenetic data. The package is based on methods introduced in Fleming et al (2014) <doi:10.1086/675504>. |
Authors: | Michael J. Noonan [aut, cre], Christen H. Fleming [aut] |
Maintainer: | Michael Noonan <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-08 03:43:45 UTC |
Source: | https://github.com/noonanm/ctpm |
This function is currently a wrapper for methods implemented in the package slouch
.
ctpm.fit(data, phylo, model = NULL, time.units = "Ma")
ctpm.fit(data, phylo, model = NULL, time.units = "Ma")
data |
A vector of continuous species trait data. This vector needs to be of the same length and same order as phylo$tip.label. |
phylo |
An object of class 'phylo'. |
model |
The model to fit. Can be one of |
time.units |
A character defining the units of the edge lengths of the phylogentic tree. Defaults to "Ma" |
Fits evolutionary models to species trait data using the methods implemented in the package slouch
and returns a model fit object (class ctmm) that is used for plotting a fitted model against an emprical variogram.
Returns a model fit object (class ctmm) that is used for plotting a fitted model against an emprical variogram.
Running summary
on the fitted model is not currently meaningful.
M. J. Noonan, C. H. Fleming.
Noonan, M. J., Fagan, W. F., and Fleming C. H. (2021) “A semi-variance approach to visualising phylogenetic autocorrelation”. Methods in Ecology and Evolution, in press.
vignette("variograms", package = "ctpm")
, plot.variogram
, %#%
.
#Load package and data library(ctpm) data("moid_traits") data("musteloids") #Extract the trait of interest from the full dataset SSD <- moid_traits$SSD #Calculate variogram SVF <- variogram(SSD, musteloids) #Fit the model FIT <- ctpm.fit(SSD, musteloids, model = "BM") #Plot the variogram and fitted model plot(SVF, FIT)
#Load package and data library(ctpm) data("moid_traits") data("musteloids") #Extract the trait of interest from the full dataset SSD <- moid_traits$SSD #Calculate variogram SVF <- variogram(SSD, musteloids) #Fit the model FIT <- ctpm.fit(SSD, musteloids, model = "BM") #Plot the variogram and fitted model plot(SVF, FIT)
Morphological and life history data on mean male body mass (kg), mean male body mass (kg), sexual size dimorphism (male mass/female mass), mean male body length (mm), mean female body length (mm), mean litter size (number of offspring), social class (Solitary, Pairs, Variable Groups, Groups), and diet (Carnivorous, Piscivorous, Insectivorous, Omnivorous, Frugivorous/Herbivorous) for 57 species of extant musteloids.
data("moid_traits")
data("moid_traits")
An object of class "data.frame".
Noonan, M. J., Johnson, P. J., Kitchener, A. C., Harrington, L. A., Newman, C., and Macdonald, D. W. (2016). Sexual size dimorphism in musteloids: An anomalous allometric pattern is explained by feeding ecology. Ecology and evolution, 6(23), 8495-8501. doi:10.1002/ece3.2480. Noonan, M. J., Fagan, W. F., and Fleming C. H. (2021) “A semi-variance approach to visualising phylogenetic autocorrelation”. Methods in Ecology and Evolution, in press.
# Load package and data library(ctpm) data("moid_traits") # Plot male mass versus female mass plot(moid_traits$Mass.M ~ moid_traits$Mass.F)
# Load package and data library(ctpm) data("moid_traits") # Plot male mass versus female mass plot(moid_traits$Mass.M ~ moid_traits$Mass.F)
A phylogenetic tree of Musteloidea.
data("musteloids")
data("musteloids")
An object of class "phylo", from package "ape".
Law, Chris J. and Slater, Graham J. and Mehta, Rita S. (2017). Lineage Diversity and Size Disparity in Musteloidea: Testing Patterns of Adaptive Radiation Using Molecular and Fossil-Based Methods. Systematic Biology, 67(1), 127-144. doi:10.1093/sysbio/syx047.
# Load package and tree library(ctpm) data("musteloids") # Plot the phylogeny plot(musteloids)
# Load package and tree library(ctpm) data("musteloids") # Plot the phylogeny plot(musteloids)
Produces plots of varigram objects (semi-variance vs. time lag) and model semi-variance functions, with approximate confidence intervals around the semi-variance estimates.
## S3 method for class 'vg' plot(x, CTPM = NULL, col="black", col.CTPM = "red", fraction = 1, ...)
## S3 method for class 'vg' plot(x, CTPM = NULL, col="black", col.CTPM = "red", fraction = 1, ...)
x |
A |
CTPM |
A |
col |
Color for the empirical variogram. Can be an array. |
col.CTPM |
Color for the model. Can be an array. |
fraction |
The proportion of the variogram object, |
... |
Additional |
For highly irregularly phylogenetic distances with few species, it may be useful to set complete = FALSE
to coarsen the variogram. When this is the cases, species are binned across lags, with the number of lags estimated using either kmeans
or Gaussian Mixture Modelling GMM
clustering with n classes = .
Returns a plot of semi-variance vs. time lag, with the empirical variogram in black and the ctpm
semi-variance function in red if specified.
The errors of the empirical variogram are correlated. Smooth trends are not necessarily significant.
M. J. Noonan, C. H. Fleming.
Noonan, M. J., Fagan, W. F., and Fleming C. H. (2021) “A semi-variance approach to visualising phylogenetic autocorrelation”. Methods in Ecology and Evolution, in press.
vignette("variograms", package = "ctpm")
, variogram
, ctpm.fit
.
#Load package and data library(ctpm) data("moid_traits") data("musteloids") #Extract the trait of interest from the full dataset SSD <- moid_traits$SSD #Calculate variogram SVF <- variogram(SSD, musteloids) #Plot the variogram plot(SVF)
#Load package and data library(ctpm) data("moid_traits") data("musteloids") #Extract the trait of interest from the full dataset SSD <- moid_traits$SSD #Calculate variogram SVF <- variogram(SSD, musteloids) #Plot the variogram plot(SVF)
This function calculates the empirical variogram of phylogenetic data for visualizing stationary (time-averaged) autocorrelation structure. One of two weighting algorithms can be used.
variogram(data, phylo, weights = "IID", complete = FALSE, time.units = "Ma", trait.units = NULL, progress = TRUE, algorithm = "GMM")
variogram(data, phylo, weights = "IID", complete = FALSE, time.units = "Ma", trait.units = NULL, progress = TRUE, algorithm = "GMM")
data |
A vector of continuous species trait data. This vector needs to be of the same length and same order as |
phylo |
An object of class 'phylo'. |
weights |
The weights to apply when calculating the semi-variances. Can be one of |
time.units |
A character string defining the units of the branch lengths. Defaults to |
trait.units |
A character string defining the units of the trait being analysed. Defaults to uniteless. |
complete |
A logical value indicating whether the semi-variance is to be calculated across all possible lags. Defalts to |
algorithm |
A character string defining the algorithm to apply when calculating the time-lag bins. Can be one of |
progress |
A logical value indicating whether to include a progress bar. |
weights
The weights for the semi-variance are calculated based on an assumption about the form of the the correlation matrix. If the phylogenetic process is Independent and Identically Distributed (IID), then it is sufficient to consider a correlation matrix, where the diagonal is 1 and the off-diagonal is if species pair
and
share one species in common and 0 otherwise.
If the phylogenetic process is BM, then it is sufficient to consider a correlation matrix where the diagonal is 1 and the off-diagonal is the squared proportion of time lag during which the backward-in-time-forward-in-time tip-branch-tip trajectories correspond to the same species.
complete
If calculating all pairwaise phylogenetic distances results in highly irregular time series (which is usually the case), it is more useful to coarsen the variogram. This is the case when complete = FALSE
. Species are binned across lags, with the number of lags estimated using either kmeans
or Gaussian Mixture Modelling GMM
clustering with n classes = .
Returns a variogram object (class variogram) which is a dataframe containing the time-lag, lag
, the semi-variance estimate at that lag, SVF
, and the degrees of freedom on the estimated semi-variance DOF
.
Can be slow on very large phylogenies.
M. J. Noonan, C. H. Fleming.
Noonan, M. J., Fagan, W. F., and Fleming C. H. (2021) “A semi-variance approach to visualising phylogenetic autocorrelation”. Methods in Ecology and Evolution, in press.
vignette("variograms", package = "ctpm")
, plot.variogram
, %#%
, KMeans_rcpp
, GMM
.
#Load package and data library(ctpm) data("moid_traits") data("musteloids") #Extract the trait of interest from the full dataset SSD <- moid_traits$SSD #Calculate variogram SVF <- variogram(SSD, musteloids) #Plot the variogram plot(SVF)
#Load package and data library(ctpm) data("moid_traits") data("musteloids") #Extract the trait of interest from the full dataset SSD <- moid_traits$SSD #Calculate variogram SVF <- variogram(SSD, musteloids) #Plot the variogram plot(SVF)