Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow distance matrix input #30

Open
talegari opened this issue Oct 25, 2017 · 5 comments
Open

Allow distance matrix input #30

talegari opened this issue Oct 25, 2017 · 5 comments

Comments

@talegari
Copy link

Hi Rebecca,

Thanks for the handy package!

Would it be a good idea to allow a distance matrix input?

@rlbarter
Copy link
Owner

Can you elaborate a little more on what you mean?

@talegari
Copy link
Author

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:

image

I find superheat's interface and plot(based on ggplot2) better. It might be handy to have an option to input a dist object.

@rlbarter
Copy link
Owner

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

@talegari
Copy link
Author

talegari commented Nov 1, 2017

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:

image

@rlbarter
Copy link
Owner

rlbarter commented Nov 2, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants