From 78a86f6e41a9466e5f5c77fdfd106a4c7a3ad5e1 Mon Sep 17 00:00:00 2001 From: Daniel Bojar Date: Mon, 26 Feb 2024 13:48:34 +0100 Subject: [PATCH] fix edge case for TST_grouped_benjamini_hochberg when nothing in group is significant --- glycowork/glycan_data/stats.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/glycowork/glycan_data/stats.py b/glycowork/glycan_data/stats.py index b973e28..6d7d501 100644 --- a/glycowork/glycan_data/stats.py +++ b/glycowork/glycan_data/stats.py @@ -573,7 +573,10 @@ def TST_grouped_benjamini_hochberg(identifiers_grouped, p_values_grouped, alpha) # Estimate π0 for the group within the Two-Stage method pi0_estimate = pi0_tst(group_p_values, alpha) if pi0_estimate == 1: - adjusted_p_values[group] = [1.0] * len(group_p_values) + group_adjusted_p_values = [1.0] * len(group_p_values) + for identifier, corrected_pval in zip(identifiers_grouped[group], group_adjusted_p_values): + adjusted_p_values[identifier] = corrected_pval + significance_dict[identifier] = False continue n = len(group_p_values) sorted_indices = np.argsort(group_p_values)