SystemsPartitionVisualizer#
- class panorama.systems.systems_partitions.SystemsPartitionVisualizer(name, output_dir, formats=None)#
Bases:
VisualizationBuilderVisualizer for pangenome systems partition distributions.
This class creates heatmap visualizations showing how pangenome systems are partitioned (persistent, shell, cloud, etc.) across different organisms. The visualization helps understand the conservation patterns of genetic systems.
- partitions#
List of partition categories
- partition2color#
Mapping from partitions to colors
- mapper#
Categorical color mapper for partitions
- 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 SystemsPartitionVisualizer.
- Parameters:
name (
str) – Name of the pangenome for visualization titlesoutput_dir (
Path) – Directory path where output files will be savedformats (
Optional[List[str]]) – List of output formats to generate
- 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_bar_plots(partition_matrix)#
Create bar plots showing system and organism statistics.
Creates stacked bars for partition distributions (left) and organism counts (top) to provide marginal summaries of the partition matrix.
- Parameters:
partition_matrix (
DataFrame) – DataFrame with partition information- Return type:
None
- create_color_bar(title)#
Create a color bar for the partition matrix.
- Parameters:
title (
str) – Title to display on the color bar- Return type:
None
- create_left_bar(source)#
Create a stacked horizontal bar plot showing partition distributions by system.
- Parameters:
source (
ColumnDataSource) – ColumnDataSource containing stacked partition data- Return type:
None
- 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
- create_main_figure(partition_matrix, x_range, y_range)#
Create the main partition matrix heatmap figure.
- Parameters:
partition_matrix (
DataFrame) – DataFrame with systems, organisms, and partition informationx_range (
FactorRange) – X-axis range for the plot (organisms)y_range (
FactorRange) – Y-axis range for the plot (systems)
- 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.
- plot()#
Create and save the complete partition visualization layout.
Arranges the main partition heatmap with supporting bar plots and color bar in a clean grid layout, then saves the result in specified formats.
- Return type:
None
- property top_bar: figure#
Get the top bar plot figure.