jsegrestin
jsegrestin

Reputation: 21

Phylogenetic correlation test

I need to perform a correlation test (returning r, t and p.value) between two variables that accounts for a phylogenetic correlation structure between individuals. Is there any simple way to do that in R?

Upvotes: 2

Views: 699

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226247

From the ape package, specifically ?ape::pic ("phylogenetically independent contrast"):

 library(ape)
 cat("((((Homo:0.21,Pongo:0.21):0.28,",
        "Macaca:0.49):0.13,Ateles:0.62):0.38,Galago:1.00);",
        file = "ex.tre", sep = "\n")
 tree.primates <- read.tree("ex.tre")
 X <- c(4.09434, 3.61092, 2.37024, 2.02815, -1.46968)
 Y <- c(4.74493, 3.33220, 3.36730, 2.89037, 2.30259)
 names(X) <- names(Y) <- c("Homo", "Pongo", "Macaca", "Ateles", "Galago")
 pic.X <- pic(X, tree.primates)
 pic.Y <- pic(Y, tree.primates)
 cor.test(pic.X, pic.Y)

 # Pearson's product-moment correlation
 # 
 # data:  pic.X and pic.Y
 # t = -0.85623, df = 2, p-value = 0.4821
 # alternative hypothesis: true correlation is not equal to 0
 # 95 percent confidence interval:
 # -0.9874751  0.8823934
 # sample estimates:
 # cor 
 # -0.5179156 

If you're going to do much of this work you might want to get Paradis's Analysis of Phylogenetics and Evolution with R, and see the phylogenetics task view

Upvotes: 1

Related Questions