From 98304d9af2a42d5910a2cd33226c0c14fe5e2bd0 Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Sun, 25 Feb 2024 10:41:02 +0000 Subject: [PATCH 1/2] Update `heatmap` Add argument `title`. --- src/cellrank/pl/_heatmap.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cellrank/pl/_heatmap.py b/src/cellrank/pl/_heatmap.py index 7359593cb..9d381b4e2 100644 --- a/src/cellrank/pl/_heatmap.py +++ b/src/cellrank/pl/_heatmap.py @@ -89,6 +89,7 @@ def heatmap( dpi: Optional[int] = None, save: Optional[Union[str, pathlib.Path]] = None, gene_order: Optional[Sequence[str]] = None, + title: Optional[str] = None, **kwargs: Any, ) -> Optional[Union[Dict[str, pd.DataFrame], Tuple[_return_model_type, Dict[str, pd.DataFrame]]]]: """Plot a heatmap of smoothed gene expression along specified lineages. @@ -340,6 +341,8 @@ def color_fill_rec(ax, xs, y1, y2, colors=None, cmap=cmap, **kwargs) -> None: labelbottom=True, ) ax.set_xlabel(xlabel) + if title is not None: + ax.set_title(title) return fig, None @@ -443,6 +446,8 @@ def _(gene_order: Optional[Sequence[str]] = None) -> Tuple[List[plt.Figure], pd. g.ax_heatmap.set_xlabel(xlabel) g.ax_heatmap.set_xticks(np.linspace(0, len(df.columns), _N_XTICKS)) g.ax_heatmap.set_xticklabels([round(n, 3) for n in np.linspace(x_min, x_max, _N_XTICKS)]) + if title is not None: + g.ax_heatmap.set_title(title) # fmt: on if show_clust: # robustly show dendrogram, because gene names can be long From ad63d57e9fdb4cb94710b13a5643387f8e38a848 Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Sun, 25 Feb 2024 10:41:36 +0000 Subject: [PATCH 2/2] Update `heatmap` Change order of arguments and add docstring for `title`. --- src/cellrank/pl/_heatmap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cellrank/pl/_heatmap.py b/src/cellrank/pl/_heatmap.py index 9d381b4e2..37f72194a 100644 --- a/src/cellrank/pl/_heatmap.py +++ b/src/cellrank/pl/_heatmap.py @@ -77,6 +77,7 @@ def heatmap( lineage_height: float = 0.33, fontsize: Optional[float] = None, xlabel: Optional[str] = None, + title: Optional[str] = None, cmap: colors.ListedColormap = cm.viridis, dendrogram: bool = True, return_genes: bool = False, @@ -89,7 +90,6 @@ def heatmap( dpi: Optional[int] = None, save: Optional[Union[str, pathlib.Path]] = None, gene_order: Optional[Sequence[str]] = None, - title: Optional[str] = None, **kwargs: Any, ) -> Optional[Union[Dict[str, pd.DataFrame], Tuple[_return_model_type, Dict[str, pd.DataFrame]]]]: """Plot a heatmap of smoothed gene expression along specified lineages. @@ -148,6 +148,8 @@ def heatmap( Size of the title's font. xlabel Label on the x-axis. If :obj:`None`, it is determined based on ``time_key``. + title + Title of the figure. cmap Colormap to use when visualizing the smoothed expression. dendrogram