DingWB / PyComplexHeatmap

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

How to sort columns after col_split #81

Open stephanmg opened 1 month ago

stephanmg commented 1 month ago

Hi,

I have a col_split by a pd.Series to group into 3 different groups A, B, and C.

The groups A, B, C seem to be automatically sorted ascending.

However I need to sort with a custom order within the groups A, B, C. How is this possible?

DingWB commented 1 month ago

Hi @stephanmg ,

Take a look at: https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/advanced_usage.html#Cluster-between-groups-and-cluster-within-groups

I guess col_split_order is what you are looking for.

stephanmg commented 1 month ago

Yes, I forgot that I need to also specify col_cluster=False, col_dendrogram=False is not enough.

stephanmg commented 1 month ago

@DingWB thank you! Is it also possible to remove or reposition the label of a anno_barplot(...)?

Code: AB=anno_barplot(....

I need to move the label AB or remove it in the plot.

Remove label with label_kws: 'visible': False. Can I also move the label more away from the plot?

Also, how can i provide a label to anno_barplot which contains spaces, in the examples in the docs there are never spaces I think, is this perhaps not supported? I need to write AB variant=anno_barplot(...) in essence.

DingWB commented 1 month ago

How did you control the pad in a normal barplot? You can control the pad similarly by taking the ax of the anno_barplot and doing whatever you want.

stephanmg commented 1 month ago

Thanks, what about the label name? Can I somehow include spaces?

DingWB commented 1 month ago

Please try.

stephanmg commented 1 month ago

No, sorry, I mean in the labels name. This is a second question, on how to rename the label, e.g. AB for the annotation toAB variant`

DingWB commented 1 month ago

See this docu: https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/advanced_usage.html#Add-multiple-heatmap-annotations-using-for-loop

You could prepare a dict and pass it to HeatmapAnnotation. You can give whatever key to the dict (including space).

stephanmg commented 1 month ago

legend_kws with label I assume? doesn't work somehow for my anno_barplot. :/

stephanmg commented 1 month ago

row_ha = HeatmapAnnotation(ABadvanced=anno_barplot(histo_data_for_row_ha, colors=bar_color, height=15), verbose=0, label_kws={'label': "# problems solved", 'rotation':0, 'fontsize': 8, 'horizontalignment':'left','verticalalignment':'bottom', 'visible':False}, axis=1)

stephanmg commented 1 month ago

But this will not rename Abadvanced to "# problems solved"... don't know why. Could you help out again? Thanks!