用 vegan 进行排序分析 米湘成

65
Institute of Botany, the Chinese Academy of Sciences 用 vegan 用用用用用 用用用

Upload: greg

Post on 11-Feb-2016

334 views

Category:

Documents


0 download

DESCRIPTION

用 vegan 进行排序分析 米湘成. 一、 vegan 软件包 是 Vegetation analysis 的缩写。是一个群落分析的软件。 作者: Jari Oksanen http://cc.oulu.fi/~jarioksa/softhelp/vegan.html >library(vegan). 群落数据. >gtsdata= read.table(“gtsdata.txt”,header=T); >gtsdata >dim(gtsdata) - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

用 vegan 进行排序分析米湘成

Page 2: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

一、 vegan 软件包是 Vegetation analysis 的缩写。是一个群落分析的软件。作者: Jari Oksanen

http://cc.oulu.fi/~jarioksa/softhelp/vegan.html

>library(vegan)

Page 3: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

群落数据>gtsdata=read.table(“gtsdata.txt”,header=T);

>gtsdata>dim(gtsdata) CASEYR SCHSUP DAPOLD PINMAS CINSUB CYCGLA MACTHU LITGLA CASFAR MELOLD MYRRUB

ADIMIL ALBKAL SORFOL CYCMYR TOXSUC CASTIB1 22 3 8 1 0 9 0 9 0 1 1 0 0 0 0 1 02 10 8 4 0 4 12 0 3 0 0 1 4 0 0 0 2 03 4 2 7 0 4 25 0 4 1 0 1 0 0 0 0 1 0

4 22 2 9 0 12 5 1 5 10 1 0 2 0 0 0 0 75 11 5 3 0 8 5 3 2 4 0 0 3 0 0 0 0 26 3 7 1 0 8 6 3 0 1 0 0 3 0 0 0 0 07 15 5 2 0 6 5 3 0 0 0 1 4 0 0 0 2 08 14 5 9 0 6 11 0 5 0 0 0 0 0 0 0 0 09 26 3 11 1 4 11 0 6 0 0 1 3 0 0 0 2 010 23 5 9 1 2 11 0 8 0 0 0 5 1 0 0 0 011 14 2 4 1 1 3 3 20 0 0 4 2 1 0 0 1 012 12 7 5 0 12 1 1 5 0 3 1 2 0 0 0 0 013 4 5 10 0 6 0 6 0 2 0 0 0 0 0 0 0 414 4 2 1 0 0 2 5 2 0 0 0 0 0 0 3 1 315 3 2 2 0 6 1 4 1 0 0 1 0 0 0 4 0 416 14 4 4 0 5 5 4 0 0 0 0 1 1 0 3 0 0

Page 4: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

环境数据>gtsenv=read.table(“gtsenv.txt”,header=T);

>gtsenv>dim(gtsenv)

elev convex slope aspect N P K pH1 54.89275 -1.7437500 46.78939 114.01775 3.334376 0.2147654 3.694624 4.7139932 57.99200 -2.2150000 45.69906 263.08339 4.202102 0.2451958 4.373228 4.7731203 54.50325 3.8407500 44.46079 256.71699 3.833674 0.2260520 4.289754 4.9354784 47.89600 4.3260000 39.24653 237.81106 3.079796 0.2017985 3.958930 5.0871595 46.18900 1.7790000 37.27584 110.11573 2.887753 0.1963663 3.644821 5.1675246 51.84300 4.2870000 35.67033 185.92226 3.678946 0.2422317 4.624101 4.8151547 60.73600 1.8480000 33.06503 201.07674 4.654444 0.2853413 5.090561 4.6786138 73.48775 -2.6817500 37.39011 184.01256 4.710466 0.2841518 5.814682 4.5715909 89.08200 -1.2530000 45.07064 150.55880 4.292108 0.2328600 5.726786 4.68215310 104.62625 -6.4292500 45.64218 131.79889 3.798971 0.2010399 5.481689 4.765959

Page 5: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

