Convert a phylogeny into the correlation matrix used as a random-
effect structure in phylogenetic meta-analysis (metafor::rma.mv)
or phylogenetic mixed models (MCMCglmm, brms, etc.).
Arguments
- x
A
phyloobject, amultiPhylo, or apr_tree_result(the$treeslot is extracted). FormultiPhyloinput, returns a list of correlation matrices.- corr
Logical. Pass through to
ape::vcv().TRUE(default) returns a correlation matrix (diagonal = 1);FALSEreturns the variance-covariance matrix.- ...
Additional arguments forwarded to
ape::vcv().
Value
A square symmetric matrix with row/column names equal to
the tip labels. For multiPhylo input, a list of such matrices.
Details
Wraps ape::vcv() with corr = TRUE. Designed to slot in after
pr_get_tree() when the goal is meta-analysis, where typically:
Topology comes from Open Tree of Life (
source = "rotl") because the species span many higher taxa.Polytomies are resolved at random (
resolve_polytomies = TRUE).Branch lengths are computed via Grafen's method (
branch_lengths = "grafen") because rotl's edge lengths are unit-length placeholders.The correlation matrix is computed once and reused as
random = ~1|species'sR = list(species = phy_cor)inmetafor::rma.mv()(orrandom = ~specieswithcov.formula = ~ phyloinMCMCglmm).
The correlation matrix has the property that, for a Brownian-motion model on a tree with branch lengths in time units, two species' off-diagonal entry equals the time from root to their MRCA divided by the time from root to tip. So an ultrametric tree always has diagonal = 1 (every tip is the same distance from the root).
For meta-analysis with rotl topology + Grafen's method, the
resulting matrix is the standard Pagel's lambda = 1 phylogenetic
correlation that metafor::rma.mv() accepts directly.
References
Paradis, E., & Schliep, K. (2019). ape 5.0: an environment for modern phylogenetics and evolutionary analyses in R. Bioinformatics, 35(3), 526–528. doi:10.1093/bioinformatics/bty633
Cinar, O., Nakagawa, S., & Viechtbauer, W. (2022). Phylogenetic multilevel meta-analysis: a simulation study on the importance of modelling the phylogeny. Methods in Ecology and Evolution, 13(2), 383–395. doi:10.1111/2041-210X.13760
See also
pr_get_tree() (use with branch_lengths = "grafen"
and resolve_polytomies = TRUE for the meta-analysis path);
ape::vcv() for the underlying computation.
Examples
set.seed(1)
tr <- ape::rcoal(5) # ultrametric, bifurcating
phy_cor <- pr_phylo_cor(tr)
dim(phy_cor)
#> [1] 5 5
all(diag(phy_cor) == 1)
#> [1] TRUE
if (FALSE) { # \dontrun{
# End-to-end meta-analysis prep
res <- pr_get_tree(c("Homo sapiens", "Pan troglodytes",
"Mus musculus", "Rattus norvegicus"),
source = "rotl",
resolve_polytomies = TRUE,
branch_lengths = "grafen")
phy_cor <- pr_phylo_cor(res)
# phy_cor can now be supplied to downstream meta-analysis models.
} # }