From 85ea8f0f856b95ed152a1ccad1f521522149e499 Mon Sep 17 00:00:00 2001 From: Zewen Kelvin Tuong Date: Fri, 19 Apr 2024 09:31:31 +1000 Subject: [PATCH] Update plot_cpdb_heatmap.py --- ktplotspy/plot/plot_cpdb_heatmap.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ktplotspy/plot/plot_cpdb_heatmap.py b/ktplotspy/plot/plot_cpdb_heatmap.py index 36a129e..053d77f 100644 --- a/ktplotspy/plot/plot_cpdb_heatmap.py +++ b/ktplotspy/plot/plot_cpdb_heatmap.py @@ -27,6 +27,7 @@ def plot_cpdb_heatmap( title: str = "", return_tables: bool = False, symmetrical: bool = True, + default_sep: str = DEFAULT_CPDB_SEP, **kwargs ) -> Union[sns.matrix.ClusterGrid, Dict]: """Plot cellphonedb results as total counts of interactions. @@ -66,6 +67,8 @@ def plot_cpdb_heatmap( Whether to return the dataframes storing the interaction network. symmetrical : bool, optional Whether to return the sum of interactions as symmetrical heatmap. + default_sep : str, optional + The default separator used when CellPhoneDB was run. **kwargs Passed to seaborn.clustermap. @@ -83,7 +86,7 @@ def plot_cpdb_heatmap( all_int = all_intr.iloc[:, col_start : all_intr.shape[1]].T all_int.columns = intr_pairs if cell_types is None: - cell_types = sorted(list(set([y for z in [x.split(DEFAULT_CPDB_SEP) for x in all_intr.columns[col_start:]] for y in z]))) + cell_types = sorted(list(set([y for z in [x.split(default_sep) for x in all_intr.columns[col_start:]] for y in z]))) cell_types_comb = ["|".join(list(x)) for x in list(product(cell_types, cell_types))] cell_types_keep = [ct for ct in all_int.index if ct in cell_types_comb] empty_celltypes = list(set(cell_types_comb) ^ set(cell_types_keep))