First, we load the package phylosignal and the dataset
carnivora from adephylo.
Here is a phylogenetic tree of 19 carnivora species.
And we create a dataframe of 3 traits for the 19 carnivora species.
dat <- list()
dat$mass <- carni19$bm
dat$random <- rnorm(19, sd = 10)
dat$bm <- rTraitCont(tre)
dat <- as.data.frame(dat)We can combine phylogeny and traits into a phylo4d
object.
## $stat
## Cmean I K K.star Lambda
## mass 0.5493887 0.3921068 0.7127747 0.71549137 9.640762e-01
## random -0.0173566 -0.1313433 0.0945843 0.09610554 6.846792e-05
## bm 0.5874005 0.4566148 0.9232223 0.92371346 9.492529e-01
##
## $pvalue
## Cmean I K K.star Lambda
## mass 0.001 0.001 0.001 0.001 0.001
## random 0.382 0.753 0.844 0.844 1.000
## bm 0.001 0.001 0.001 0.001 0.001
mass.crlg <- phyloCorrelogram(p4d, trait = "mass")
random.crlg <- phyloCorrelogram(p4d, trait = "random")
bm.crlg <- phyloCorrelogram(p4d, trait = "bm")
plot(mass.crlg)carni.lipa <- lipaMoran(p4d)
carni.lipa.p4d <- lipaMoran(p4d, as.p4d = TRUE)
barplot.phylo4d(p4d, bar.col=(carni.lipa$p.value < 0.05) + 1, center = FALSE , scale = FALSE)barplot.phylo4d(carni.lipa.p4d, bar.col = (carni.lipa$p.value < 0.05) + 1, center = FALSE, scale = FALSE)