plotly / dash-bio

Open-source bioinformatics components for Dash
https://dash-gallery.plotly.host/Portal/?search=Bioinformatics
MIT License
531 stars 192 forks source link

`Clustergram` obscures lengthy row labels with colour scale bar #771

Open kamurani opened 4 months ago

kamurani commented 4 months ago

I am using Clustergram figures in a Jupyter notebook. When plotting the clusters calculated from a dataframe, I have some long column / row names that I need to show in the figure as labels.

However, the colour scale bar is not automatically adjusted to move to the right to accommodate the extra space taken up by longer text in the row labels.

To Reproduce

import pandas as pd
import dash_bio
example_df = pd.read_csv('https://git.io/clustergram_brain_cancer.csv').set_index('ID_REF')

# add row names 
row_prefix = "A really long name for a row / column"
example_df.index = [f"{row_prefix} {i}" for i in example_df.index]

fig = dash_bio.Clustergram(
    data=example_df,
    row_labels=list(example_df.index),
)
fig.show()

This gives me: image

Expected behavior The plot should detect the sizing of row / column labels, and if there is enough room (which there is in this case), the colour scale bar should position itself outside the range of this text.

Alternatively, there should be a way to disable the colour bar to prevent obscuring the labels (I have been unable to get this working either with Clustergram)

E.g.

fig.update_coloraxes(showscale=False) # this does not remove anything from the `Clustergram` figure. 

Versions

Python 3.12.2

>>>print(dash_bio.__version__)
1.0.2