Skip to content

Commit 4f75845

Browse files
authored
Merge pull request #28 from Akanksha2511/ListerLab/master
Speed improvement.
2 parents d470430 + 813d720 commit 4f75845

File tree

3 files changed

+16
-31
lines changed

3 files changed

+16
-31
lines changed

HOME/HOME_functions.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
from sklearn import preprocessing
1414
#from sklearn.externals import joblib
1515
import statsmodels.stats.proportion as sm
16+
def fun_win(val):
17+
t=1-(min(val,1))
18+
return t
1619

1720
def fill_na(df_file):
1821
filter_col = [col for col in list(df_file) if col.startswith(('mc'))]
@@ -214,12 +217,10 @@ def norm_slidingwin_predict_CG(df_file,input_file_path,model_path):
214217

215218
status.append(sign_win)
216219
val=(abs(pos_specific-pos1)/250.0)
217-
wght=[]
218-
for i in val:
219-
t=min(i,1)
220-
wght.append(1-t)
221220

222221

222+
wght=map(fun_win, val)
223+
223224
bins=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
224225
hist,edges = np.histogram(mod_value, bins=bins,weights=wght)
225226
k=float(sum(hist))
@@ -269,12 +270,8 @@ def norm_slidingwin_predict_nonCG(df_file,input_file_path,model_path):
269270

270271
status.append(sign_win)
271272
val=(abs(pos_specific-pos1)/10.0)
272-
wght=[]
273-
for i in val:
274-
t=min(i,1)
275-
wght.append(1-t)
273+
wght=map(fun_win, val)
276274

277-
278275
bins=np.linspace(0,1,11)
279276
hist,edges = np.histogram(mod_value, bins=bins,weights=wght)
280277
k=float(sum(hist))
@@ -772,11 +769,7 @@ def norm_slidingwin_predict_nonCG_withoutchunk(df_file,input_file_path,model_pat
772769

773770
status.append(sign_win)
774771
val=(abs(pos_specific-pos1)/10.0)
775-
wght=[]
776-
for i in val:
777-
t=min(i,1)
778-
wght.append(1-t)
779-
772+
wght=map(fun_win, val)
780773

781774
bins=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
782775
hist,edges = np.histogram(mod_value, bins=bins,weights=wght)

HOME/HOME_timeseries_functions.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
#from sklearn.externals import joblib
1414
import statsmodels.stats.proportion as sm
1515

16+
def fun_win(val):
17+
t=1-(min(val,1))
18+
return t
19+
1620
def fill_na(df_file):
1721
filter_col = [col for col in list(df_file) if col.startswith(('mc'))]
1822
filter_col1 = [col for col in list(df_file) if col.startswith(('h'))]
@@ -215,11 +219,7 @@ def norm_slidingwin_predict_CG(df_file,input_file_path,model_path):
215219

216220
status.append(sign_win)
217221
val=(abs(pos_specific-pos1)/250.0)
218-
wght=[]
219-
for i in val:
220-
t=min(i,1)
221-
wght.append(1-t)
222-
222+
wght=map(fun_win, val)
223223

224224
bins=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
225225
hist,edges = np.histogram(mod_value, bins=bins,weights=wght)
@@ -280,11 +280,7 @@ def norm_slidingwin_predict_nonCG_withoutchunk(df_file,input_file_path,model_pat
280280

281281
status.append(sign_win)
282282
val=(abs(pos_specific-pos1)/10.0)
283-
wght=[]
284-
for i in val:
285-
t=min(i,1)
286-
wght.append(1-t)
287-
283+
wght=map(fun_win, val)
288284

289285
bins=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]
290286
hist,edges = np.histogram(mod_value, bins=bins,weights=wght)
@@ -340,12 +336,8 @@ def norm_slidingwin_predict_nonCG(df_file,input_file_path,model_path):
340336

341337
status.append(sign_win)
342338
val=(abs(pos_specific-pos1)/10.0)
343-
wght=[]
344-
for i in val:
345-
t=min(i,1)
346-
wght.append(1-t)
347-
348-
339+
wght=map(fun_win, val)
340+
349341
bins=np.linspace(0,1,11)
350342
hist,edges = np.histogram(mod_value, bins=bins,weights=wght)
351343
k=float(sum(hist))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
setup(
88
name = 'HOME',
9-
version = '0.7',
9+
version = '0.8',
1010
description="HOME: Histogram Of MEthylation",
1111
author = 'akanksha srivastava',
1212
install_requires = [

0 commit comments

Comments
 (0)