mwaskom / seaborn

Statistical data visualization in Python
https://seaborn.pydata.org
BSD 3-Clause "New" or "Revised" License
12.58k stars 1.93k forks source link

Custom reorder of rows/cols in clustermap #646

Closed michael-imbeault closed 9 years ago

michael-imbeault commented 9 years ago

I'm using clustermap and would like to reorder the clusters generated with MOLO (see http://cran.r-project.org/web/packages/dendsort/vignettes/example_figures.html).

I have two 1D arrays of the new orders for columns and rows, but can't change ClusterGrid.dendrogram_row.reordered_ind. Is there a way to reorder the rows/cols and the corresponding dendrograms?

Thanks, Michael

mwaskom commented 9 years ago

I believe the dendrogram itself is drawn by code that lives in scipy and thus isn't something we are able to manipulate, but you could at least reorder your matrix and plot the heatmap.

michael-imbeault commented 9 years ago

Yeah that is what I'm doing right now - I guess the other options is to modify the linkage matrix itself, I'll try that. Thanks!

markak commented 9 years ago

I'd be interested in helping to implement something like this - have hacked together a notebook showing the difference optimal leaf ordering makes to clustermap (dendrogram reordering not present yet) - http://nbviewer.ipython.org/url/stanford.edu/~markak/2015-09-02%20-%20Optimal%20leaf%20ordering%20for%20hierarchical%20clustering.ipynb#

mwaskom commented 9 years ago

If there are improvements that can be made to the clustering algorithms, they should be committed upstream to scipy and/or fastcluster.