superheat
superheat copied to clipboard
Allow distance matrix input
Hi Rebecca,
Thanks for the handy package!
Would it be a good idea to allow a distance matrix input?
Can you elaborate a little more on what you mean?
In some situations, we might have just distance matrices and not original data matrix. Visualizing heatmap of distance matrices and dendograms might be a good idea. Here is one illustration:
library("magrittr")
iris[,1:4] %>%
dist() %>% # assume we only have dist, but not the original data matrix
GMD::heatmap.3()
produces:
I find superheat
's interface and plot(based on ggplot2) better. It might be handy to have an option to input a dist object.
I see what you're suggesting. At some point I might add this functionality, but at the moment doing this would only require one extra line converting the distance matrix to an actual matrix:
iris[,1:4] %>%
dist() %>%
as.matrix %>%
superheat
You are missing the point: Hierarchical clustering of the data
and data %>% dist() %>% as.matrix()
yield two different dendograms. In the latter case, we are clustering based on distances of distances.
library("superheat")
library("magrittr")
library("cowplot")
with_dist <- iris[,1:4] %>%
dist() %>%
as.matrix() %>%
superheat(row.dendrogram = TRUE, print.plot = FALSE) %>%
extract2("plot")
plain <- iris[,1:4] %>%
superheat(row.dendrogram = TRUE, print.plot = FALSE) %>%
extract2("plot")
cowplot::plot_grid(with_dist, plain)
produces:
Ah I see - so you want to provide the original dendrogram but plot the distance matrix.
I'll add this to my list of features to add... it might be a while before I get to it though. I have other priorities at the moment unfortunately.