当前位置: 代码迷 >> 综合 >> R—计算系统发育多样性PD (Calculate Faith’s Phylogenetic Diversity)
  详细解决方案

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

热度:33   发布时间:2023-12-07 04:05:33.0

R计算 PD Calculate Faith’s Phylogenetic Diversity

网址: https://cran.r-project.org/web/packages/picante/index.html

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(phylocom s a m p l e , p h y l o c o m sample, phylocom sample,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)

参考资料:

https://daijiang.name/en/2014/05/04/notes-func-phylo-book-1/

原文网址:https://www.jianshu.com/p/789a93c2f62a