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.54938871 0.39210678 0.71277467 0.7154914 0.9640762
## random 0.06048736 -0.01865426 0.09961004 0.1009364 0.1136136
## bm 0.52960782 0.44174683 0.57384692 0.5743103 0.9523392
##
## $pvalue
## Cmean I K K.star Lambda
## mass 0.001 0.001 0.001 0.001 0.0010000
## random 0.251 0.336 0.808 0.803 0.5909521
## bm 0.001 0.001 0.002 0.002 0.0010000
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)