数据的标准化1. decostand(x, method, MARGIN, range.

global, na.rm = FALSE)total: 除以行和或列和 (default MARGIN = 1);max: 除以行或列的最大值 (default MARGIN = 2);freq: 除以行或列的最大值 , 并乘以非零值的个数 (default MA

RGIN=2);normalize: 使行或列的平方和等于 1 (default MARGIN = 1);range: 标准化使行或列的值在 0 ... 1 (default MARGIN = 2).standardize: 标准化使行或列的和为 1 且方差为 1(default MA

RGIN = 2) ;pa: 将数据转换为 0 、 1 数据; chi.square: 除以行和及列和的平方根;hellinger: 采用 total 标准化以后再取平方根;2. wisconsin(x) : 除以列最大值,再除以行和。

Page 6: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

一、什么是排序 (ordination)?排序的过程是将样方或植物种排列在一定的空间,使得排序轴能够反映一定的生态梯度,从而,能够解释植被或植物种的分布与环境因子间的关系,也就是说排序是为了揭示植被 - 环境间的生态关系。因此,排序也叫梯度分析( gradient analysis )。间接梯度分析 (Indirect gradient analysis)

直接梯度分析 (direct gradient analysis)

Page 7: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

一、什么是排序 (ordination)?排序的过程是将样方或植物种排列在一定的空间,使得排序轴能够反映一定的生态梯度,从而,能够解释植被或植物种的分布与环境因子间的关系,也就是说排序是为了揭示植被 - 环境间的生态关系。因此,排序也叫梯度分析( gradient analysis )。间接梯度分析 (Indirect gradient analysis)

直接梯度分析 (direct gradient analysis)

Page 8: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

2 个种的排序图 3 个种的排序图4 个种的排序图???

40 个种排序图???

Page 9: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

排序的内容:1. 降低维数,减少坐标轴的数目 ;2. 由降低维数引起的信息损失尽量少,即发生最

小的畸变,也就是说它的第 1-3 轴排序轴包含大量的生态信息 。

Page 10: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

排序的目标:表示植被与环境之间的关系:所有排序方法都反映植物种和环境之间的关系以及在某一环境梯度上的种间关系。1.线形模型( linear model ),短的梯度,主成分分析( Principle component analysis) ,需要对数据进行非线性转换,如取对数;2.非线性模型( non-linear model )如高斯模型,长的梯度,对应分析 ( Correspondence analysis)

Page 11: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

排序采用的距离方法:1.欧氏距离:

2. 卡方距离

Page 12: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences二、主成分分析 (Principle component analysis, PCA)主成分分析的主要原理是:

使坐标旋转一定的角度后,使第一轴表示数据最大的方差,使第二轴表示数据第二的方差。而且轴与轴之间是正交的( orthogonal) 。

Page 13: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

PCA 和 RDA 都采用函数 rda 实现:在 vegan 包中,rda(formula, data, scale=FALSE, ...) rda(X, Y, Z, scale=FALSE, ...) scores(x, display=c("sites", "species"), choices,

...) 在 stat 包中:princomp(x, ...) princomp(formula, data = NULL, subset,

na.action, ...)

Page 14: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

主成分分析表示信息的方法:1.特征值 (eigenvalue) 和 Inertia

每一个轴都有一个特征值表示其信息量也就是方差的大小。

Page 15: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>gts.rda=rda(gtsdata)>gts.rdaCall: rda(X = gtsdata) Inertia RankTotal 352.1 Unconstrained 352.1 22Inertia is variance Eigenvalues for unconstrained axes: PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 111.779 73.580 54.607 32.959 26.481 18.063 12.763 7.637 >sum(apply(gtsdata,2,var))>summary(gts.rda)!! 所以如果不对数据做标准化的话,丰富种的值就非常大,排序时就只能看清丰富种的位置,其它种就拥挤在一起。

Page 16: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

plot(rda(gtsdata,scale=T))plot(rda(gtsdata))

Page 17: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

2. 特征值向量 (eigenvector) 和负荷 (loading)

虽然所有的属性在排序中共同起作用,但各个属性的贡献是不等的,这可以用负荷量( Loading )表示。

为特征向量, 为特征根 , 为负荷 ;

jijij UL

jiU j ijL

Page 18: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>gts.pca=princomp(gtsdata);

