DingWB / PyComplexHeatmap

PyComplexHeatmap: A Python package to plot complex heatmap (clustermap)
https://dingwb.github.io/PyComplexHeatmap/
MIT License
297 stars 32 forks source link

Order messed after split rows #80

Closed Bo-UT closed 2 months ago

Bo-UT commented 4 months ago

hi,

I split the rows whiling clustering, but it seems the order is completed messed up. Is there any setting to fix the split order? Thank you!

cm = pch.ClusterMapPlotter(pd.DataFrame(res_dict),
                      row_cluster=True,
                      col_cluster=True,
                      row_dendrogram=True,
                      row_split=28,
                    #   show_rownames=True,
                    #   show_colnames=True,
                      cmap="YlOrRd", vmin=0, vmax=0.5)

image

image

DingWB commented 4 months ago

Hi @Bo-UT ,

For row_split=int, rows would be clustered according to the row dendrogram structure, you can not change the order as you want (otherwise, the row dendrogram tree could not be plotted). To give a custom row_split_order, please use row_split=pd.Series or row_split=pd.DataFrame and give row_split_order=list to specify the order you want. Another method is to sort the rows and columns before plotting and run ClusterMapPlotter with row_cluster=False, col_cluster=False. Here are some relevant documentation: https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/cpg_modules.html#Plotting-the-Dot-clustermap https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/single_cell_methylation.html#Visualizing-Single-Cell-DNA-Methylation-Data-(Loyfer2023)

Bo-UT commented 4 months ago

Hi @DingWB,

Great. Thank you a lot!!