plotly / dash-bio

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

Clustergram has too much whitespace when "cluster" option is None #644

Closed adkinsrs closed 2 years ago

adkinsrs commented 2 years ago

Describe the bug When the "cluster" option for dashbio.Clustergram() is "all", "row", or "col" the dendrograms show correctly and the subplot for the missing dendrogram is properly constrained. However if one wishes to not do clustering (such as passing None to that option), there is whitespace where the row and column dendrograms should be.

To Reproduce Steps to reproduce the behavior:

Expected behavior In my opinion, if a dendrogram is not to be computed on both rows and columns, then the domains for those subplot axes should be constrained to [0,0] or [1,1]. It seems that if either row dendros or column dendros are missing, then that particular axis's domain is constrained correctly.

Screenshots If applicable, add screenshots to help explain the issue.

Correct dendrogram axes domains

Screen Shot 2021-12-08 at 10 47 02 AM Screen Shot 2021-12-08 at 10 46 48 AM Screen Shot 2021-12-08 at 10 46 36 AM

Incorrect dendrogram axis domains

Screen Shot 2021-12-08 at 10 46 20 AM

Python version: 3.9.9 Python environment (via Docker) - am happy to provide a pip freeze if necessary scanpy==1.8.2

pandas==1.0.4

pandas==1.3.4 numba==0.50.1 llvmlite==0.33.0rc1 # For numba

numpy==1.18.5

numpy==1.19.3 jupyter==1.0.0 xlrd==1.2.0 requests==2.23.0 plotly==4.14.3 kaleido==0.2.1 dash-bio==0.6.1 MulticoreTSNE==0.1 Pillow==7.1.1 biopython==1.76 biocode==0.9.0 python-dotenv==0.14.0 Flask==1.1.2 mysql-connector-python==8.0.12 SQLAlchemy==1.2.12 Flask-RESTful==0.3.8 mod-wsgi==4.9.0

opencv-python==4.1.1.26

opencv-python==4.5.4.60 anndata==0.7.8 h5py==2.10.0

Additional context I coded a fix for my immediate need as follows:

# For reference, I have checkbox for the user to cluster columns or rows (cluster_genes, cluster_obs)
# This is a situation where the user did not check either box
            if not (cluster_genes or cluster_obs):
                fig.layout["xaxis4"]["domain"] = [0,0]
                fig.layout["xaxis5"]["domain"] = [0,0.95]
                fig.layout["yaxis2"]["domain"] = [1,1]
                fig.layout["yaxis5"]["domain"] = [0,1]