>summary(gts.pca)Importance of components: Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9Standard deviation 10.4395571 8.4699817 7.2966750 5.6687688 5.0812197 4.19660429 3.52761081 2.72874248 1.97771180Proportion of Variance 0.3174708 0.2089799 0.1550921 0.0936089 0.0752100 0.05130216 0.03624941 0.02169026 0.01139372Cumulative Proportion 0.3174708 0.5264507 0.6815428 0.7751517 0.8503617 0.90166388 0.93791329 0.95960355 0.97099728 Comp.10 Comp.11 Comp.12 Comp.13 Comp.14 Comp.15 Comp.16 Comp.17Standard deviation 1.7323299 1.35729335 1.200607370 0.981219107 0.886018324 0.732918287 0.615547693 0.603479672Proportion of Variance 0.0087418 0.00536645 0.004198959 0.002804605 0.002286783 0.001564771 0.001103731 0.001060877Cumulative Proportion 0.9797391 0.98510553 0.989304485 0.992109090 0.994395873 0.995960644 0.997064374 0.998125251 Comp.18 Comp.19 Comp.20 Comp.21 Comp.22Standard deviation 0.5225505121 0.3955964131 0.3717554040 0.2314638405 1.491582e-01Proportion of Variance 0.0007954194 0.0004558735 0.0004025819 0.0001560652 6.480882e-05Cumulative Proportion 0.9989206707 0.9993765441 0.9997791260 0.9999351912 1.000000e+00

Page 19: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>gts.pca$loadingsLoadings: Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9 Comp.10 Comp.11 Comp.12 Comp.13 Comp.14 Comp.15Belper 0.128 -0.115 -0.190 0.248 -0.138 0.661 -0.214 0.287 -0.113 Empnig 0.153 0.156 0.137 -0.234 Junbuf -0.222 0.253 0.111 -0.706 0.113 0.162 0.119 0.161 -0.319 -0.220 -0.184 0.237 Junart -0.331 -0.169 -0.189 0.712 0.199 -0.110 0.369 0.216 Airpra 0.319 0.114 0.141 0.207 -0.186 0.169 0.220 Elepal -0.623 0.175 -0.226 0.240 0.121 0.175 0.437 0.146 -0.402 -0.179 Rumace 0.218 0.529 -0.318 0.225 0.222 -0.299 0.178 0.217 0.286 -0.219 Viclat -0.107 -0.136 0.179 -0.186 -0.119 -0.316 0.425 -0.242 -0.302 Brarut 0.557 -0.638 -0.108 -0.269 0.298 -0.168 0.107 0.113 Ranfla -0.282 -0.396 -0.445 -0.443 -0.323 -0.119 Cirarv 0.140 0.324 -0.265 -0.828 -0.204 Hyprad 0.489 -0.114 0.169 -0.355 0.266 0.111 -0.296 Leoaut 0.233 0.100 0.284 -0.365 -0.333 -0.158 0.231 -0.529 0.135 -0.320 -0.138 0.191 Potpal -0.124 0.107 0.309 -0.329 0.322 0.363 -0.284 0.552 Poapra 0.300 -0.310 -0.403 -0.283 0.362 0.328 -0.305 0.156 -0.102 0.138 -0.138 -0.107 -0.105 0.243 Calcus -0.247 -0.212 0.230 -0.169 -0.166 -0.131 -0.538 0.563 0.206 0.321 Tripra 0.139 0.371 -0.178 0.112 0.189 -0.325 -0.183 -0.114 -0.351 0.138 Trirep 0.242 0.107 -0.182 -0.737 0.320 -0.236 0.159 0.266 0.190 -0.114 -0.187 Antodo 0.240 0.307 0.368 0.127 0.282 0.306 0.293 0.340 0.328 -0.261 -0.134 -0.193 -0.182 0.191 Comp.16 Comp.17 Comp.18 Comp.19

Belper 0.210 -0.447 Empnig 0.528 0.372 0.564 -0.345 ……

Page 20: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>dune.pca$scores Comp.1 Comp.2 Comp.3 Comp.4 Comp.5 Comp.6 Comp.7 Comp.8 Comp.9 Comp.10

