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
4 changes: 2 additions & 2 deletions idr/idr.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,8 @@ def build_rank_vectors(merged_peaks):
rank1 = numpy.lexsort((numpy.random.random(len(s1)), s1)).argsort()
rank2 = numpy.lexsort((numpy.random.random(len(s2)), s2)).argsort()

return ( numpy.array(rank1, dtype=numpy.int),
numpy.array(rank2, dtype=numpy.int) )
return ( numpy.array(rank1, dtype=int),
numpy.array(rank2, dtype=int) )

def build_idr_output_line_with_bed6(
m_pk, IDR, localIDR, output_file_type, signal_type,
Expand Down
15 changes: 8 additions & 7 deletions idr/inv_cdf.pyx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cimport cython
cimport numpy as np
import numpy as np
from libc.math cimport exp, sqrt, pow, log, erf, fabs
from libc.stdlib cimport malloc, free

Expand Down Expand Up @@ -67,20 +68,20 @@ def cdf_i(double r, double mu, double sigma, double lamda,
@cython.wraparound(False)
@cython.cdivision(True)
def c_compute_pseudo_values(
np.ndarray[np.int_t, ndim=1] rs,
np.ndarray[np.double_t, ndim=1] zs,
long[:] rs,
double[:] zs,
double mu, double sigma, double lamda,
double EPS):
cdef int N = len(rs)
cdef int N = rs.shape[0]
cdef double pseudo_N = N+1
cdef double* ordered_zs = <double * >malloc(N*sizeof(double))

cdef double smallest_r = 1./pseudo_N
lb = d_min(0, mu)
cdef double lb = d_min(0, mu)
while c_cdf(lb, mu, sigma, lamda) > smallest_r:
lb -= 1

ub = d_max(0, mu)
cdef double ub = d_max(0, mu)
while c_cdf(ub, mu, sigma, lamda) < 1-smallest_r:
ub += 1

Expand All @@ -101,7 +102,7 @@ def c_compute_pseudo_values(
ub = lb + 2*(res - ordered_zs[i-1])

for i in range(N):
zs[i] = ordered_zs[rs[i]]
zs[i] = ordered_zs[<size_t>rs[i]]
free( ordered_zs )

return zs
return np.asarray(zs)