我需要在两个变量之间执行相关性测试(返回r,t和p.value),这两个变量说明了个体之间的系统发育相关结构。在R中有什么简单的方法可以做到吗?
发布于 2017-08-22 20:44:48
来自ape包,特别是?ape::pic (“系统发育独立的对比”):
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 如果你打算做很多这方面的工作,你可能想要得到Paradis的Analysis of Phylogenetics and Evolution with R,然后看看phylogenetics task view
https://stackoverflow.com/questions/45817925
复制相似问题