2 2.91150470 -2.9148367 -0.39183558 -3.26667206 0.35051735 0.28388605 0.52066037 0.73059997 -1.4793222 0.87321856513 0.06136859 -2.6231269 -0.42838176 1.30336777 1.66947506 -2.17899298 -0.36875549 -0.19309055 -0.7950698 -0.3970940404 1.02850538 -2.5050978 -0.67488903 0.85437428 -1.19090106 1.35200297 -1.38639373 0.33487590 -0.2026383 0.13842749016 -8.54104222 1.7027507 -0.14285826 0.31503377 0.03466446 1.36133046 -0.62042478 0.09876075 1.1388422 0.3921811216 4.16821528 6.8308661 -2.63927075 -0.34689727 0.46906091 0.99514014 -0.21265662 -1.24990383 0.1266251 -0.1271093601 0.15018963 -3.6074502 -0.74802148 2.81234916 0.67477409 1.51071796 -1.01725395 -1.24774013 0.4766938 -0.0077944828 -3.14967642 -0.9611984 -1.22643599 -0.63476176 -1.32815601 0.99274210 2.97567231 -0.45122396 -0.2354594 0.4652611015 3.21093219 3.0252592 -0.21089223 1.55168869 1.89306982 1.96234630 0.02060707 1.42609520 -1.2696912 0.31379745417 0.88446774 -1.0991631 4.11846904 2.95696513 1.82749949 1.03467888 0.19910009 0.21144777 0.4951844 -0.20873502615 -5.36951040 1.3256396 0.27524739 -0.08549455 -0.98964812 -0.03800091 0.01096899 0.59404602 0.2103164 1.57520902810 3.45432187 -0.5619981 0.22090135 -2.84516449 1.14051915 1.11003109 0.94915018 1.48318189 2.1446676 -1.05414067111 2.05213785 -0.4771088 0.78453920 -1.68401438 -3.04693268 -0.67046740 -0.20422357 -1.77321117 0.3264255 -0.2508240139 0.51663009 -0.7985760 -3.10680983 1.50246304 -0.17373810 -2.71788982 2.81684219 0.29094051 0.5294339 -0.12467418418 1.48341665 0.5202995 0.08634919 -1.41220478 -4.20399526 -0.27655732 -1.80257041 0.82080959 -0.2487870 -0.2761808133 1.55380353 -2.6194360 -1.23079594 0.02776684 -1.08296299 1.36424397 -0.72252666 -0.06854765 0.2756024 -0.02824622720 -6.47874619 1.3255668 0.32165172 0.42698365 -0.96651137 -0.03909689 0.25420231 0.40610164 -1.4497751 -2.08633302414 -3.32303762 -0.4813713 0.33609162 -4.32311947 4.58574613 -0.75540377 -1.05044347 -1.01983081 -0.2338041 -0.05547216319 2.12620726 1.7311377 7.11694599 0.02181364 -0.81591309 -1.23637774 1.06159360 -0.46978018 -0.1239673 0.33109708712 0.53622284 1.2960367 -1.00112155 1.17604614 0.43846541 -4.12336930 -1.88335169 0.88204619 0.6654894 0.3871344047 2.72408923 0.8918069 -1.45888311 1.64947664 0.71496681 0.06903620 0.45980325 -0.80557716 -0.3507664 0.140277752

Page 21: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>biplot(gts.pca)

箭头所指的方向就是旋转以前物种的轴,箭头的长短表示物种对排序轴的影响大小。

Page 22: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

我们常用的 PCA 是采用协方差矩阵进行计算的,但是也可以采用相关矩阵进行计算。>princomp(gtsdata,cor=T)>rda(gtsdata, scale=T)采用相关矩阵进行计算要使各个种之间变得差异小一些,两者结果是不同的。在实际应用中,两个都进行计算,选更易于解释和表现生态关系的。如果要在排序图上表现聚类,可能要采用协方差计算结果;如果不同的种有类似的贡献时,可能要采用相关矩阵计算结果。

Page 23: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

3. 每个轴包含的信息量如果前三轴包含的信息量非常少,表明种间的信息相关性非常少,信息冗余非常少,不能用 PCA 分析。 >summary(gts.rda)Eigenvalues, and their contribution to the variance

PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PC10 PC11 PC12 PC13 PC14 PC15lambda 111.7788 73.5801 54.6066 32.9589 26.4808 18.0631 12.763 7.6370 4.012 3.0779 1.8895 1.4784 0.9875 0.8052 0.5509accounted 0.3175 0.5265 0.6815 0.7752 0.8504 0.9017 0.938 0.9596 0.971 0.9797 0.9851 0.9893 0.9921 0.9944 0.9960 PC16 PC17 PC18 PC19 PC20 PC21 PC22lambda 0.3886 0.3735 0.2801 0.1605 0.1417 0.05495 0.02282accounted 0.9971 0.9981 0.9989 0.9994 0.9998 0.99994 1.00000

Page 24: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences二、对应分析 (Correspondence analysis, CA)

1. CA 采用单峰模型,因此结果一般优于 PCA ;2. CA 采用 距离,因此用于处理有很多 0 的数据,特别是处理“有”或“无”的数据;3. 矩阵中不允许有负数, PCA 分析矩阵可有负数。

Page 25: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

4. CA 除了采用卡方距离以外,其它计算步骤都与 PCA 一致(如旋转等 )

5. CA 在 vegan 中的实现:cca(formula, data, ...)

cca(X, Y, Z, ...)

Page 26: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

4. CA 除了采用卡方距离以外,其它计算步骤都与 PCA 一致(如旋转等)>gts.ca=cca(gtsdata)

>gts.caCall:cca(X = gtsdata) Inertia RankTotal 1.424 Unconstrained 1.424 21Inertia is mean squared contingency coefficient Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.50253 0.26564 0.14023 0.10502 0.09127 0.05540 0.05063 0.04204

Page 27: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

4. Inerta 在这里是矩阵标准化后的卡方统计>chisq.test(gtsdata/sum(gtsdata)) Pearson's Chi-squared testdata: gtsdata/sum(gtsdata) X-squared = 1.4243, df = 819, p-value = 1

>summary(gts.ca)

5. 对样方和物种的排序坐标进行加权平均。( 1 )用物种数据对样地坐标进行加权平均;( 2 )用样方数据对物种坐标进行加权平均;( 3 )对样方和物种坐标都进行加权平均;加权平均后的排序图会收缩,收缩的因子等于特征值。

Page 28: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

plot(gts.ca, scaling=1)用物种数据对样地坐标进行加权平均 , 使样方坐标在物种数据的中心,因此对样方感兴趣的话,采用这种做图方法。

plot(gts.ca)

Page 29: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

plot(gts.ca, scaling=2) plot(gts.ca, scaling=3)

用样地数据对物种坐标进行加权平均 , 使物种数据在样方数据的中心,因此对物种感兴趣的话,采用这种做图方法。

Page 30: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

6. 对 CA 结果的解释:( 1 )每个轴的特征值表示各轴样方坐标和物种坐标的相关性,如:例子中第一轴的特征值是: 0.

53601 。(2) 采用物种数据对样方坐标进行加权平均时,A. 样方之间的距离就是它们之间的卡方距离 ;

B. 由于加权平均时,采用样方内物种的相对多度进行加权,因此如果一个样方内没有某个物种,这个物种对样方的坐标没有贡献。

Page 31: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

C. 因此如果一个物种靠近某个样方,表明该物种可能对该样方的位置起很大的作用。特别是对于二元数据的排序,这个样方可能就代表该物种。如图中, 20号样方与短柄枹 (QUESER)靠得比较近,表明:短柄枹表征了20号样方的特征,19号样方与 20号样方距离近,生态关系也较近。

Page 32: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences( 3 )生态位的阐述:物种是按单峰曲线沿生境梯度分布的,A.物种在排序空间的分布表明物种和环境的关系,物种和样方的相对位置表明物种和样方的相对关系。

如图中, 22号样方和青冈 (CYCGLA)

Page 33: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

B. 只在少数样方出现的物种通常在排序空间的边缘,表明它们只偶然发生,或它们只在稀有生境(如米槠 CASCAR )。C. 在排序空间中心的物种,可能在取样区域是该物种最优分布区,如甜槠,或有两个或多个最优分布区,或与前两个轴不相关。

Page 34: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

除趋势对应分析 (Detrended correspondence analysis, DCA) :

CA 采用单峰曲线表示物种和环境关系

