R—计算系统发育多样性PD (Calculate Faith’s Phylogenetic Diversity)

636 阅读1分钟

R计算 PD Calculate Faith’s Phylogenetic Diversity

网址: cran.r-project.org/web/package…

Description: Calculate the sum of the total phylogenetic branch length for one or multiple samples.

Usage: pd(samp, tree, include.root=TRUE)

Arguments

samp: Community data matrix

tree:A phylo tree object

include.root: Should the root node be included in all PD calculations (default = TRUE)

#加载包 library(picante)

library(ape)

#测试数据 data(phylocom)

pd(phylocomsample,phylocomsample, phylocomphylo)

  1. 读取树文件: tree= read.tree("D:/timberproject2021/sp_tree20210707.tre")

  2. 读取samp数据矩阵 b = read.csv("D:/timberproject2021/GridsID-species2.csv", header = T, row.names=1)

  3. 计算pd c = pd(b, tree, include.root=TRUE)

  4. 导出计算结果 write.csv(c,file = "D:/aaa.csv")

报错:修改树: If youwant the root ofyour tree to correspond to the most recent ancestor of the taxaactually present in your sample, you should prune the tree before running pd:

prunedTree<-prune.sample(b,tree)

参考资料:

daijiang.name/en/2014/05/…

原文网址:www.jianshu.com/p/789a93c2f…