From 3f9bd6245a9c00436efd9544ca3d8f3532a6d753 Mon Sep 17 00:00:00 2001 From: Joshua Charkow Date: Thu, 5 Mar 2026 09:18:54 -0500 Subject: [PATCH] Mahmoud pemp implementation --- pyprophet/stats.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pyprophet/stats.py b/pyprophet/stats.py index 07285d67..1523f5d2 100644 --- a/pyprophet/stats.py +++ b/pyprophet/stats.py @@ -143,8 +143,13 @@ def pemp(stat, stat0): m = len(stat) m0 = len(stat0) - statc = np.concatenate((stat, stat0)) - v = np.array([True] * m + [False] * m0) + # ------- originally (as in r implementation): + #statc = np.concatenate((stat, stat0)) + #v = np.array([True] * m + [False] * m0) + # ------- switching the positions of Targets and decoys to avoid pi0 becoming negative, basically, decoys win ties making p values more conservative + statc = np.concatenate((stat0, stat)) + v = np.array( [False] * m0 + [True] * m) + perm = np.argsort(-statc, kind="mergesort") # reversed sort, mergesort is stable v = v[perm]