Skip to content

Commit

Permalink
Update plot_cpdb_heatmap.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zktuong committed Apr 18, 2024
1 parent 642bb98 commit 85ea8f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ktplotspy/plot/plot_cpdb_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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))
Expand Down

0 comments on commit 85ea8f0

Please sign in to comment.