Page 35: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

CA产生的弓形效应

CA 的第二排序轴在许多情况下是第一轴的二次变形,即所谓的“弓形效应”( Arch effect )或者“马蹄形效应”( horse-shoe effect )。

Page 36: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

DCA 在 R 中的实现采用函数 decorana 。decorana(veg, iweigh=0, iresc=4, ira=0, mk=26, short=0, before=NULL, after=NULL)

veg: 群落数据 ;iweig:稀有物种的权重;iresc :纠正弓形效应的次数;ira: 分析的类型 (0: DCA, 1:CA);mk :校正弓形效应轴的分段数 ;short: 需要校正的最短梯度。

Page 37: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

plot(decorana(gtsdata))plot(cca(gtsdata))

Page 38: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

冗余分析 (redundancy analysis, RDA)及典范对应分析( Canonical correspondence analysis, CCA)

1.通常采用 PCA 处理环境数据,采用 CA 处理群落数据,但这些方法都只能处理一个数据表;2.RDA 和 CCA 是多元分析( PCA , CA )和线性回归的结合,研究植被和环境之间的关系。

Page 39: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

PCA 与环境因子结合是 RDA , CA 与环境因子结合是 CCA 。CCA 在 vegan 中的实现:cca(formula, data, ...) cca(X, Y, Z, ...)

RDA 在 vegan 中的实现:rda(formula, data, ...) rda(X, Y, Z, ...)

Page 40: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

> gts.rda=rda(gtsdata,gtsenv);

>gts.rda=rda(gtsdata~elev+convex+slope+aspect+N+K+P+pH,data=gtsenv);

scale=F scale=T

Page 41: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>gts.rdaCall:rda(X = gtsdata, Y = gtsenv)

Inertia RankTotal 352.1 Constrained 137.4 8Unconstrained 214.7 22Inertia is variance Eigenvalues for constrained axes: RDA1 RDA2 RDA3 RDA4 RDA5 RDA6 RDA7 RD

A8 56.3864 42.7769 17.8270 13.5066 2.5020 2.1217 1.6616 0.6203

Eigenvalues for unconstrained axes: PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 72.287 54.891 26.618 17.959 12.730 9.918 5.659 5.349

Page 42: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

plot(gts.rda)

环境因子一般用箭头表示,箭头所处的象限表示环境因子与排序轴间的正负相关性,箭头连线的长度代表着某个环境因子与群落分布和种类分布间相关程度的大小,连线越长,说有相关性越大。反之越小。箭头连线和排序轴的夹角代表着某个环境因子与排序轴的相关性大小,夹角越小,相关性越高;反之越低。

Page 43: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>summary(gts.rda)Call:rda(X = gtsdata, Y = gtsenv) Inertia RankTotal 352.1 Constrained 137.4 8Unconstrained 214.7 22Inertia is variance

Eigenvalues for constrained axes: RDA1 RDA2 RDA3 RDA4 RDA5 RDA6 RDA7 RD

A8 56.3864 42.7769 17.8270 13.5066 2.5020 2.1217 1.6616 0.6203 Eigenvalues for unconstrained axes: PC1 PC2 PC3 PC4 PC5 PC6 PC7 PC8 72.287 54.891 26.618 17.959 12.730 9.918 5.659 5.349

Page 44: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>gts.cca=cca(gtsdata,gtsenv);

>gts.cca=cca(gtsdata~elev+convex+slope+aspect+N+K+P+pH,data=gtsenv)

plot(gts.ccca)

Page 45: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>gts.ccaCall:cca(X = gtsdata, Y = gtsenv) Inertia RankTotal 1.4243 Constrained 0.6928 8Unconstrained 0.7315 21Inertia is mean squared contingency coefficient

Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 CCA5 CCA6 CCA7

CCA8 0.338081 0.209369 0.066810 0.036824 0.013992 0.011367 0.009057

0.007305 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.24676 0.11172 0.06530 0.05198 0.04321 0.03871 0.03436 0.02685

Page 46: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

plot(gts.cca)

Page 47: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of SciencesRDA和 CCA结果的检验:goodness(object, display = c(“species”, “sites”), ch

oices, model = c(“CCA”, “CA”), statistic = c(“explained”, “distance”), summarize = FALSE, ...) :检验物种或样方与环境因子的相关性;

