From da20d13aec691ceea2ac959830fd91206c362c39 Mon Sep 17 00:00:00 2001 From: Jamie Kai <31858695+jwkai@users.noreply.github.com> Date: Thu, 2 Feb 2023 21:57:47 -0800 Subject: [PATCH] Update variable_function.py --- .../tools/variable_function/variable_function.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/alldata/bblab_site/tools/variable_function/variable_function.py b/alldata/bblab_site/tools/variable_function/variable_function.py index 11e6dd2..da0b58f 100644 --- a/alldata/bblab_site/tools/variable_function/variable_function.py +++ b/alldata/bblab_site/tools/variable_function/variable_function.py @@ -84,13 +84,15 @@ def mwu_choose_method(x, y): return "asymptotic" return "exact" - def mannwhitneyu_category(result, category): + def mannwhitneyu_category(result, category, stringify_p): pos = [float(x[-1]) for x in result if category in x[:-1]] pos_median = median(pos) neg = [float(x[-1]) for x in result if category not in x[:-1]] neg_median = median(neg) mwu_method = mwu_choose_method(pos, neg) _, p = stats.mannwhitneyu(pos, neg, alternative='two-sided', method=mwu_method) + if stringify_p: + p = "{:.8f}".format(p) return [len(pos), len(neg), pos_median, neg_median, p, mwu_method] try: @@ -112,7 +114,7 @@ def mannwhitneyu_category(result, category):