From b5b5e749b13f8f4fa47a743dbf948eab04bf78cf Mon Sep 17 00:00:00 2001 From: yyoshiaki Date: Wed, 29 Nov 2023 11:37:31 +0900 Subject: [PATCH 1/2] fixed the bug in scdrs/util.py When mcp included NaN, significance was not displayed. This is because multipletest()[1] is filled with NaN when p values included NaN, while multipletest()[0] is normal. By modifying to use multipletest()[0], the problem is solved. --- scdrs/util.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scdrs/util.py b/scdrs/util.py index 6eaccc4..07895af 100644 --- a/scdrs/util.py +++ b/scdrs/util.py @@ -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, @@ -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, @@ -568,10 +568,10 @@ def plot_group_stats( 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_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, @@ -593,7 +593,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"], ) From 76f51aaf483a0e544ded07ed8b532867f5b6861e Mon Sep 17 00:00:00 2001 From: yyoshiaki Date: Wed, 29 Nov 2023 18:06:00 +0900 Subject: [PATCH 2/2] added the two lines --- scdrs/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scdrs/util.py b/scdrs/util.py index 07895af..a23db8b 100644 --- a/scdrs/util.py +++ b/scdrs/util.py @@ -567,6 +567,8 @@ 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(