raivokolde / pheatmap

Pretty heatmaps
227 stars 83 forks source link

Support 1-Spearman rank or 1-Kendall tau correlation coefficient as distance metric #28

Closed tomwenseleers closed 7 years ago

tomwenseleers commented 7 years ago

Currently, I noticed that if one chooses 1-correlation as the distance metric for clustering that only a Pearson correlation can be used, and not kendall tau or spearman rank.

I was wondering if you would mind supporting those too by any chance? (Allowing argument method to be passed to cor() would be a simple fix, but more elegant would probably be to allow "kendall" or "spearman" in addition to "correlation" or "pearson" for a standard Pearson correlation.)

raivokolde commented 7 years ago

You can enter distance matrix if you want to use more exotic distances. For example, use clustering_distance_cols = dist((1-cor(mat, method = "kendall")))

mebbert commented 6 years ago

Per issue #41, we should actually use as.dist rather than dist. My understanding is that dist will recalculate distances of the 1-cor(mat, method = "kendall") distances (distance of distances), rather than convert the calculated distances to a dist object.