4

我需要使用函数“pheatmap”制作热图,使用 UPGMA 和 1-pearson 相关性作为距离度量。我的教授声称这是默认的距离度量,尽管在我的例子中它使用“欧几里得”作为距离度量。欧几里得和 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 
4

1 回答 1

5

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

>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)))
    }
...

更多信息在官方文档中。周围有这么多的包,把东西混在一起的情况并不少见:)

于 2017-12-23T11:09:40.470 回答