inertcomp(object, display = c(“species”, “sites”), statistic = c(“explained”, “distance”), proportional = FALSE) :物种或样方的方差分解分析;

spenvcor(object) : 物种和环境的相关分析 ;intersetcor(object) : 物种和各轴的相关分析;最好使用: envfit;vif.cca(object) :方差膨胀因子分析;

Page 48: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

如:>goodness(gts.cca,display=“sp”)

>inertcomp(gts.cca, proportional = T)

>spenvcor(gts.cca)

>intersetcor(gts.cca)

>vif.cca(gts.cca)

Page 49: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

作图函数:plot(x, choices = c(1, 2), display = c("sp", "wa",

"cn"), scaling = 2, type, xlim, ylim, ...)

x: cca 或 rda 分析结果;choices: 选择的轴;display:显示的类型, sp, 物种, wa, 样方,

lc, 线性结合的样方坐标 ;

Page 50: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

作图函数:text(x, display = "sites", labels, choices = c(1, 2), s

caling = 2, arrow.mul, head.arrow = 0.05, select, ...)

x: cca 或 rda 分析结果;display:显示的类型, sp , wa, lc , bp, 环境因子 ;cn, 中心化后的环境因子;label: 用来替代箭头的字符;Arrow.mul: 环境因子放大倍数 ;

Page 51: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

作图函数 :points(x, display = "sites", choices = c(1, 2), scalin

g = 2, arrow.mul, head.arrow = 0.05, select, ...)>plot(gts.cca,type="n");>text(gts.cca,display=“cn”,arrow.mul=1.5,c

ol=4); >points(gts.cca,display="lc",pch=16,col=2,s

elect=1:20)>points(gts.cca,display=“lc”,pch=2,col=4,sel

ect=21:40)>text(gts.cca,display=“lc”,col=4”);

Page 52: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

RDA和 CCA结果的检验:envfit(X, P, permutations = 0, strata, choices

=c(1,2), ...) envfit(formula, data, ...) >gts.cca=cca(gtsdata,gtsenv)>ef=envfit(gts.cca,gtsenv,permu=1000)

CCA1 CCA2 r2 Pr(>r) elev -0.9999873 -0.0050479 0.5005 <0.001 ***convex -0.7746504 0.6323898 0.0844 0.28

slope 0.1526685 0.9882775 0.5296 <0.001 ***aspect -0.1364818 -0.9906426 0.0169 0.82 N 0.6878942 0.7258110 0.6342 <0.001 ***P 0.8101502 0.5862224 0.5856 <0.001 ***K 0.6004984 0.7996260 0.3364 <0.001 ***pH -0.1929061 -0.9812172 0.6313 <0.001 ***

Page 53: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

RDA和 CCA结果的检验:anova(object, alpha=0.05, beta=0.01, step=1

00, perm.max=10000, by = NULL, ...) permutest.cca(x, permutations=100, model=

c("direct", "reduced","full"), first = FALSE, strata, ...)

x, object:cca 或 rda 的分析结果;by: 为” axis”, 或” terms” ,分析各轴或因子的显著性;

Page 54: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

RDA和 CCA结果的检验: >gts.cca=cca(gtsdata~elev+convex+slope+as

pect+P+N+K+pH,data=gtsenv)>anova(gts.cca)>anova(gts.cca,by=“axis”)>anova(gts.cca,by=“terms”)

Model: cca(formula = gtsdata ~ elev + convex + slope + aspect + P + N + K + pH, data = gtsenv) Df Chisq F N.Perm Pr(>F)

elev 1 0.2446 7.0228 100 <0.01 ***convex 1 0.0624 1.7902 100 0.07 .

slope 1 0.1356 3.8928 100 <0.01 ***aspect 1 0.0208 0.5981 100 0.55 P 1 0.0911 2.6159 100 <0.01 ***N 1 0.0591 1.6966 100 0.04 * K 1 0.0484 1.3906 100 0.07 . pH 1 0.0307 0.8814 100 0.39

