Skip to content

Commit

Permalink
Merge pull request #76 from yyoshiaki/fix-plot_group_stats
Browse files Browse the repository at this point in the history
fixed the bug in scdrs/util.py
  • Loading branch information
KangchengHou authored Nov 29, 2023
2 parents 9417105 + 76f51aa commit a7c9efe
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions scdrs/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def plot_group_stats(
[dict_df_stats[trait]["assoc_mcp"] for trait in trait_list], axis=1
).T
df_assoc_fdr = pd.DataFrame(
multipletests(df_assoc_fdr.values.flatten(), method="fdr_bh")[1].reshape(
multipletests(df_assoc_fdr.values.flatten(), method="fdr_bh", alpha=assoc_fdr_threshold)[0].reshape(
df_assoc_fdr.shape
),
index=df_assoc_fdr.index,
Expand All @@ -552,7 +552,7 @@ def plot_group_stats(
[dict_df_stats[trait]["hetero_mcp"] for trait in trait_list], axis=1
).T
df_hetero_fdr = pd.DataFrame(
multipletests(df_hetero_fdr.values.flatten(), method="fdr_bh")[1].reshape(
multipletests(df_hetero_fdr.values.flatten(), method="fdr_bh", alpha=hetero_fdr_threshold)[0].reshape(
df_hetero_fdr.shape
),
index=df_hetero_fdr.index,
Expand All @@ -567,11 +567,13 @@ def plot_group_stats(
and (df_assoc_fdr is not None)
and (df_hetero_fdr is not None)
), "If dict_df_stats is not provided, df_fdr_prop, df_assoc_fdr, df_hetero_fdr must be all provided."
df_assoc_fdr = (df_assoc_fdr < assoc_fdr_threshold)
df_hetero_fdr = (df_hetero_fdr < hetero_fdr_threshold)

df_hetero_fdr = df_hetero_fdr * df_assoc_fdr
df_hetero_fdr = df_hetero_fdr.applymap(
lambda x: "×" if x < hetero_fdr_threshold else ""
lambda x: "×" if x else ""
)
df_hetero_fdr[df_assoc_fdr > assoc_fdr_threshold] = ""

fig, ax = plot_heatmap(
df_fdr_prop,
Expand All @@ -593,7 +595,7 @@ def plot_group_stats(

small_squares(
ax,
pos=[(y, x) for x, y in zip(*np.where(df_assoc_fdr < assoc_fdr_threshold))],
pos=[(y, x) for x, y in zip(*np.where(df_assoc_fdr))],
size=plot_kws["signif_size"],
linewidth=plot_kws["signif_width"],
)
Expand Down

0 comments on commit a7c9efe

Please sign in to comment.