Skip to content

Commit

Permalink
Update plot_cpdb.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-harasty authored and zktuong committed Jun 28, 2024
1 parent 75320b4 commit c6766dd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ktplotspy/plot/plot_cpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def plot_cpdb(
scale_alpha_by_cellsign: bool = False,
filter_by_cellsign: bool = False,
keep_id_cp_interaction: bool = False,
result_precision: int = 3,
) -> Union[ggplot, pd.DataFrame]:
"""Plotting CellPhoneDB results as a dot plot.
Expand Down Expand Up @@ -160,6 +161,8 @@ def plot_cpdb(
Filter out interactions with a 0 value cellsign.
keep_id_cp_interaction: bool, optional
Whether to keep the original `id_cp_interaction` value when plotting.
result_precision: int, optional
Sets integer value for decimal points of p_value, default to 3
Returns
-------
Union[ggplot, pd.DataFrame]
Expand Down Expand Up @@ -334,6 +337,9 @@ def plot_cpdb(
df_pvals.columns = DEFAULT_COLUMNS + ["pvals"]
df.celltype_group = [re.sub(DEFAULT_SEP, "-", c) for c in df.celltype_group]
df["pvals"] = df_pvals["pvals"]
# change the decimal points
if df.at[i, "pvals"] == 0:
df.at[i, "pvals"] = 1**-result_precision
if interaction_scores is not None:
df_interaction_scores = interaction_scores_matx.melt(ignore_index=False).reset_index()
df_interaction_scores.index = df_interaction_scores["index"] + DEFAULT_SEP * 3 + df_interaction_scores["variable"]
Expand Down

0 comments on commit c6766dd

Please sign in to comment.