Creates a phylogenetic tree with branch lengths and a diagonal matrix to represent a (generalized) 3-point structured covariance matrix from a trait evolution model on a known tree.
transf.branch.lengths(phy, model = c("BM", "OUrandomRoot",
"OUfixedRoot", "lambda", "kappa", "delta", "EB", "trend"),
parameters = NULL, check.pruningwise = TRUE,
check.ultrametric=TRUE, D=NULL, check.names = TRUE)
a phylogenetic tree of type phylo with branch lengths.
a phylogenetic model. Default is "BM", for Brownian motion. Alternatives are "OU", "lambda", "kappa", "delta", "EB" and "trend".
List of parameters for the model (see Note).
if FALSE, the tree is assumed to be in pruningwise order.
if FALSE, the tree is assumed to be
ultrametric and D
needs to be provided. This is used for the
OU transformations only.
vector of ajustments for the external edge lengths, to make the tree ultrametric. Used for the OU transformations only.
D
needs to have names that match tip labels
unless check.names=FALSE, in which case the elements in D
are
assumed to come in the same order as tip labels in the tree.
a rooted tree with a root edge and transformed branch lengths.
a vector containing the diagonal elements of the diagonal matrix for the generalized 3-point structure.
Possible phylogenetic models are the Brownian motion model (BM), the
Ornstein-Uhlenbeck model (OU), Pagel's lambda model (lambda), Pagel's
kappa model (kappa), Pagel's delta model (delta), the early burst model
(EB), and the Brownian motion with a trend (trend). Edge lengths are
unchanged under BM and the trend model.
Under the kappa model, each branch length \(\ell\) is transformed
to \(\ell^\kappa\).
If the time from the root to a node is \(t\) in phy
,
it is transformed to
\( T * (t/T)^\delta\)
under the delta model, where \(T\) is the maximum root-to-tip
distance. The transformed tree has the same \(T\).
Under EB, \(t\) is transformed to
\((e^{\mathrm{rate}*t}-1)/\mathrm{rate}\),
which is very close to \(t\) (i.e. to the BM model)
when rate
is close to 0.
Under the lambda model, the time \(t\) from the
root to a node is transformed to
\(\lambda t\) for an internal node and
is unchanged for a tip.
Under "OUrandomRoot", \(t\) is transformed to
\(\exp(-2\alpha (T-t))\),
where \(T\) is now the mean root-to-tip distance.
Under "OUfixedRroot", \(t\) is transformed to
\(\exp(-2\alpha (T-t))(1-\exp(-2 \alpha t))\).
Under the OU models, diagWeight
contains \(\exp(\alpha
D_i)\) for tip \(i\), where \(D_i\) is the extra
length added to tip \(i\) to make the tree ultrametric.
Ho, L. S. T. and Ane, C. A linear-time algorithm for Gaussian and non-Gaussian trait evolution models. Systematic Biology 63(3):397-408.
# NOT RUN {
set.seed(123456)
tre1 = rcoal(10)
tre2 = transf.branch.lengths(phy=tre1, model="OUrandomRoot",
parameters = list(alpha=1))
par(mfrow = c(2,1))
plot(tre1)
plot(tre2$tree,root.edge=TRUE)
# }
Run the code above in your browser using DataLab