关联测度(association measures),生成n*n的对称方阵。此为后续章节的基础。
测度(measure)、指数(index)和系数(coefficient)表达着相同的意思,目的都是量化对象对(Q模式,Q mode)或变量对(R模式,R mode)之间的关系。
在Q模式中。关联测度是对象之间的距离(distance)(相异性)或相似性(similarity),例如欧氏距离、Jaccard相似系数。在R模式下,关联测度是变量之间的依赖性(dependence)测度,例如协方差或相关系数。
微生物数据由于存在双零问题,会使得相关性偏高。
一个物种在一个样方或地点不存在,可能由很多原因引起:可能该地不适合该物种生存;可能适合该物种生存但还没有扩散到;可能某地不是该物种某些重要生态位维度的最优条件,因此分布受抑制;亦可能该物种是存在的,只是未观测或采集到该物种;以及由于数据处理的问题,相关数据被认定为噪音值并屏蔽。
今日在学习后,重绘书中的相异矩阵热图,关键函数如下:
coldiss(spe.db,byrank=FALSE,diag=TRUE)
coldiss(spe.dbln,byrank = FALSE,diag = TRUE)
除去代码靠前部分的数据清洗,本文提供coldiss的函数代码,转载自Github
"coldiss" <- function(D, nc = 4, byrank = TRUE, diag = FALSE)
{
require(gclus)
if (max(D)>1) D <- D/max(D)
if (byrank) {
spe.color <- dmat.color(1-D, cm.colors(nc))
}
else {
spe.color <- dmat.color(1-D, byrank=FALSE, cm.colors(nc))
}
spe.o <- order.single(1-D)
speo.color <- spe.color[spe.o, spe.o]
op <- par(mfrow=c(1,2), pty="s")
if (diag) {
plotcolors(spe.color, rlabels=attributes(D)$Labels,
main="Dissimilarity Matrix",
dlabels=attributes(D)$Labels)
plotcolors(speo.color, rlabels=attributes(D)$Labels[spe.o],
main="Ordered Dissimilarity Matrix",
dlabels=attributes(D)$Labels[spe.o])
}
else {
plotcolors(spe.color, rlabels=attributes(D)$Labels,
main="Dissimilarity Matrix")
plotcolors(speo.color, rlabels=attributes(D)$Labels[spe.o],
main="Ordered Dissimilarity Matrix")
}
par(op)
}
依据今天的尝试,未来可再次尝试第二章中的复杂图重绘,晚安。
发表回复