VisualizationBuilder#
- class panorama.systems.utils.VisualizationBuilder(name, output_dir, formats=None)#
Bases:
ABCAbstract base class for building correlation matrix and partition visualizations.
This class maintains a common configuration and provides a cohesive interface for creating all components of pangenome visualizations. It handles shared functionality like plot dimensions, styling, and file saving.
- BELOW_HEIGHT = 138#
Space for bottom plots
- Type:
int
- CENTER_WIDTH = 1335#
Space for main heatmap
- Type:
int
- DEFAULT_FORMAT = 'html'#
Default output format when none specified
- Type:
str
- LEFT_WIDTH = 267#
Space for left bar plots
- Type:
int
- MIDDLE_HEIGHT = 644#
Space for main heatmap
- Type:
int
- OUTPUT_FORMATS = ['html', 'png']#
Supported output formats for saving figures
- Type:
list
- PNG_EXPORT_HEIGHT = 1080#
Height of PNG exports
- Type:
int
- PNG_EXPORT_WIDTH = 1920#
Width of PNG exports
- Type:
int
- RIGHT_WIDTH = 178#
Space for color bars
- Type:
int
- TOP_HEIGHT = 138#
int Space for top bar plots
- TOTAL_HEIGHT = 920#
Total height of the complete visualization layout.
- Type:
int
- TOTAL_WIDTH = 1780#
Total width of the complete visualization layout.
- Type:
int
- __init__(name, output_dir, formats=None)#
Initialize the visualization builder.
- Parameters:
name (
str) – Name of the pangenome for visualization titles and filenamesoutput_dir (
Path) – Directory path where output files will be savedformats (
Optional[List[str]]) – List of output formats to generate. Defaults to [“html”]
- static _configure_bar_plot_style(plot, x_label=None, y_label=None, flip_x=False, hide_x_axis=False, hide_y_axis=False)#
Configure styling for bar plots.
- Parameters:
plot (
figure) – The figure to configurex_label (
Optional[str]) – Label for x-axisy_label (
Optional[str]) – Label for y-axisflip_x (
bool) – Whether to flip the x-axishide_x_axis (
bool) – Whether to hide the x-axishide_y_axis (
bool) – Whether to hide the y-axis
- Return type:
None
- static _configure_minimal_plot(plot)#
Configure a minimal plot style (no axes, grid, etc.).
- Parameters:
plot (
figure) – The figure to configure with minimal styling- Return type:
None
- _configure_plot_style()#
Configure common plot styling for the main figure.
This method sets up consistent appearance across all visualization types, including fonts, colors, and axis properties.
- Return type:
None
- _create_main_figure(matrix, x_range=None, y_range=None, tooltips=None)#
Create the main heatmap figure with common configuration.
- Parameters:
matrix (
DataFrame) – Data matrix for determining ranges if not providedx_range (
Optional[FactorRange]) – X-axis range for the plot. If None, derived from matrix columnsy_range (
Optional[FactorRange]) – Y-axis range for the plot. If None, derived from matrix indextooltips (
Optional[List[Tuple[str,str]]]) – List of tooltip specifications as (label, field) tuples
- Return type:
None
- _save_figure(fig, filename_base)#
Save a Bokeh figure in the specified formats.
- Parameters:
fig (
figure) – The Bokeh figure object to savefilename_base (
str) – Base filename without extension
- Raises:
Exception – If an unsupported output format is specified
- Return type:
None
- property color_bar: figure#
Get the color bar figure.
- create_left_bar_plot(source, matrix, y_field='system_name', value_field='count', color='navy')#
Create a horizontal bar plot on the left side of the visualization.
- Parameters:
source (
ColumnDataSource) – ColumnDataSource containing the data for the barsmatrix (
DataFrame) – Data matrix for determining the y-rangey_field (
str) – Field name for the y-axis valuesvalue_field (
str) – Field name for the bar valuescolor (
str) – Color for the bars
- Return type:
None
- abstractmethod create_main_figure(*args, **kwargs)#
Create the main visualization figure.
This method must be implemented by subclasses to create their specific type of main visualization (correlation matrix, partition matrix, etc.).
- Return type:
None
- create_top_bar_plot(source, x_field, value_field='count', color='green', x_order=None)#
Create a vertical bar plot on the top of the visualization.
- Parameters:
source (
ColumnDataSource) – ColumnDataSource containing the data for the barsx_field (
str) – Field name for the x-axis valuesvalue_field (
str) – Field name for the bar valuescolor (
str) – Color for the barsx_order (
Optional[List[str]]) – Custom ordering for x-axis. If None, uses source data order
- Return type:
None
- property glyph: Glyph#
Get the glyph from the renderer.
- property glyph_renderer: GlyphRenderer#
Get the glyph renderer for the main plot.
- property left_bar: figure#
Get the left bar plot figure.
- property main_plot: figure#
Get the main heatmap plot figure.
- abstractmethod plot()#
Create and save the complete visualization layout.
This method must be implemented by subclasses to define their specific layout arrangement and save the final visualization.
- Return type:
None
- property top_bar: figure#
Get the top bar plot figure.