pheatmap默认距离度量R

pheatmap默认距离度量R,r,distance,metric,pheatmap,R,Distance,Metric,Pheatmap,我需要用函数“pheatmap”制作一个热图,使用UPGMA和1-pearson相关性作为距离度量。我的教授声称这是默认的距离度量,尽管在我的例子中它使用“欧几里得”作为距离度量。欧几里得和1-pearson相关性相同还是他错了?如果他错了,我该如何为我的热图使用正确的距离度量 我的意见 ph=pheatmap(avgreltlog10, color = colorRampPalette(rev(brewer.pal(n = 7, name = "RdYlBu")))(100), kmean

我需要用函数“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 

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

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

更多信息请访问。有太多的包,所以混淆起来并不少见:)

方法被传递到函数
pheatmap:::cluster_mat
,检查源代码,如果指定“correlation”,那么
d=as.dist(1-cor(t(mat)))
可以更详细一些吗?现在我将
clustering\u distance\u rows=“correlation”、clustering\u distance\u cols=“correlation”
作为参数包含在ph()函数中。但是我不确定在哪里放置
d=as.dist(1-cor(t(mat))
。如何处理
pheatmap:::cluster\u mat
pheatmap:::cluster\u mat
只是一个内部函数。把它输入你的控制台。您不必对
d=…
执行任何操作,函数
pheatmap:::cluster\u mat
会为您执行此操作