pheatmap默认距离度量R

问题描述 投票:2回答:1

我需要使用函数'pheatmap'制作热图,使用UPGMA和1-pearson相关作为距离度量。我的教授声称这是默认距离度量,虽然在我的情况下它使用'欧几里德'作为距离度量。欧几里得和1 - 皮尔森的相关性是相同还是错了?如果他错了,我怎样才能为热图使用正确的距离指标?

我的意见

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 
r distance metric pheatmap
1个回答
3
投票

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

>pheatmap

如果你这样做,你可以看到euclidean被用作默认值:

... 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。周围有很多套餐,混合起来并不少见:)

© www.soinside.com 2019 - 2024. All rights reserved.