Title: | Explore Phylogenetic Signals Using Distance-Based Methods |
---|---|
Description: | A unified method, called M statistic, is provided for detecting phylogenetic signals in continuous traits, discrete traits, and multi-trait combinations. Blomberg and Garland (2002) <doi:10.1046/j.1420-9101.2002.00472.x> provided a widely accepted statistical definition of the phylogenetic signal, which is the "tendency for related species to resemble each other more than they resemble species drawn at random from the tree". The M statistic strictly adheres to the definition of phylogenetic signal, formulating an index and developing a method of testing in strict accordance with the definition, instead of relying on correlation analysis or evolutionary models. The novel method equivalently expressed the textual definition of the phylogenetic signal as an inequality equation of the phylogenetic and trait distances and constructed the M statistic. Also, there are more distance-based methods under development. |
Authors: | Liang Yao [aut, cre], Ye Yuan [aut] |
Maintainer: | Liang Yao <dylanyao@126.com> |
License: | GPL (>= 3) |
Version: | 0.2.2 |
Built: | 2025-02-17 06:01:40 UTC |
Source: | https://github.com/anonymous-eco/phylosignaldb |
gower_dist()
calculates Gower distance among observations or species.
gower_dist(x, type = list(), dist_format = c("matrix", "dist"))
gower_dist(x, type = list(), dist_format = c("matrix", "dist"))
x |
A data frame. The columns usually represent trait data, and the row names are species names. |
type |
A list for specifying the variable types of the columns in |
dist_format |
The class of the return value. Default is "matrix". |
A matrix or dist object containing the Gower distance among the rows of x
.
Gower, J.C. (1971) A general coefficient of similarity and some of its properties. Biometrics: 857-871.
Kaufman, L. & Rousseeuw, P.J. (1990) Finding Groups in Data: An Introduction to Cluster Analysis. Wiley, New York.
cluster::daisy()
which this function wraps.
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5")))
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5")))
M_rand_perm
calculates M statistic for trait(s) after randomly permuting the species names or tip labels in phylogeny.
The M statistic is a unified method for detecting phylogenetic signals in continuous traits,
discrete traits, and multi-trait combinations.
Blomberg and Garland (2002) provided a widely accepted statistical definition of
the phylogenetic signal, which is the "tendency for related species to resemble
each other more than they resemble species drawn at random from the tree".
The M statistic strictly adheres to the definition of phylogenetic signal,
formulating an index and developing a method of testing in strict accordance
with the definition, instead of relying on correlation analysis or evolutionary models.
The novel method equivalently expressed the textual definition of the phylogenetic signal
as an inequality equation of the phylogenetic and trait distances and constructed the M statistic.
M_rand_perm( trait_dist = NULL, phy = NULL, reps = 999, auto_multi2di = TRUE, cores = 1 )
M_rand_perm( trait_dist = NULL, phy = NULL, reps = 999, auto_multi2di = TRUE, cores = 1 )
trait_dist |
A distance object of class |
phy |
A phylogenetic tree of class phylo. |
reps |
An integer. The number of random permutations. |
auto_multi2di |
A logical switch, |
cores |
Number of cores to be used in parallel processing.
Default is 1, indicating no parallel computation is performed.
If set to 0, parallel computation is executed using |
A list object containing two components.
Component $permuted
is the vector of M values obtained after random permutation for reps
times;
component $observed
is the value of M statistic obtained from the original input data.
Blomberg, S.P. & Garland, T., Jr (2002) Tempo and mode in evolution: phylogenetic inertia, adaptation and comparative methods. Journal of Evolutionary Biology, 15(6): 899-910.
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5"))) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5"))) M_rand_perm(trait_dist, turtles$phylo, reps = 99) # reps=999 better
M_stat
calculates the value of M statistic as a measurement of the strength of
the phylogenetic signal for the trait(s). The trait(s) could be continuous, discrete, or multi-variable.
Blomberg and Garland (2002) provided a widely accepted statistical definition of
the phylogenetic signal, which is the "tendency for related species to resemble
each other more than they resemble species drawn at random from the tree".
The M statistic strictly adheres to the definition of phylogenetic signal,
formulating an index and developing a method of testing in strict accordance
with the definition, instead of relying on correlation analysis or evolutionary models.
The novel method equivalently expressed the textual definition of the phylogenetic signal
as an inequality equation of the phylogenetic and trait distances and constructed the M statistic.
M_stat(trait_dist = NULL, phy = NULL, auto_multi2di = TRUE)
M_stat(trait_dist = NULL, phy = NULL, auto_multi2di = TRUE)
trait_dist |
A distance object of class |
phy |
A phylogenetic tree of class phylo. |
auto_multi2di |
A logical switch, |
A value that lies between 0 and 1, inclusive.
Blomberg, S.P. & Garland, T., Jr (2002) Tempo and mode in evolution: phylogenetic inertia, adaptation and comparative methods. Journal of Evolutionary Biology, 15(6): 899-910.
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) M_stat(trait_dist, turtles$phylo) # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) M_stat(trait_dist, turtles$phylo) # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) M_stat(trait_dist, turtles$phylo) # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5"))) M_stat(trait_dist, turtles$phylo)
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) M_stat(trait_dist, turtles$phylo) # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) M_stat(trait_dist, turtles$phylo) # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) M_stat(trait_dist, turtles$phylo) # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5"))) M_stat(trait_dist, turtles$phylo)
phylosignal_M
computes the M statistic for trait(s) and evaluates
its statistical significance through a random permutation test.
The M statistic is a unified method for detecting phylogenetic signals in continuous traits,
discrete traits, and multi-trait combinations.
Blomberg and Garland (2002) provided a widely accepted statistical definition of
the phylogenetic signal, which is the "tendency for related species to resemble
each other more than they resemble species drawn at random from the tree".
The M statistic strictly adheres to the definition of phylogenetic signal,
formulating an index and developing a method of testing in strict accordance
with the definition, instead of relying on correlation analysis or evolutionary models.
The novel method equivalently expressed the textual definition of the phylogenetic signal
as an inequality equation of the phylogenetic and trait distances and constructed the M statistic.
phylosignal_M( trait_dist = NULL, phy = NULL, reps = 999, auto_multi2di = TRUE, output_M_permuted = FALSE, cores = 1 )
phylosignal_M( trait_dist = NULL, phy = NULL, reps = 999, auto_multi2di = TRUE, output_M_permuted = FALSE, cores = 1 )
trait_dist |
A distance object of class |
phy |
A phylogenetic tree of class phylo. |
reps |
An integer. The number of random permutations. |
auto_multi2di |
A logical switch, |
output_M_permuted |
A logical switch, |
cores |
Number of cores to be used in parallel processing.
Default is 1, indicating no parallel computation is performed.
If set to 0, parallel computation is executed using |
A list object containing two components.
Component $permuted
is the vector of M values obtained after random permutation for reps
times;
component $observed
is the value of M statistic obtained from the original input data.
Blomberg, S.P. & Garland, T., Jr (2002) Tempo and mode in evolution: phylogenetic inertia, adaptation and comparative methods. Journal of Evolutionary Biology, 15(6): 899-910.
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5"))) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better
data("turtles") # Continuous trait trait_df <- data.frame(M1 = turtles$traits$M1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Nominal discrete trait trait_df <- data.frame(B1 = turtles$traits$B1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = 1)) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Ordinal discrete trait trait_df <- data.frame(CS1 = turtles$traits$CS1, row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(ordered = 1)) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better # Multi-trait Combinations trait_df <- data.frame(turtles$traits[, c("M1", "M2", "M3", "M4", "M5")], row.names = turtles$traits$specie) trait_dist <- gower_dist(x = trait_df, type = list(factor = c("M4", "M5"))) phylosignal_M(trait_dist, turtles$phylo, reps = 99) # reps=999 better
An ecological trait dataset for turtles. The dataset was derived from the recently published ReptTraits dataset (Oskyrko et al., 2024), extracting species classified under the major group Testudines (comprising 361 species). Only ecological traits with more than 50% of the species having trait records were retained. The phylogeny of turtles was derived by pruning from the maximum clade credibility tree with 288 tips provided in Thomson et al. (2021). Only those species that are present in both the ReptTraits dataset and the turtle phylogenetic tree were selected. Ultimately, the dataset comprised 240 species, encompassing 5 morphology traits, 2 behaviour traits, 2 life history traits, 5 habitat variables, and 2 variables concerning species conservation status.
turtles data("turtles")
turtles data("turtles")
turtles
is a list object with 3 components:
The ecological traits of turtles as an object of class data.frame
/tibble
.
The phylogeny of turtles as an object of class phylo
.
The full names and id of ecological traits.
More details in Oskyrko et al. (2024) and Thomson et al. (2021).
Oskyrko, O., Mi, C., Meiri, S. & Du, W. (2024) ReptTraits: a comprehensive dataset of ecological traits in reptiles. Scientific Data, 11(1): 243.
Thomson, R.C., Spinks, P.Q. & Shaffer, H.B. (2021) A global phylogeny of turtles reveals a burst of climate-associated diversification on continental margins. Proceedings of the National Academy of Sciences, 118(7): e2012215118.