troutpy.pl.heatmap#
- troutpy.pl.heatmap(data, output_path='', save=False, figsize=None, tag='', title=None, cmap='RdBu_r', annot=False, cbar=True, vmax=None, vmin=0, row_cluster=True, col_cluster=True)#
Generate a clustered heatmap from the given data and optionally save it to a file.
- Parameters:
data (pandas.DataFrame) – The data to visualize as a heatmap. Rows and columns will be clustered if specified.
output_path (str) – Directory where the heatmap should be saved if
saveis True. Defaults to an empty string.save (bool) – Whether to save the generated heatmap to a file. Defaults to False.
figsize (tuple) – Size of the figure as (width, height). If None, the size is calculated based on the data dimensions. Defaults to None.
tag (str) – A tag to append to the saved file name. Defaults to an empty string.
title (str) – Title of the heatmap. Defaults to None.
cmap (str) – Colormap to use for the heatmap. Defaults to “RdBu_r”.
annot (bool) – Whether to annotate the heatmap cells with their values. Defaults to False.
cbar (bool) – Whether to display a color bar in the heatmap. Defaults to True.
vmax (float) – Maximum value for the colormap. Defaults to None.
vmin (float) – Minimum value for the colormap. Defaults to 0.
row_cluster (bool) – Whether to perform hierarchical clustering on rows. Defaults to True.
col_cluster (bool) – Whether to perform hierarchical clustering on columns. Defaults to True.
- Returns:
None
Notes
If
saveis True, the heatmap will be saved as a PDF file in theoutput_path/figuresdirectory.Clustering is performed using seaborn’s
clustermapfunction.