可以选择提供距离矩阵(请参阅?pheatmap
):
clustering_distance_rows: distance measure used in clustering rows.
Possible values are ‘"correlation"’ for Pearson correlation
and all the distances supported by ‘dist’, such as
‘"euclidean"’, etc. If the value is none of the above it is
assumed that a distance matrix is provided.
您可以尝试以下方法:
library(cluster)
data(agriculture)
gower_samples <- as.dist(as.matrix(daisy(agriculture, metric = "gower")))
gower_features <- as.dist(as.matrix(daisy(t(agriculture), metric = "gower")))
pheatmap(agriculture,
clustering_distance_rows=gower_samples,
clustering_distance_cols=gower_features)