R语言怎么做相关性分析( 二 )


kl散度
(2)dist用法
This function computes and returns the distance matrix computed by using the specified distance measure to compute the distances between the rows of a data matrix.
这个函数用特定的方法计算矩阵的行之间的距离,并返回距离矩阵 。
dist(x, method = "euclidean", diag = FALSE, upper = FALSE, p = 2)
method:可以是"euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski"
diag:是否显示对角线的值
upper:是否显示上三角的值
p:The power of the Minkowski distance
(3)scale用法
scale(x, center = TRUE, scale = TRUE)

step7: scale是对矩阵的每一列进行标准化,如果要对行标准化需要先转置 。如heatmapdata <- t(scale(t(heatmapdata)))
(4)R Script
sampleDist <- dist(t(testdata1))
sampleDistMatrix <- as.matrix(sampleDist)
colnames(sampleDistMatrix) <- NULL
colors <- colorRampPalette(rev(brewer.pal(9,"Blues")))(255)
pheatmap(sampleDistMatrix,
clustering_distance_rows=sampleDist,
clustering_distance_cols=sampleDist,
color = colors)

R语言怎么做相关性分析



【R语言怎么做相关性分析】

猜你喜欢