Page 55: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of SciencesRDA和 CCA模型的选择: step(mod1,scope)>mod1=cca(gtsdata~1,data=gtsenv);>mod2=cca(gtsdata~elev+convex+slope+asp

ect+P+N+K+pH,data=gtsenv);>mod=step(mod1,scope=(list(lower=formula

(mod1),upper=formula(mod2))));Start: AIC=180.2

gtsdata ~ 1 Df AIC

+ P 1 174.66+ elev 1 174.67+ N 1 174.89+ pH 1 176.95+ slope 1 177.82+ K 1 178.14

<none> 180.20+ convex 1 180.85+ aspect 1 181.53

Page 56: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of SciencesRDA和 CCA模型的选择:>modCall:cca(formula = gtsdata ~ P + pH + elev + convex, data = gtsenv) Inertia RankTotal 1.4243 Constrained 0.5640 4Unconstrained 0.8603 21Inertia is mean squared contingency coefficient

Eigenvalues for constrained axes: CCA1 CCA2 CCA3 CCA4 0.31595 0.18030 0.04863 0.01913 Eigenvalues for unconstrained axes: CA1 CA2 CA3 CA4 CA5 CA6 CA7 CA8 0.27067 0.13398 0.08373 0.06294 0.05026 0.04852 0.04199 0.02758

Page 57: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

绘制环境因子梯度图:ordisurf(x, y, choices=c(1, 2), knots=10, family

="gaussian", col="red", thinplate = TRUE, add = FALSE, display = "sites", w = weights(x), main, nlevels = 10, levels, labcex = 0.6, ...)

x:cca 或 rda 的结果,y: 需要绘图的环境因子或物种 ;

Page 58: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>ef=envfit(gts.cca,gtsenv,permutation=1000) >plot(gts.cca,display="sites")>plot(ef)>tmp=with(gtsenv,ordisurf(gts.cca,K,add=T))>with(gtsenv,ordisurf(gts.cca,pH,add=T,col=6))

Page 59: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

绘制物种因子梯度图:ordisurf(x, y, choices=c(1, 2), knots=10, family

="gaussian", col="red", thinplate = TRUE, add = FALSE, display = "sites", w = weights(x), main, nlevels = 10, levels, labcex = 0.6, ...)

ordihull(ord, groups, display = "sites", draw = c("lines","polygon"), show.groups, ...)

ordispider(ord, groups, display="sites", w = weights(ord, display), show.groups, ...)

x:cca 或 rda 的结果,y: 需要绘图的因子 ;add, 添加到别的图上 ;

Page 60: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>plot(gts.cca,type="p",display="sites")> with(gtsdata,points(gts.cca,dis="sites", cex=sqrt(QUE

SER),pch=16,col=4))> with(gtsdata,ordihull(gts.cca,dis="sites", QUESER>0,s

how=T))>with(gtsdata,ordispider(gts.cca,QUESER>0, show=T,w

=QUESER,col=4))>with(gtsdata,ordisurf(gts.cca,QUESER,add=T)

Page 61: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

绘制三维排序图:ordiplot3d(object, display = "sites", choices = 1:3,

ax.col = 2, arr.len = 0.1, arr.col = 4, envfit, xlab, ylab, zlab, ...)

ordirgl(object, display = "sites", choices = 1:3, type = "p", ax.col = "red", arr.col = "yellow", text, envfit, ...)

orglpoints(object, display = "sites", choices = 1:3, ...) orgltext(object, text, display = "sites", choices = 1:3, justify = "center", adj = 0.5, ...)

Page 62: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

>ordiplot3d(gts.cca,type=“h”) > ordirgl(gts.cca,type="p")

Page 63: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

排序结果的比较:procrustes(X, Y, scale = TRUE, symmetric = FAL

SE, scores = "sites", ...) protest(X, Y, scores = "sites", permutations = 100

0, strata, ...) x,y: 两个排序结果;

Page 64: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

排序结果的比较:>gts.cca=cca(gtsdata,gtsenv);>gts.rda=rda(gtsdata,gtsenv);>procrustes(gts.cca,gts.rda,scores=“sp”);>protest(gts.cca,gts.rda,scores=“sp”);

Page 65: 用 vegan 进行排序分析 米湘成

Institute of Botany, the Chinese Academy of Sciences

THANK YOU !谢谢!