Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion qvalue/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from qvalue import *
from .qvalue import *
8 changes: 4 additions & 4 deletions qvalue/qvalue.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def estimate(pv, m=None, verbose=False, lowmem=False, pi0=None):
tck = interpolate.splrep(lam, pi0, k=3)
pi0 = interpolate.splev(lam[-1], tck)
if verbose:
print("qvalues pi0=%.3f, estimated proportion of null features " % pi0)
print(("qvalues pi0=%.3f, estimated proportion of null features " % pi0))

if pi0 > 1:
if verbose:
print("got pi0 > 1 (%.3f) while estimating qvalues, setting it to 1" % pi0)
print(("got pi0 > 1 (%.3f) while estimating qvalues, setting it to 1" % pi0))
pi0 = 1.0

assert(pi0 >= 0 and pi0 <= 1), "pi0 is not between 0 and 1: %f" % pi0
Expand All @@ -63,7 +63,7 @@ def estimate(pv, m=None, verbose=False, lowmem=False, pi0=None):
qv[last_pv] = (pi0*pv[last_pv]*m)/float(m)
pv[last_pv] = -sp.inf
prev_qv = last_pv
for i in xrange(int(len(pv))-2, -1, -1):
for i in range(int(len(pv))-2, -1, -1):
cur_max = pv.argmax()
qv_i = (pi0*m*pv[cur_max]/float(i+1))
pv[cur_max] = -sp.inf
Expand All @@ -77,7 +77,7 @@ def estimate(pv, m=None, verbose=False, lowmem=False, pi0=None):
qv = pi0 * m/len(pv) * pv
qv[-1] = min(qv[-1], 1.0)

for i in xrange(len(pv)-2, -1, -1):
for i in range(len(pv)-2, -1, -1):
qv[i] = min(pi0*m*pv[i]/(i+1.0), qv[i+1])

# reorder qvalues
Expand Down