Skip to content

Conversation

@georgezakinih
Copy link
Contributor

Summary

This PR refactors the relational heatmap template to use Plotly's native image export instead of the matplotlib workaround.

Changes

  • Remove matplotlib workaround functions (get_plotly_colorscale_as_matplotlib, create_matplotlib_heatmap_matching_plotly)
  • Use pio.to_image() for direct PNG export with proper scale factor calculation
  • Update template_utils._save_single_object() to handle raw image bytes
  • Replace test suite with comprehensive integration tests
  • Fix font size inconsistency between PNG and HTML outputs

Benefits

  • Reduces code complexity by ~30% (200 lines → 140 lines)
  • Better performance (single plot generation instead of two)
  • True color fidelity (no Plotly → matplotlib conversion)
  • Fixes font size scaling issues in PNG exports
  • Works correctly in Galaxy's headless environment using kaleido

Testing

All 5 unit tests pass successfully, including:

  • Complete workflow with file outputs
  • PNG image quality validation
  • Different colormap options
  • JSON file input
  • No-save mode

Verified PNG outputs have correct dimensions and valid file format."

…port

Remove matplotlib workaround that recreated plots and use Plotly's
native image export instead. This simplifies the code while maintaining
output quality and fixing font size consistency between PNG and HTML.

- Remove get_plotly_colorscale_as_matplotlib() and
  create_matplotlib_heatmap_matching_plotly() functions
- Add direct PNG export using pio.to_image() with proper scale factor
- Update template_utils._save_single_object() to handle raw image bytes
- Replace test suite with comprehensive integration tests
- Fix font size inconsistency between PNG and HTML outputs
- Reduce code complexity by ~30% (200 lines → 140 lines)

The refactored implementation uses kaleido for headless PNG generation,
which works correctly in Galaxy's headless environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants