gpt4 book ai didi

r - pheatmap 默认距离度量 R

转载 作者:行者123 更新时间:2023-12-04 02:00:08 24 4
gpt4 key购买 nike

我需要使用函数 'pheatmap' 制作一个热图,使用 UPGMA 和 1-pearson 相关作为距离度量。我的教授声称这是默认的距离度量,尽管在我的情况下它使用“欧几里得”作为距离度量。 euclidian 和 1 - pearson 相关性相同还是他错了?如果他错了,我如何为我的热图使用正确的距离度量?

我的输入

ph=pheatmap(avgreltlog10, color = colorRampPalette(rev(brewer.pal(n = 7, 
name = "RdYlBu")))(100),
kmeans_k = NA, breaks = NA, border_color = "grey60",
cellwidth = 10, cellheight=10, scale = "none", cluster_rows=TRUE,
clustering_method = "average", cutree_rows = 4, cutree_cols= 2,)

R输出
$tree_row

Call:
hclust(d = d, method = method)

Cluster method : average
Distance : euclidean
Number of objects: 65


$tree_col

Call:
hclust(d = d, method = method)

Cluster method : average
Distance : euclidean
Number of objects: 10

最佳答案

您可以通过在终端中键入不带 () 的函数名称轻松检查默认设置

>pheatmap

如果你这样做,你可以看到欧几里得被用作默认值:
... clustering_distance_rows = "euclidean", clustering_distance_cols = "euclidean", clustering_method = "complete", ...

要使用 1-pearson 相关,只需将其指定为:
cluster_rows = TRUE,
clustering_distance_rows = "correlation"

它之所以有效是因为,再一次,如果您深入研究代码,您会看到它调用了 cluster_mat,它执行以下操作:
cluster_mat = function(mat, distance, method){
...
if(distance[1] == "correlation"){
d = as.dist(1 - cor(t(mat)))
}
...

更多信息在 official document .周围有很多包,混在一起的情况并不少见:)

关于r - pheatmap 默认距离度量 R,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47874486/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com