hrchy_cytocommunity.visualization.visualization.vis_heatmap

hrchy_cytocommunity.visualization.visualization.vis_heatmap(mat: DataFrame, output=True, save_path=None)

Visualize a heatmap for a given matrix or DataFrame.

This function creates a heatmap visualization using Seaborn, displaying matrix values with optional annotations and saving the figure to disk if a path is provided.

Parameters:
  • mat (pandas.DataFrame) – Input data matrix to visualize. Each element will be represented as a colored cell in the heatmap. The index and column names (if any) will be used as axis labels.

  • output (bool, default=True) – Whether to display the generated heatmap using plt.show(). Set to False when generating figures in non-interactive environments.

  • save_path (str or Path, optional) – File path to save the generated heatmap as a PNG image. If None, the figure will not be saved.

Returns:

The function produces a visual output (heatmap) but does not return any data.

Return type:

None

Notes

  • The heatmap uses the Reds color map by default.

  • Each cell value in the input matrix is displayed directly (annot=True).

  • When both output=False and save_path=None, the plot will be generated but not displayed or saved.

Examples

>>> import pandas as pd
>>> import numpy as np
>>> data = pd.DataFrame(np.random.rand(4, 4),
...                     index=['A', 'B', 'C', 'D'],
...                     columns=['X1', 'X2', 'X3', 'X4'])
>>> vis_heatmap(data, output=True, save_path="results/heatmap_example.png")