R计算功能多样性— functional diversity (FD)

一般植物功能特征被划分为3类:一是植物形态特征, 包括生长型、生活型、植株高度等;二是植物生殖特征,包括传粉方式、扩散方式、种子重量等;三是植物生理特征, 如植物固氮能力等[30].——参考

为研究中包括的每个物种创建一个定性和/或定量性状的矩阵;使用R中的FD包来计算你选择的性状的种间Gower距离。Gower距离矩阵可用于绘制树状图,描述物种间的相似性/不相似性,然后你可以使用R中的FD或BAT或其他软件包,以类似于计算系统发育多样性(PD)的方式,总结连接每个物种库中的物种的分支长度。 参考:https://www.researchgate.net/post/Can_anyone_help_with_measuring_functional_diversity

FD computes different multidimensional FD indices. Tocompute FD indices, a species-by-trait(s) matrix is required (or at least aspecies-by-species distance matrix). gowdis computes the Gower dissimilarityfrom different trait types (continuous, ordinal, nominal, or binary), andtolerates NAs. It can treat ordinal variables as described by Podani (1999),and can handle asymetric binary variables and variable weights. gowdis iscalled bydbFD, the main function of FD.】

dbFD uses principal coordinates analysis (PCoA) toreturn PCoA axes, which are then used as ‘traits’to compute FD. dbFD computesseveral multidimensional FD indices, including the three indices of Villéger etal. (2008): functional richness (FRic), functional evenness (FEve), andfunctional divergence (FDiv). It also computesfunctional dispersion (FDis) (Laliberté and Legendre 2010), Rao’s quadraticentropy (Q) (Botta-Dukát 2005), a posteriori functional group richness (FGR),and the community-level weighted means of trait values (CWM), an index offunctional composition. Some of these indices can be weighted by speciesabundances. dbFD includes several options for flexibility.

FD一般是FR,FE,FD三个层面,FR指功能多样性丰富度,FE值功能多样性均匀度,FD值功能多样性离散度。

Package FD:computes different multidimensional functional diversity (FD) indices

基本命令: dbFD(x, a, w, w.abun = TRUE, stand.x = TRUE,…)

x: 功能特征的矩阵或数据框架

a: 包括出现在x中的物种丰富度矩阵。The number of species (columns) in a must match the number of species (rows) in x. In addition, thespecies labels in a and x must be identical and in the same order. (x和a两个数据集的物种数目一致和顺序相同)

1. 数据准备:
建立两个数据dataframe, 保持两个数据集中的物种名称顺序保持一致:

FD包官方测试数据:蓝奏云: https://wwe.lanzoui.com/iG2lNqyrt5g (此数据集为FD包的官方数据,具体请查看https://cran.r-project.org/web/packages/FD/index.html)
情况1:手动录入的数据,或者数据量少的数据可手动调节;

情况2:物种较多,两个数据集包含较多的物种名称不一致情况;

解决办法:使用excel,若X和a中的物种不完全相符,以物种较少的数据物种数目为准,删减x中的数据以对应a。利用数据透视表功能建立数据矩阵;注意:a中物种名称若出现空格,将不能成功读取,会出现格式变化,建议标准物种名称为“Abies_chensiensis”(加短横线)。

  1. 原始数据:列A代表物种名称,列B代表所在的群落

  2. 数据透视表插入,以物种作为行坐标

  3. 颠倒横纵坐标,让物种信息处于列

  4. FD包计算
    2.1 加载包
    library(“FD”) #加载FD包

2.2 加载数据
traits <- read.csv(“D:/xxx.csv”, row.names=1) #x,加载数据

species <- read.csv(“D:/xxx.csv”, header=T,row.names=1) #a,加载数据

2.3 数据检查
rownames(traits) #查看导入数据的行列名称,是否有不一致情况

colnames(traits) #查看导入数据的行列名称,是否有不一致情况

rownames(species) #查看导入数据的行列名称,是否有不一致情况

colnames(species) #查看导入数据的行列名称,是否有不一致情况

2.4 计算FD
results = dbFD(traits, species, corr=“lingoes”) #dbFD计算FD值

2.5 数据导出
write.csv(results,file = “D:/ xxx-FD-results.csv”) #数据导出,结果导出为csv格式数据

2.6 可能的报错信息

在这里插入图片描述
原因:species 和trait中物种数目不一致,需要将两个数据矩阵中物种数量和顺序一致!

在这里插入图片描述
可能原因:trait性状矩阵中存在不能识别的性状变量,改为数值型变量试试(如“常绿”、“落叶”改为“1”、”2“)

在这里插入图片描述
原因:species 和trait中物种顺序不一致,需要将两个数据矩阵中物种数量和顺序一致!

报错信息:
#Error in dbFD(traits, species) : At least onespecies does not occur in any community (zero total abundance across allcommunities).
解决办法:x和a两个数据集物种不一致,存在无功能性状的空白物种数据,需要删除样方中不存在的物种

报错信息:
#Error in dbFD(traits, species) :
Species xspecies distance matrix was still is not Euclidean after ‘sqrt’ correction. Useanother correction method.
解决办法:a =dbFD(traits, species, corr=“lingoes”)

报错信息:
#Error in dbFD(traits, species) : At least onespecies does not occur in any community (zero total abundance across allcommunities).

解决办法:x和a两个数据集物种不一致,存在无功能性状的空白物种数据,需要删除样方中不存在的物种;

报错信息:
#Error in dbFD(traits, species) : Species xspecies distance matrix was still is not Euclidean after ‘sqrt’ correction. Useanother correction method.
解决办法:a =dbFD(traits, species, corr=“lingoes”)

原创不易,点赞为谢!
文章原文: https://www.jianshu.com/p/b91f076584fd

评论 25
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

雨林课堂

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值