-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclassification.py
570 lines (554 loc) · 48 KB
/
classification.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
import pandas as pd
import numpy as np
import os
from padelpy import padeldescriptor, from_smiles
from joblib import load
from glob import glob
"""
This program contain
1. Load data
2. Compute FP
3. Baseline predict
4. Stacked
5. AD
6. Show outcome
"""
def load_data(df_name):
df = pd.read_csv(df_name+".csv", index_col=0)
print(df)
df["Smiles"].to_csv('smile.smi', sep='\t', index=False, header=False)
return df
def compute_fps(df):
xml_files = glob("*.xml")
xml_files.sort()
FP_list = [
'AP2DC','AD2D','EState','CDKExt','CDK','CDKGraph','KRFPC','KRFP','MACCS','PubChem','SubFPC','SubFP']
fp = dict(zip(FP_list, xml_files))
#Calculate fingerprints
for i in FP_list:
padeldescriptor(mol_dir='smile.smi',
d_file=i+'.csv',
descriptortypes= fp[i],
retainorder=True,
removesalt=True,
threads=2,
detectaromaticity=True,
standardizetautomers=True,
standardizenitro=True,
fingerprints=True
)
Fingerprint = pd.read_csv(i+'.csv').set_index(df.index)
Fingerprint = Fingerprint.drop('Name', axis=1)
Fingerprint.to_csv(i+'.csv')
print(i+'.csv', 'done')
#load at pc
fp_at = pd.read_csv('AD2D.csv' ).set_index(df.index)
fp_es = pd.read_csv('EState.csv' ).set_index(df.index)
fp_ke = pd.read_csv('KRFP.csv' ).set_index(df.index)
fp_pc = pd.read_csv('PubChem.csv' ).set_index(df.index)
fp_ss = pd.read_csv('SubFP.csv' ).set_index(df.index)
fp_cd = pd.read_csv('CDKGraph.csv' ).set_index(df.index)
fp_cn = pd.read_csv('CDK.csv' ).set_index(df.index)
fp_kc = pd.read_csv('KRFPC.csv' ).set_index(df.index)
fp_ce = pd.read_csv('CDKExt.csv' ).set_index(df.index)
fp_sc = pd.read_csv('SubFPC.csv' ).set_index(df.index)
fp_ac = pd.read_csv('AP2DC.csv' ).set_index(df.index)
fp_ma = pd.read_csv('MACCS.csv' ).set_index(df.index)
return fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma
#helper functions
def select_col(df, columns_list):
missing_columns = [col for col in columns_list if col not in df.columns]
if not missing_columns:
return df[columns_list]
else:
return f"Column(s) missing: {', '.join(missing_columns)}"
def ad_measurement(name, df, model, dk, sk, z=0.5):
distance, index = model.kneighbors(df)
di = np.mean(distance, axis=1)
AD_status = ['within_AD' if di[i] < dk + (z * sk) else 'outside_AD' for i in range(len(di))]
df_ad = pd.DataFrame(AD_status, index=df.index, columns=['AD_'+ name])
return df_ad
def herg_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma):
fp_at_sel = pd.read_csv(os.path.join("classification", "herg", "xat_train.csv"), index_col=0)
fp_es_sel = pd.read_csv(os.path.join("classification", "herg", "xes_train.csv"), index_col=0)
fp_ke_sel = pd.read_csv(os.path.join("classification", "herg", "xke_train.csv"), index_col=0)
fp_pc_sel = pd.read_csv(os.path.join("classification", "herg", "xpc_train.csv"), index_col=0)
fp_ss_sel = pd.read_csv(os.path.join("classification", "herg", "xss_train.csv"), index_col=0)
fp_cd_sel = pd.read_csv(os.path.join("classification", "herg", "xcd_train.csv"), index_col=0)
fp_cn_sel = pd.read_csv(os.path.join("classification", "herg", "xcn_train.csv"), index_col=0)
fp_kc_sel = pd.read_csv(os.path.join("classification", "herg", "xkc_train.csv"), index_col=0)
fp_ce_sel = pd.read_csv(os.path.join("classification", "herg", "xce_train.csv"), index_col=0)
fp_sc_sel = pd.read_csv(os.path.join("classification", "herg", "xsc_train.csv"), index_col=0)
fp_ac_sel = pd.read_csv(os.path.join("classification", "herg", "xac_train.csv"), index_col=0)
fp_ma_sel = pd.read_csv(os.path.join("classification", "herg", "xma_train.csv"), index_col=0)
herg_fp_at = fp_at[fp_at_sel.columns]
herg_fp_es = fp_es[fp_es_sel.columns]
herg_fp_ke = fp_ke[fp_ke_sel.columns]
herg_fp_pc = fp_pc[fp_pc_sel.columns]
herg_fp_ss = fp_ss[fp_ss_sel.columns]
herg_fp_cd = fp_cd[fp_cd_sel.columns]
herg_fp_cn = fp_cn[fp_cn_sel.columns]
herg_fp_kc = fp_kc[fp_kc_sel.columns]
herg_fp_ce = fp_ce[fp_ce_sel.columns]
herg_fp_sc = fp_sc[fp_sc_sel.columns]
herg_fp_ac = fp_ac[fp_ac_sel.columns]
herg_fp_ma = fp_ma[fp_ma_sel.columns]
return herg_fp_at, herg_fp_es, herg_fp_ke, herg_fp_pc, herg_fp_ss, herg_fp_cd, herg_fp_cn, herg_fp_kc, herg_fp_ce, herg_fp_sc, herg_fp_ac, herg_fp_ma
def mtor_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma):
fp_at_sel = pd.read_csv(os.path.join("classification", "mtor", "xat_train.csv"), index_col=0)
fp_es_sel = pd.read_csv(os.path.join("classification", "mtor", "xes_train.csv"), index_col=0)
fp_ke_sel = pd.read_csv(os.path.join("classification", "mtor", "xke_train.csv"), index_col=0)
fp_pc_sel = pd.read_csv(os.path.join("classification", "mtor", "xpc_train.csv"), index_col=0)
fp_ss_sel = pd.read_csv(os.path.join("classification", "mtor", "xss_train.csv"), index_col=0)
fp_cd_sel = pd.read_csv(os.path.join("classification", "mtor", "xcd_train.csv"), index_col=0)
fp_cn_sel = pd.read_csv(os.path.join("classification", "mtor", "xcn_train.csv"), index_col=0)
fp_kc_sel = pd.read_csv(os.path.join("classification", "mtor", "xkc_train.csv"), index_col=0)
fp_ce_sel = pd.read_csv(os.path.join("classification", "mtor", "xce_train.csv"), index_col=0)
fp_sc_sel = pd.read_csv(os.path.join("classification", "mtor", "xsc_train.csv"), index_col=0)
fp_ac_sel = pd.read_csv(os.path.join("classification", "mtor", "xac_train.csv"), index_col=0)
fp_ma_sel = pd.read_csv(os.path.join("classification", "mtor", "xma_train.csv"), index_col=0)
mtor_fp_at = fp_at[fp_at_sel.columns]
mtor_fp_es = fp_es[fp_es_sel.columns]
mtor_fp_ke = fp_ke[fp_ke_sel.columns]
mtor_fp_pc = fp_pc[fp_pc_sel.columns]
mtor_fp_ss = fp_ss[fp_ss_sel.columns]
mtor_fp_cd = fp_cd[fp_cd_sel.columns]
mtor_fp_cn = fp_cn[fp_cn_sel.columns]
mtor_fp_kc = fp_kc[fp_kc_sel.columns]
mtor_fp_ce = fp_ce[fp_ce_sel.columns]
mtor_fp_sc = fp_sc[fp_sc_sel.columns]
mtor_fp_ac = fp_ac[fp_ac_sel.columns]
mtor_fp_ma = fp_ma[fp_ma_sel.columns]
return mtor_fp_at, mtor_fp_es, mtor_fp_ke, mtor_fp_pc, mtor_fp_ss, mtor_fp_cd, mtor_fp_cn, mtor_fp_kc, mtor_fp_ce, mtor_fp_sc, mtor_fp_ac, mtor_fp_ma
def pbmcs_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma):
fp_at_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xat_train.csv"), index_col=0)
fp_es_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xes_train.csv"), index_col=0)
fp_ke_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xke_train.csv"), index_col=0)
fp_pc_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xpc_train.csv"), index_col=0)
fp_ss_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xss_train.csv"), index_col=0)
fp_cd_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xcd_train.csv"), index_col=0)
fp_cn_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xcn_train.csv"), index_col=0)
fp_kc_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xkc_train.csv"), index_col=0)
fp_ce_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xce_train.csv"), index_col=0)
fp_sc_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xsc_train.csv"), index_col=0)
fp_ac_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xac_train.csv"), index_col=0)
fp_ma_sel = pd.read_csv(os.path.join("classification", "pbmcs", "xma_train.csv"), index_col=0)
pbmcs_fp_at = fp_at[fp_at_sel.columns]
pbmcs_fp_es = fp_es[fp_es_sel.columns]
pbmcs_fp_ke = fp_ke[fp_ke_sel.columns]
pbmcs_fp_pc = fp_pc[fp_pc_sel.columns]
pbmcs_fp_ss = fp_ss[fp_ss_sel.columns]
pbmcs_fp_cd = fp_cd[fp_cd_sel.columns]
pbmcs_fp_cn = fp_cn[fp_cn_sel.columns]
pbmcs_fp_kc = fp_kc[fp_kc_sel.columns]
pbmcs_fp_ce = fp_ce[fp_ce_sel.columns]
pbmcs_fp_sc = fp_sc[fp_sc_sel.columns]
pbmcs_fp_ac = fp_ac[fp_ac_sel.columns]
pbmcs_fp_ma = fp_ma[fp_ma_sel.columns]
return pbmcs_fp_at, pbmcs_fp_es, pbmcs_fp_ke, pbmcs_fp_pc, pbmcs_fp_ss, pbmcs_fp_cd, pbmcs_fp_cn, pbmcs_fp_kc, pbmcs_fp_ce, pbmcs_fp_sc, pbmcs_fp_ac, pbmcs_fp_ma
def ames_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma):
fp_at_sel = pd.read_csv(os.path.join("classification", "ames", "xat_train.csv"), index_col=0)
fp_es_sel = pd.read_csv(os.path.join("classification", "ames", "xes_train.csv"), index_col=0)
fp_ke_sel = pd.read_csv(os.path.join("classification", "ames", "xke_train.csv"), index_col=0)
fp_pc_sel = pd.read_csv(os.path.join("classification", "ames", "xpc_train.csv"), index_col=0)
fp_ss_sel = pd.read_csv(os.path.join("classification", "ames", "xss_train.csv"), index_col=0)
fp_cd_sel = pd.read_csv(os.path.join("classification", "ames", "xcd_train.csv"), index_col=0)
fp_cn_sel = pd.read_csv(os.path.join("classification", "ames", "xcn_train.csv"), index_col=0)
fp_kc_sel = pd.read_csv(os.path.join("classification", "ames", "xkc_train.csv"), index_col=0)
fp_ce_sel = pd.read_csv(os.path.join("classification", "ames", "xce_train.csv"), index_col=0)
fp_sc_sel = pd.read_csv(os.path.join("classification", "ames", "xsc_train.csv"), index_col=0)
fp_ac_sel = pd.read_csv(os.path.join("classification", "ames", "xac_train.csv"), index_col=0)
fp_ma_sel = pd.read_csv(os.path.join("classification", "ames", "xma_train.csv"), index_col=0)
ames_fp_at = fp_at[fp_at_sel.columns]
ames_fp_es = fp_es[fp_es_sel.columns]
ames_fp_ke = fp_ke[fp_ke_sel.columns]
ames_fp_pc = fp_pc[fp_pc_sel.columns]
ames_fp_ss = fp_ss[fp_ss_sel.columns]
ames_fp_cd = fp_cd[fp_cd_sel.columns]
ames_fp_cn = fp_cn[fp_cn_sel.columns]
ames_fp_kc = fp_kc[fp_kc_sel.columns]
ames_fp_ce = fp_ce[fp_ce_sel.columns]
ames_fp_sc = fp_sc[fp_sc_sel.columns]
ames_fp_ac = fp_ac[fp_ac_sel.columns]
ames_fp_ma = fp_ma[fp_ma_sel.columns]
return ames_fp_at, ames_fp_es, ames_fp_ke, ames_fp_pc, ames_fp_ss, ames_fp_cd, ames_fp_cn, ames_fp_kc, ames_fp_ce, ames_fp_sc, ames_fp_ac, ames_fp_ma
def stacked_herg(herg_fp_at, herg_fp_es, herg_fp_ke, herg_fp_pc, herg_fp_ss, herg_fp_cd, herg_fp_cn, herg_fp_kc, herg_fp_ce, herg_fp_sc, herg_fp_ac, herg_fp_ma):
rf_at = load(os.path.join("classification", "herg", "baseline_model_rf_at.joblib"))
rf_es = load(os.path.join("classification", "herg", "baseline_model_rf_es.joblib"))
rf_ke = load(os.path.join("classification", "herg", "baseline_model_rf_ke.joblib"))
rf_pc = load(os.path.join("classification", "herg", "baseline_model_rf_pc.joblib"))
rf_ss = load(os.path.join("classification", "herg", "baseline_model_rf_ss.joblib"))
rf_cd = load(os.path.join("classification", "herg", "baseline_model_rf_cd.joblib"))
rf_cn = load(os.path.join("classification", "herg", "baseline_model_rf_cn.joblib"))
rf_kc = load(os.path.join("classification", "herg", "baseline_model_rf_kc.joblib"))
rf_ce = load(os.path.join("classification", "herg", "baseline_model_rf_ce.joblib"))
rf_sc = load(os.path.join("classification", "herg", "baseline_model_rf_sc.joblib"))
rf_ac = load(os.path.join("classification", "herg", "baseline_model_rf_ac.joblib"))
rf_ma = load(os.path.join("classification", "herg", "baseline_model_rf_ma.joblib"))
yat_pred_rf_test = pd.DataFrame(rf_at.predict(herg_fp_at), columns=["yat_pred_rf"]).set_index(herg_fp_at.index)
yes_pred_rf_test = pd.DataFrame(rf_es.predict(herg_fp_es), columns=["yes_pred_rf"]).set_index(herg_fp_es.index)
yke_pred_rf_test = pd.DataFrame(rf_ke.predict(herg_fp_ke), columns=["yke_pred_rf"]).set_index(herg_fp_ke.index)
ypc_pred_rf_test = pd.DataFrame(rf_pc.predict(herg_fp_pc), columns=["ypc_pred_rf"]).set_index(herg_fp_pc.index)
yss_pred_rf_test = pd.DataFrame(rf_ss.predict(herg_fp_ss), columns=["yss_pred_rf"]).set_index(herg_fp_ss.index)
ycd_pred_rf_test = pd.DataFrame(rf_cd.predict(herg_fp_cd), columns=["ycd_pred_rf"]).set_index(herg_fp_cd.index)
ycn_pred_rf_test = pd.DataFrame(rf_cn.predict(herg_fp_cn), columns=["ycn_pred_rf"]).set_index(herg_fp_cn.index)
ykc_pred_rf_test = pd.DataFrame(rf_kc.predict(herg_fp_kc), columns=["ykc_pred_rf"]).set_index(herg_fp_kc.index)
yce_pred_rf_test = pd.DataFrame(rf_ce.predict(herg_fp_ce), columns=["yce_pred_rf"]).set_index(herg_fp_ce.index)
ysc_pred_rf_test = pd.DataFrame(rf_sc.predict(herg_fp_sc), columns=["ysc_pred_rf"]).set_index(herg_fp_sc.index)
yac_pred_rf_test = pd.DataFrame(rf_ac.predict(herg_fp_ac), columns=["yac_pred_rf"]).set_index(herg_fp_ac.index)
yma_pred_rf_test = pd.DataFrame(rf_ma.predict(herg_fp_ma), columns=["yma_pred_rf"]).set_index(herg_fp_ma.index)
xgb_at = load(os.path.join("classification", "herg", "baseline_model_xgb_at.joblib"))
xgb_es = load(os.path.join("classification", "herg", "baseline_model_xgb_es.joblib"))
xgb_ke = load(os.path.join("classification", "herg", "baseline_model_xgb_ke.joblib"))
xgb_pc = load(os.path.join("classification", "herg", "baseline_model_xgb_pc.joblib"))
xgb_ss = load(os.path.join("classification", "herg", "baseline_model_xgb_ss.joblib"))
xgb_cd = load(os.path.join("classification", "herg", "baseline_model_xgb_cd.joblib"))
xgb_cn = load(os.path.join("classification", "herg", "baseline_model_xgb_cn.joblib"))
xgb_kc = load(os.path.join("classification", "herg", "baseline_model_xgb_kc.joblib"))
xgb_ce = load(os.path.join("classification", "herg", "baseline_model_xgb_ce.joblib"))
xgb_sc = load(os.path.join("classification", "herg", "baseline_model_xgb_sc.joblib"))
xgb_ac = load(os.path.join("classification", "herg", "baseline_model_xgb_ac.joblib"))
xgb_ma = load(os.path.join("classification", "herg", "baseline_model_xgb_ma.joblib"))
yat_pred_xgb_test = pd.DataFrame(xgb_at.predict(herg_fp_at), columns=["yat_pred_xgb"]).set_index(herg_fp_at.index)
yes_pred_xgb_test = pd.DataFrame(xgb_es.predict(herg_fp_es), columns=["yes_pred_xgb"]).set_index(herg_fp_es.index)
yke_pred_xgb_test = pd.DataFrame(xgb_ke.predict(herg_fp_ke), columns=["yke_pred_xgb"]).set_index(herg_fp_ke.index)
ypc_pred_xgb_test = pd.DataFrame(xgb_pc.predict(herg_fp_pc), columns=["ypc_pred_xgb"]).set_index(herg_fp_pc.index)
yss_pred_xgb_test = pd.DataFrame(xgb_ss.predict(herg_fp_ss), columns=["yss_pred_xgb"]).set_index(herg_fp_ss.index)
ycd_pred_xgb_test = pd.DataFrame(xgb_cd.predict(herg_fp_cd), columns=["ycd_pred_xgb"]).set_index(herg_fp_cd.index)
ycn_pred_xgb_test = pd.DataFrame(xgb_cn.predict(herg_fp_cn), columns=["ycn_pred_xgb"]).set_index(herg_fp_cn.index)
ykc_pred_xgb_test = pd.DataFrame(xgb_kc.predict(herg_fp_kc), columns=["ykc_pred_xgb"]).set_index(herg_fp_kc.index)
yce_pred_xgb_test = pd.DataFrame(xgb_ce.predict(herg_fp_ce), columns=["yce_pred_xgb"]).set_index(herg_fp_ce.index)
ysc_pred_xgb_test = pd.DataFrame(xgb_sc.predict(herg_fp_sc), columns=["ysc_pred_xgb"]).set_index(herg_fp_sc.index)
yac_pred_xgb_test = pd.DataFrame(xgb_ac.predict(herg_fp_ac), columns=["yac_pred_xgb"]).set_index(herg_fp_ac.index)
yma_pred_xgb_test = pd.DataFrame(xgb_ma.predict(herg_fp_ma), columns=["yma_pred_xgb"]).set_index(herg_fp_ma.index)
svm_at = load(os.path.join("classification", "herg", "baseline_model_svc_at.joblib"))
svm_es = load(os.path.join("classification", "herg", "baseline_model_svc_es.joblib"))
svm_ke = load(os.path.join("classification", "herg", "baseline_model_svc_ke.joblib"))
svm_pc = load(os.path.join("classification", "herg", "baseline_model_svc_pc.joblib"))
svm_ss = load(os.path.join("classification", "herg", "baseline_model_svc_ss.joblib"))
svm_cd = load(os.path.join("classification", "herg", "baseline_model_svc_cd.joblib"))
svm_cn = load(os.path.join("classification", "herg", "baseline_model_svc_cn.joblib"))
svm_kc = load(os.path.join("classification", "herg", "baseline_model_svc_kc.joblib"))
svm_ce = load(os.path.join("classification", "herg", "baseline_model_svc_ce.joblib"))
svm_sc = load(os.path.join("classification", "herg", "baseline_model_svc_sc.joblib"))
svm_ac = load(os.path.join("classification", "herg", "baseline_model_svc_ac.joblib"))
svm_ma = load(os.path.join("classification", "herg", "baseline_model_svc_ma.joblib"))
yat_pred_svc_test = pd.DataFrame(svm_at.predict(herg_fp_at), columns=["yat_pred_svc"]).set_index(herg_fp_at.index)
yes_pred_svc_test = pd.DataFrame(svm_es.predict(herg_fp_es), columns=["yes_pred_svc"]).set_index(herg_fp_es.index)
yke_pred_svc_test = pd.DataFrame(svm_ke.predict(herg_fp_ke), columns=["yke_pred_svc"]).set_index(herg_fp_ke.index)
ypc_pred_svc_test = pd.DataFrame(svm_pc.predict(herg_fp_pc), columns=["ypc_pred_svc"]).set_index(herg_fp_pc.index)
yss_pred_svc_test = pd.DataFrame(svm_ss.predict(herg_fp_ss), columns=["yss_pred_svc"]).set_index(herg_fp_ss.index)
ycd_pred_svc_test = pd.DataFrame(svm_cd.predict(herg_fp_cd), columns=["ycd_pred_svc"]).set_index(herg_fp_cd.index)
ycn_pred_svc_test = pd.DataFrame(svm_cn.predict(herg_fp_cn), columns=["ycn_pred_svc"]).set_index(herg_fp_cn.index)
ykc_pred_svc_test = pd.DataFrame(svm_kc.predict(herg_fp_kc), columns=["ykc_pred_svc"]).set_index(herg_fp_kc.index)
yce_pred_svc_test = pd.DataFrame(svm_ce.predict(herg_fp_ce), columns=["yce_pred_svc"]).set_index(herg_fp_ce.index)
ysc_pred_svc_test = pd.DataFrame(svm_sc.predict(herg_fp_sc), columns=["ysc_pred_svc"]).set_index(herg_fp_sc.index)
yac_pred_svc_test = pd.DataFrame(svm_ac.predict(herg_fp_ac), columns=["yac_pred_svc"]).set_index(herg_fp_ac.index)
yma_pred_svc_test = pd.DataFrame(svm_ma.predict(herg_fp_ma), columns=["yma_pred_svc"]).set_index(herg_fp_ma.index)
stack_test = pd.concat([yat_pred_rf_test, yat_pred_xgb_test, yat_pred_svc_test,
yes_pred_rf_test, yes_pred_xgb_test, yes_pred_svc_test,
yke_pred_rf_test, yke_pred_xgb_test, yke_pred_svc_test,
ypc_pred_rf_test, ypc_pred_xgb_test, ypc_pred_svc_test,
yss_pred_rf_test, yss_pred_xgb_test, yss_pred_svc_test,
ycd_pred_rf_test, ycd_pred_xgb_test, ycd_pred_svc_test,
ycn_pred_rf_test, ycn_pred_xgb_test, ycn_pred_svc_test,
ykc_pred_rf_test, ykc_pred_xgb_test, ykc_pred_svc_test,
yce_pred_rf_test, yce_pred_xgb_test, yce_pred_svc_test,
ysc_pred_rf_test, ysc_pred_xgb_test, ysc_pred_svc_test,
yac_pred_rf_test, yac_pred_xgb_test, yac_pred_svc_test,
yma_pred_rf_test, yma_pred_xgb_test, yma_pred_svc_test,], axis=1)
stacked_model = load(os.path.join("classification", "herg", "stacked_model.joblib"))
y_pred = pd.DataFrame(stacked_model.predict(stack_test), columns=["hERG_class"]).set_index(herg_fp_at.index)
ad_model = load(os.path.join("classification", "herg", "ad_1_0.5.joblib"))
y_ad = ad_measurement("hERG", stack_test, ad_model, 0.8779, 0.9588, z=0.5)
y_pred = pd.concat([y_pred, y_ad], axis=1)
return y_pred
def stacked_mtor(mtor_fp_at, mtor_fp_es, mtor_fp_ke, mtor_fp_pc, mtor_fp_ss, mtor_fp_cd, mtor_fp_cn, mtor_fp_kc, mtor_fp_ce, mtor_fp_sc, mtor_fp_ac, mtor_fp_ma):
rf_at = load(os.path.join("classification", "mtor", "baseline_model_rf_at.joblib"))
rf_es = load(os.path.join("classification", "mtor", "baseline_model_rf_es.joblib"))
rf_ke = load(os.path.join("classification", "mtor", "baseline_model_rf_ke.joblib"))
rf_pc = load(os.path.join("classification", "mtor", "baseline_model_rf_pc.joblib"))
rf_ss = load(os.path.join("classification", "mtor", "baseline_model_rf_ss.joblib"))
rf_cd = load(os.path.join("classification", "mtor", "baseline_model_rf_cd.joblib"))
rf_cn = load(os.path.join("classification", "mtor", "baseline_model_rf_cn.joblib"))
rf_kc = load(os.path.join("classification", "mtor", "baseline_model_rf_kc.joblib"))
rf_ce = load(os.path.join("classification", "mtor", "baseline_model_rf_ce.joblib"))
rf_sc = load(os.path.join("classification", "mtor", "baseline_model_rf_sc.joblib"))
rf_ac = load(os.path.join("classification", "mtor", "baseline_model_rf_ac.joblib"))
rf_ma = load(os.path.join("classification", "mtor", "baseline_model_rf_ma.joblib"))
yat_pred_rf_test = pd.DataFrame(rf_at.predict(mtor_fp_at), columns=["yat_pred_rf"]).set_index(mtor_fp_at.index)
yes_pred_rf_test = pd.DataFrame(rf_es.predict(mtor_fp_es), columns=["yes_pred_rf"]).set_index(mtor_fp_es.index)
yke_pred_rf_test = pd.DataFrame(rf_ke.predict(mtor_fp_ke), columns=["yke_pred_rf"]).set_index(mtor_fp_ke.index)
ypc_pred_rf_test = pd.DataFrame(rf_pc.predict(mtor_fp_pc), columns=["ypc_pred_rf"]).set_index(mtor_fp_pc.index)
yss_pred_rf_test = pd.DataFrame(rf_ss.predict(mtor_fp_ss), columns=["yss_pred_rf"]).set_index(mtor_fp_ss.index)
ycd_pred_rf_test = pd.DataFrame(rf_cd.predict(mtor_fp_cd), columns=["ycd_pred_rf"]).set_index(mtor_fp_cd.index)
ycn_pred_rf_test = pd.DataFrame(rf_cn.predict(mtor_fp_cn), columns=["ycn_pred_rf"]).set_index(mtor_fp_cn.index)
ykc_pred_rf_test = pd.DataFrame(rf_kc.predict(mtor_fp_kc), columns=["ykc_pred_rf"]).set_index(mtor_fp_kc.index)
yce_pred_rf_test = pd.DataFrame(rf_ce.predict(mtor_fp_ce), columns=["yce_pred_rf"]).set_index(mtor_fp_ce.index)
ysc_pred_rf_test = pd.DataFrame(rf_sc.predict(mtor_fp_sc), columns=["ysc_pred_rf"]).set_index(mtor_fp_sc.index)
yac_pred_rf_test = pd.DataFrame(rf_ac.predict(mtor_fp_ac), columns=["yac_pred_rf"]).set_index(mtor_fp_ac.index)
yma_pred_rf_test = pd.DataFrame(rf_ma.predict(mtor_fp_ma), columns=["yma_pred_rf"]).set_index(mtor_fp_ma.index)
xgb_at = load(os.path.join("classification", "mtor", "baseline_model_xgb_at.joblib"))
xgb_es = load(os.path.join("classification", "mtor", "baseline_model_xgb_es.joblib"))
xgb_ke = load(os.path.join("classification", "mtor", "baseline_model_xgb_ke.joblib"))
xgb_pc = load(os.path.join("classification", "mtor", "baseline_model_xgb_pc.joblib"))
xgb_ss = load(os.path.join("classification", "mtor", "baseline_model_xgb_ss.joblib"))
xgb_cd = load(os.path.join("classification", "mtor", "baseline_model_xgb_cd.joblib"))
xgb_cn = load(os.path.join("classification", "mtor", "baseline_model_xgb_cn.joblib"))
xgb_kc = load(os.path.join("classification", "mtor", "baseline_model_xgb_kc.joblib"))
xgb_ce = load(os.path.join("classification", "mtor", "baseline_model_xgb_ce.joblib"))
xgb_sc = load(os.path.join("classification", "mtor", "baseline_model_xgb_sc.joblib"))
xgb_ac = load(os.path.join("classification", "mtor", "baseline_model_xgb_ac.joblib"))
xgb_ma = load(os.path.join("classification", "mtor", "baseline_model_xgb_ma.joblib"))
yat_pred_xgb_test = pd.DataFrame(xgb_at.predict(mtor_fp_at), columns=["yat_pred_xgb"]).set_index(mtor_fp_at.index)
yes_pred_xgb_test = pd.DataFrame(xgb_es.predict(mtor_fp_es), columns=["yes_pred_xgb"]).set_index(mtor_fp_es.index)
yke_pred_xgb_test = pd.DataFrame(xgb_ke.predict(mtor_fp_ke), columns=["yke_pred_xgb"]).set_index(mtor_fp_ke.index)
ypc_pred_xgb_test = pd.DataFrame(xgb_pc.predict(mtor_fp_pc), columns=["ypc_pred_xgb"]).set_index(mtor_fp_pc.index)
yss_pred_xgb_test = pd.DataFrame(xgb_ss.predict(mtor_fp_ss), columns=["yss_pred_xgb"]).set_index(mtor_fp_ss.index)
ycd_pred_xgb_test = pd.DataFrame(xgb_cd.predict(mtor_fp_cd), columns=["ycd_pred_xgb"]).set_index(mtor_fp_cd.index)
ycn_pred_xgb_test = pd.DataFrame(xgb_cn.predict(mtor_fp_cn), columns=["ycn_pred_xgb"]).set_index(mtor_fp_cn.index)
ykc_pred_xgb_test = pd.DataFrame(xgb_kc.predict(mtor_fp_kc), columns=["ykc_pred_xgb"]).set_index(mtor_fp_kc.index)
yce_pred_xgb_test = pd.DataFrame(xgb_ce.predict(mtor_fp_ce), columns=["yce_pred_xgb"]).set_index(mtor_fp_ce.index)
ysc_pred_xgb_test = pd.DataFrame(xgb_sc.predict(mtor_fp_sc), columns=["ysc_pred_xgb"]).set_index(mtor_fp_sc.index)
yac_pred_xgb_test = pd.DataFrame(xgb_ac.predict(mtor_fp_ac), columns=["yac_pred_xgb"]).set_index(mtor_fp_ac.index)
yma_pred_xgb_test = pd.DataFrame(xgb_ma.predict(mtor_fp_ma), columns=["yma_pred_xgb"]).set_index(mtor_fp_ma.index)
svm_at = load(os.path.join("classification", "mtor", "baseline_model_svc_at.joblib"))
svm_es = load(os.path.join("classification", "mtor", "baseline_model_svc_es.joblib"))
svm_ke = load(os.path.join("classification", "mtor", "baseline_model_svc_ke.joblib"))
svm_pc = load(os.path.join("classification", "mtor", "baseline_model_svc_pc.joblib"))
svm_ss = load(os.path.join("classification", "mtor", "baseline_model_svc_ss.joblib"))
svm_cd = load(os.path.join("classification", "mtor", "baseline_model_svc_cd.joblib"))
svm_cn = load(os.path.join("classification", "mtor", "baseline_model_svc_cn.joblib"))
svm_kc = load(os.path.join("classification", "mtor", "baseline_model_svc_kc.joblib"))
svm_ce = load(os.path.join("classification", "mtor", "baseline_model_svc_ce.joblib"))
svm_sc = load(os.path.join("classification", "mtor", "baseline_model_svc_sc.joblib"))
svm_ac = load(os.path.join("classification", "mtor", "baseline_model_svc_ac.joblib"))
svm_ma = load(os.path.join("classification", "mtor", "baseline_model_svc_ma.joblib"))
yat_pred_svc_test = pd.DataFrame(svm_at.predict(mtor_fp_at), columns=["yat_pred_svc"]).set_index(mtor_fp_at.index)
yes_pred_svc_test = pd.DataFrame(svm_es.predict(mtor_fp_es), columns=["yes_pred_svc"]).set_index(mtor_fp_es.index)
yke_pred_svc_test = pd.DataFrame(svm_ke.predict(mtor_fp_ke), columns=["yke_pred_svc"]).set_index(mtor_fp_ke.index)
ypc_pred_svc_test = pd.DataFrame(svm_pc.predict(mtor_fp_pc), columns=["ypc_pred_svc"]).set_index(mtor_fp_pc.index)
yss_pred_svc_test = pd.DataFrame(svm_ss.predict(mtor_fp_ss), columns=["yss_pred_svc"]).set_index(mtor_fp_ss.index)
ycd_pred_svc_test = pd.DataFrame(svm_cd.predict(mtor_fp_cd), columns=["ycd_pred_svc"]).set_index(mtor_fp_cd.index)
ycn_pred_svc_test = pd.DataFrame(svm_cn.predict(mtor_fp_cn), columns=["ycn_pred_svc"]).set_index(mtor_fp_cn.index)
ykc_pred_svc_test = pd.DataFrame(svm_kc.predict(mtor_fp_kc), columns=["ykc_pred_svc"]).set_index(mtor_fp_kc.index)
yce_pred_svc_test = pd.DataFrame(svm_ce.predict(mtor_fp_ce), columns=["yce_pred_svc"]).set_index(mtor_fp_ce.index)
ysc_pred_svc_test = pd.DataFrame(svm_sc.predict(mtor_fp_sc), columns=["ysc_pred_svc"]).set_index(mtor_fp_sc.index)
yac_pred_svc_test = pd.DataFrame(svm_ac.predict(mtor_fp_ac), columns=["yac_pred_svc"]).set_index(mtor_fp_ac.index)
yma_pred_svc_test = pd.DataFrame(svm_ma.predict(mtor_fp_ma), columns=["yma_pred_svc"]).set_index(mtor_fp_ma.index)
stack_test = pd.concat([yat_pred_rf_test, yat_pred_xgb_test, yat_pred_svc_test,
yes_pred_rf_test, yes_pred_xgb_test, yes_pred_svc_test,
yke_pred_rf_test, yke_pred_xgb_test, yke_pred_svc_test,
ypc_pred_rf_test, ypc_pred_xgb_test, ypc_pred_svc_test,
yss_pred_rf_test, yss_pred_xgb_test, yss_pred_svc_test,
ycd_pred_rf_test, ycd_pred_xgb_test, ycd_pred_svc_test,
ycn_pred_rf_test, ycn_pred_xgb_test, ycn_pred_svc_test,
ykc_pred_rf_test, ykc_pred_xgb_test, ykc_pred_svc_test,
yce_pred_rf_test, yce_pred_xgb_test, yce_pred_svc_test,
ysc_pred_rf_test, ysc_pred_xgb_test, ysc_pred_svc_test,
yac_pred_rf_test, yac_pred_xgb_test, yac_pred_svc_test,
yma_pred_rf_test, yma_pred_xgb_test, yma_pred_svc_test,], axis=1)
stacked_model = load(os.path.join("classification", "mtor", "stacked_model.joblib"))
y_pred = pd.DataFrame(stacked_model.predict(stack_test), columns=["mTOR_class"]).set_index(mtor_fp_at.index)
ad_model = load(os.path.join("classification", "mtor", "ad_1_4.joblib"))
y_ad = ad_measurement("mTOR", stack_test, ad_model, 0.79548, 1.0124, z=4)
y_pred = pd.concat([y_pred, y_ad], axis=1)
return y_pred
def stacked_pbmcs(pbmcs_fp_at, pbmcs_fp_es, pbmcs_fp_ke, pbmcs_fp_pc, pbmcs_fp_ss, pbmcs_fp_cd, pbmcs_fp_cn, pbmcs_fp_kc, pbmcs_fp_ce, pbmcs_fp_sc, pbmcs_fp_ac, pbmcs_fp_ma):
rf_at = load(os.path.join("classification", "pbmcs", "baseline_model_rf_at.joblib"))
rf_es = load(os.path.join("classification", "pbmcs", "baseline_model_rf_es.joblib"))
rf_ke = load(os.path.join("classification", "pbmcs", "baseline_model_rf_ke.joblib"))
rf_pc = load(os.path.join("classification", "pbmcs", "baseline_model_rf_pc.joblib"))
rf_ss = load(os.path.join("classification", "pbmcs", "baseline_model_rf_ss.joblib"))
rf_cd = load(os.path.join("classification", "pbmcs", "baseline_model_rf_cd.joblib"))
rf_cn = load(os.path.join("classification", "pbmcs", "baseline_model_rf_cn.joblib"))
rf_kc = load(os.path.join("classification", "pbmcs", "baseline_model_rf_kc.joblib"))
rf_ce = load(os.path.join("classification", "pbmcs", "baseline_model_rf_ce.joblib"))
rf_sc = load(os.path.join("classification", "pbmcs", "baseline_model_rf_sc.joblib"))
rf_ac = load(os.path.join("classification", "pbmcs", "baseline_model_rf_ac.joblib"))
rf_ma = load(os.path.join("classification", "pbmcs", "baseline_model_rf_ma.joblib"))
yat_pred_rf_test = pd.DataFrame(rf_at.predict(pbmcs_fp_at), columns=["yat_pred_rf"]).set_index(pbmcs_fp_at.index)
yes_pred_rf_test = pd.DataFrame(rf_es.predict(pbmcs_fp_es), columns=["yes_pred_rf"]).set_index(pbmcs_fp_es.index)
yke_pred_rf_test = pd.DataFrame(rf_ke.predict(pbmcs_fp_ke), columns=["yke_pred_rf"]).set_index(pbmcs_fp_ke.index)
ypc_pred_rf_test = pd.DataFrame(rf_pc.predict(pbmcs_fp_pc), columns=["ypc_pred_rf"]).set_index(pbmcs_fp_pc.index)
yss_pred_rf_test = pd.DataFrame(rf_ss.predict(pbmcs_fp_ss), columns=["yss_pred_rf"]).set_index(pbmcs_fp_ss.index)
ycd_pred_rf_test = pd.DataFrame(rf_cd.predict(pbmcs_fp_cd), columns=["ycd_pred_rf"]).set_index(pbmcs_fp_cd.index)
ycn_pred_rf_test = pd.DataFrame(rf_cn.predict(pbmcs_fp_cn), columns=["ycn_pred_rf"]).set_index(pbmcs_fp_cn.index)
ykc_pred_rf_test = pd.DataFrame(rf_kc.predict(pbmcs_fp_kc), columns=["ykc_pred_rf"]).set_index(pbmcs_fp_kc.index)
yce_pred_rf_test = pd.DataFrame(rf_ce.predict(pbmcs_fp_ce), columns=["yce_pred_rf"]).set_index(pbmcs_fp_ce.index)
ysc_pred_rf_test = pd.DataFrame(rf_sc.predict(pbmcs_fp_sc), columns=["ysc_pred_rf"]).set_index(pbmcs_fp_sc.index)
yac_pred_rf_test = pd.DataFrame(rf_ac.predict(pbmcs_fp_ac), columns=["yac_pred_rf"]).set_index(pbmcs_fp_ac.index)
yma_pred_rf_test = pd.DataFrame(rf_ma.predict(pbmcs_fp_ma), columns=["yma_pred_rf"]).set_index(pbmcs_fp_ma.index)
xgb_at = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_at.joblib"))
xgb_es = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_es.joblib"))
xgb_ke = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_ke.joblib"))
xgb_pc = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_pc.joblib"))
xgb_ss = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_ss.joblib"))
xgb_cd = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_cd.joblib"))
xgb_cn = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_cn.joblib"))
xgb_kc = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_kc.joblib"))
xgb_ce = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_ce.joblib"))
xgb_sc = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_sc.joblib"))
xgb_ac = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_ac.joblib"))
xgb_ma = load(os.path.join("classification", "pbmcs", "baseline_model_xgb_ma.joblib"))
yat_pred_xgb_test = pd.DataFrame(xgb_at.predict(pbmcs_fp_at), columns=["yat_pred_xgb"]).set_index(pbmcs_fp_at.index)
yes_pred_xgb_test = pd.DataFrame(xgb_es.predict(pbmcs_fp_es), columns=["yes_pred_xgb"]).set_index(pbmcs_fp_es.index)
yke_pred_xgb_test = pd.DataFrame(xgb_ke.predict(pbmcs_fp_ke), columns=["yke_pred_xgb"]).set_index(pbmcs_fp_ke.index)
ypc_pred_xgb_test = pd.DataFrame(xgb_pc.predict(pbmcs_fp_pc), columns=["ypc_pred_xgb"]).set_index(pbmcs_fp_pc.index)
yss_pred_xgb_test = pd.DataFrame(xgb_ss.predict(pbmcs_fp_ss), columns=["yss_pred_xgb"]).set_index(pbmcs_fp_ss.index)
ycd_pred_xgb_test = pd.DataFrame(xgb_cd.predict(pbmcs_fp_cd), columns=["ycd_pred_xgb"]).set_index(pbmcs_fp_cd.index)
ycn_pred_xgb_test = pd.DataFrame(xgb_cn.predict(pbmcs_fp_cn), columns=["ycn_pred_xgb"]).set_index(pbmcs_fp_cn.index)
ykc_pred_xgb_test = pd.DataFrame(xgb_kc.predict(pbmcs_fp_kc), columns=["ykc_pred_xgb"]).set_index(pbmcs_fp_kc.index)
yce_pred_xgb_test = pd.DataFrame(xgb_ce.predict(pbmcs_fp_ce), columns=["yce_pred_xgb"]).set_index(pbmcs_fp_ce.index)
ysc_pred_xgb_test = pd.DataFrame(xgb_sc.predict(pbmcs_fp_sc), columns=["ysc_pred_xgb"]).set_index(pbmcs_fp_sc.index)
yac_pred_xgb_test = pd.DataFrame(xgb_ac.predict(pbmcs_fp_ac), columns=["yac_pred_xgb"]).set_index(pbmcs_fp_ac.index)
yma_pred_xgb_test = pd.DataFrame(xgb_ma.predict(pbmcs_fp_ma), columns=["yma_pred_xgb"]).set_index(pbmcs_fp_ma.index)
svm_at = load(os.path.join("classification", "pbmcs", "baseline_model_svc_at.joblib"))
svm_es = load(os.path.join("classification", "pbmcs", "baseline_model_svc_es.joblib"))
svm_ke = load(os.path.join("classification", "pbmcs", "baseline_model_svc_ke.joblib"))
svm_pc = load(os.path.join("classification", "pbmcs", "baseline_model_svc_pc.joblib"))
svm_ss = load(os.path.join("classification", "pbmcs", "baseline_model_svc_ss.joblib"))
svm_cd = load(os.path.join("classification", "pbmcs", "baseline_model_svc_cd.joblib"))
svm_cn = load(os.path.join("classification", "pbmcs", "baseline_model_svc_cn.joblib"))
svm_kc = load(os.path.join("classification", "pbmcs", "baseline_model_svc_kc.joblib"))
svm_ce = load(os.path.join("classification", "pbmcs", "baseline_model_svc_ce.joblib"))
svm_sc = load(os.path.join("classification", "pbmcs", "baseline_model_svc_sc.joblib"))
svm_ac = load(os.path.join("classification", "pbmcs", "baseline_model_svc_ac.joblib"))
svm_ma = load(os.path.join("classification", "pbmcs", "baseline_model_svc_ma.joblib"))
yat_pred_svc_test = pd.DataFrame(svm_at.predict(pbmcs_fp_at), columns=["yat_pred_svc"]).set_index(pbmcs_fp_at.index)
yes_pred_svc_test = pd.DataFrame(svm_es.predict(pbmcs_fp_es), columns=["yes_pred_svc"]).set_index(pbmcs_fp_es.index)
yke_pred_svc_test = pd.DataFrame(svm_ke.predict(pbmcs_fp_ke), columns=["yke_pred_svc"]).set_index(pbmcs_fp_ke.index)
ypc_pred_svc_test = pd.DataFrame(svm_pc.predict(pbmcs_fp_pc), columns=["ypc_pred_svc"]).set_index(pbmcs_fp_pc.index)
yss_pred_svc_test = pd.DataFrame(svm_ss.predict(pbmcs_fp_ss), columns=["yss_pred_svc"]).set_index(pbmcs_fp_ss.index)
ycd_pred_svc_test = pd.DataFrame(svm_cd.predict(pbmcs_fp_cd), columns=["ycd_pred_svc"]).set_index(pbmcs_fp_cd.index)
ycn_pred_svc_test = pd.DataFrame(svm_cn.predict(pbmcs_fp_cn), columns=["ycn_pred_svc"]).set_index(pbmcs_fp_cn.index)
ykc_pred_svc_test = pd.DataFrame(svm_kc.predict(pbmcs_fp_kc), columns=["ykc_pred_svc"]).set_index(pbmcs_fp_kc.index)
yce_pred_svc_test = pd.DataFrame(svm_ce.predict(pbmcs_fp_ce), columns=["yce_pred_svc"]).set_index(pbmcs_fp_ce.index)
ysc_pred_svc_test = pd.DataFrame(svm_sc.predict(pbmcs_fp_sc), columns=["ysc_pred_svc"]).set_index(pbmcs_fp_sc.index)
yac_pred_svc_test = pd.DataFrame(svm_ac.predict(pbmcs_fp_ac), columns=["yac_pred_svc"]).set_index(pbmcs_fp_ac.index)
yma_pred_svc_test = pd.DataFrame(svm_ma.predict(pbmcs_fp_ma), columns=["yma_pred_svc"]).set_index(pbmcs_fp_ma.index)
stack_test = pd.concat([yat_pred_rf_test, yat_pred_xgb_test, yat_pred_svc_test,
yes_pred_rf_test, yes_pred_xgb_test, yes_pred_svc_test,
yke_pred_rf_test, yke_pred_xgb_test, yke_pred_svc_test,
ypc_pred_rf_test, ypc_pred_xgb_test, ypc_pred_svc_test,
yss_pred_rf_test, yss_pred_xgb_test, yss_pred_svc_test,
ycd_pred_rf_test, ycd_pred_xgb_test, ycd_pred_svc_test,
ycn_pred_rf_test, ycn_pred_xgb_test, ycn_pred_svc_test,
ykc_pred_rf_test, ykc_pred_xgb_test, ykc_pred_svc_test,
yce_pred_rf_test, yce_pred_xgb_test, yce_pred_svc_test,
ysc_pred_rf_test, ysc_pred_xgb_test, ysc_pred_svc_test,
yac_pred_rf_test, yac_pred_xgb_test, yac_pred_svc_test,
yma_pred_rf_test, yma_pred_xgb_test, yma_pred_svc_test,], axis=1)
stacked_model = load(os.path.join("classification", "pbmcs", "stacked_model.joblib"))
y_pred = pd.DataFrame(stacked_model.predict(stack_test), columns=["PBMCs_class"]).set_index(pbmcs_fp_at.index)
ad_model = load(os.path.join("classification", "pbmcs", "ad_10_4.joblib"))
y_ad = ad_measurement("PBMCs", stack_test, ad_model, 0.8258, 0.9770, z=4)
y_pred = pd.concat([y_pred, y_ad], axis=1)
return y_pred
def stacked_ames(pbmcs_fp_at, pbmcs_fp_es, pbmcs_fp_ke, pbmcs_fp_pc, pbmcs_fp_ss, pbmcs_fp_cd, pbmcs_fp_cn, pbmcs_fp_kc, pbmcs_fp_ce, pbmcs_fp_sc, pbmcs_fp_ac, pbmcs_fp_ma):
rf_at = load(os.path.join("classification", "ames", "baseline_model_rf_at.joblib"))
rf_es = load(os.path.join("classification", "ames", "baseline_model_rf_es.joblib"))
rf_ke = load(os.path.join("classification", "ames", "baseline_model_rf_ke.joblib"))
rf_pc = load(os.path.join("classification", "ames", "baseline_model_rf_pc.joblib"))
rf_ss = load(os.path.join("classification", "ames", "baseline_model_rf_ss.joblib"))
rf_cd = load(os.path.join("classification", "ames", "baseline_model_rf_cd.joblib"))
rf_cn = load(os.path.join("classification", "ames", "baseline_model_rf_cn.joblib"))
rf_kc = load(os.path.join("classification", "ames", "baseline_model_rf_kc.joblib"))
rf_ce = load(os.path.join("classification", "ames", "baseline_model_rf_ce.joblib"))
rf_sc = load(os.path.join("classification", "ames", "baseline_model_rf_sc.joblib"))
rf_ac = load(os.path.join("classification", "ames", "baseline_model_rf_ac.joblib"))
rf_ma = load(os.path.join("classification", "ames", "baseline_model_rf_ma.joblib"))
yat_pred_rf_test = pd.DataFrame(rf_at.predict(pbmcs_fp_at), columns=["yat_pred_rf"]).set_index(pbmcs_fp_at.index)
yes_pred_rf_test = pd.DataFrame(rf_es.predict(pbmcs_fp_es), columns=["yes_pred_rf"]).set_index(pbmcs_fp_es.index)
yke_pred_rf_test = pd.DataFrame(rf_ke.predict(pbmcs_fp_ke), columns=["yke_pred_rf"]).set_index(pbmcs_fp_ke.index)
ypc_pred_rf_test = pd.DataFrame(rf_pc.predict(pbmcs_fp_pc), columns=["ypc_pred_rf"]).set_index(pbmcs_fp_pc.index)
yss_pred_rf_test = pd.DataFrame(rf_ss.predict(pbmcs_fp_ss), columns=["yss_pred_rf"]).set_index(pbmcs_fp_ss.index)
ycd_pred_rf_test = pd.DataFrame(rf_cd.predict(pbmcs_fp_cd), columns=["ycd_pred_rf"]).set_index(pbmcs_fp_cd.index)
ycn_pred_rf_test = pd.DataFrame(rf_cn.predict(pbmcs_fp_cn), columns=["ycn_pred_rf"]).set_index(pbmcs_fp_cn.index)
ykc_pred_rf_test = pd.DataFrame(rf_kc.predict(pbmcs_fp_kc), columns=["ykc_pred_rf"]).set_index(pbmcs_fp_kc.index)
yce_pred_rf_test = pd.DataFrame(rf_ce.predict(pbmcs_fp_ce), columns=["yce_pred_rf"]).set_index(pbmcs_fp_ce.index)
ysc_pred_rf_test = pd.DataFrame(rf_sc.predict(pbmcs_fp_sc), columns=["ysc_pred_rf"]).set_index(pbmcs_fp_sc.index)
yac_pred_rf_test = pd.DataFrame(rf_ac.predict(pbmcs_fp_ac), columns=["yac_pred_rf"]).set_index(pbmcs_fp_ac.index)
yma_pred_rf_test = pd.DataFrame(rf_ma.predict(pbmcs_fp_ma), columns=["yma_pred_rf"]).set_index(pbmcs_fp_ma.index)
xgb_at = load(os.path.join("classification", "ames", "baseline_model_xgb_at.joblib"))
xgb_es = load(os.path.join("classification", "ames", "baseline_model_xgb_es.joblib"))
xgb_ke = load(os.path.join("classification", "ames", "baseline_model_xgb_ke.joblib"))
xgb_pc = load(os.path.join("classification", "ames", "baseline_model_xgb_pc.joblib"))
xgb_ss = load(os.path.join("classification", "ames", "baseline_model_xgb_ss.joblib"))
xgb_cd = load(os.path.join("classification", "ames", "baseline_model_xgb_cd.joblib"))
xgb_cn = load(os.path.join("classification", "ames", "baseline_model_xgb_cn.joblib"))
xgb_kc = load(os.path.join("classification", "ames", "baseline_model_xgb_kc.joblib"))
xgb_ce = load(os.path.join("classification", "ames", "baseline_model_xgb_ce.joblib"))
xgb_sc = load(os.path.join("classification", "ames", "baseline_model_xgb_sc.joblib"))
xgb_ac = load(os.path.join("classification", "ames", "baseline_model_xgb_ac.joblib"))
xgb_ma = load(os.path.join("classification", "ames", "baseline_model_xgb_ma.joblib"))
yat_pred_xgb_test = pd.DataFrame(xgb_at.predict(pbmcs_fp_at), columns=["yat_pred_xgb"]).set_index(pbmcs_fp_at.index)
yes_pred_xgb_test = pd.DataFrame(xgb_es.predict(pbmcs_fp_es), columns=["yes_pred_xgb"]).set_index(pbmcs_fp_es.index)
yke_pred_xgb_test = pd.DataFrame(xgb_ke.predict(pbmcs_fp_ke), columns=["yke_pred_xgb"]).set_index(pbmcs_fp_ke.index)
ypc_pred_xgb_test = pd.DataFrame(xgb_pc.predict(pbmcs_fp_pc), columns=["ypc_pred_xgb"]).set_index(pbmcs_fp_pc.index)
yss_pred_xgb_test = pd.DataFrame(xgb_ss.predict(pbmcs_fp_ss), columns=["yss_pred_xgb"]).set_index(pbmcs_fp_ss.index)
ycd_pred_xgb_test = pd.DataFrame(xgb_cd.predict(pbmcs_fp_cd), columns=["ycd_pred_xgb"]).set_index(pbmcs_fp_cd.index)
ycn_pred_xgb_test = pd.DataFrame(xgb_cn.predict(pbmcs_fp_cn), columns=["ycn_pred_xgb"]).set_index(pbmcs_fp_cn.index)
ykc_pred_xgb_test = pd.DataFrame(xgb_kc.predict(pbmcs_fp_kc), columns=["ykc_pred_xgb"]).set_index(pbmcs_fp_kc.index)
yce_pred_xgb_test = pd.DataFrame(xgb_ce.predict(pbmcs_fp_ce), columns=["yce_pred_xgb"]).set_index(pbmcs_fp_ce.index)
ysc_pred_xgb_test = pd.DataFrame(xgb_sc.predict(pbmcs_fp_sc), columns=["ysc_pred_xgb"]).set_index(pbmcs_fp_sc.index)
yac_pred_xgb_test = pd.DataFrame(xgb_ac.predict(pbmcs_fp_ac), columns=["yac_pred_xgb"]).set_index(pbmcs_fp_ac.index)
yma_pred_xgb_test = pd.DataFrame(xgb_ma.predict(pbmcs_fp_ma), columns=["yma_pred_xgb"]).set_index(pbmcs_fp_ma.index)
svm_at = load(os.path.join("classification", "ames", "baseline_model_svc_at.joblib"))
svm_es = load(os.path.join("classification", "ames", "baseline_model_svc_es.joblib"))
svm_ke = load(os.path.join("classification", "ames", "baseline_model_svc_ke.joblib"))
svm_pc = load(os.path.join("classification", "ames", "baseline_model_svc_pc.joblib"))
svm_ss = load(os.path.join("classification", "ames", "baseline_model_svc_ss.joblib"))
svm_cd = load(os.path.join("classification", "ames", "baseline_model_svc_cd.joblib"))
svm_cn = load(os.path.join("classification", "ames", "baseline_model_svc_cn.joblib"))
svm_kc = load(os.path.join("classification", "ames", "baseline_model_svc_kc.joblib"))
svm_ce = load(os.path.join("classification", "ames", "baseline_model_svc_ce.joblib"))
svm_sc = load(os.path.join("classification", "ames", "baseline_model_svc_sc.joblib"))
svm_ac = load(os.path.join("classification", "ames", "baseline_model_svc_ac.joblib"))
svm_ma = load(os.path.join("classification", "ames", "baseline_model_svc_ma.joblib"))
yat_pred_svc_test = pd.DataFrame(svm_at.predict(pbmcs_fp_at), columns=["yat_pred_svc"]).set_index(pbmcs_fp_at.index)
yes_pred_svc_test = pd.DataFrame(svm_es.predict(pbmcs_fp_es), columns=["yes_pred_svc"]).set_index(pbmcs_fp_es.index)
yke_pred_svc_test = pd.DataFrame(svm_ke.predict(pbmcs_fp_ke), columns=["yke_pred_svc"]).set_index(pbmcs_fp_ke.index)
ypc_pred_svc_test = pd.DataFrame(svm_pc.predict(pbmcs_fp_pc), columns=["ypc_pred_svc"]).set_index(pbmcs_fp_pc.index)
yss_pred_svc_test = pd.DataFrame(svm_ss.predict(pbmcs_fp_ss), columns=["yss_pred_svc"]).set_index(pbmcs_fp_ss.index)
ycd_pred_svc_test = pd.DataFrame(svm_cd.predict(pbmcs_fp_cd), columns=["ycd_pred_svc"]).set_index(pbmcs_fp_cd.index)
ycn_pred_svc_test = pd.DataFrame(svm_cn.predict(pbmcs_fp_cn), columns=["ycn_pred_svc"]).set_index(pbmcs_fp_cn.index)
ykc_pred_svc_test = pd.DataFrame(svm_kc.predict(pbmcs_fp_kc), columns=["ykc_pred_svc"]).set_index(pbmcs_fp_kc.index)
yce_pred_svc_test = pd.DataFrame(svm_ce.predict(pbmcs_fp_ce), columns=["yce_pred_svc"]).set_index(pbmcs_fp_ce.index)
ysc_pred_svc_test = pd.DataFrame(svm_sc.predict(pbmcs_fp_sc), columns=["ysc_pred_svc"]).set_index(pbmcs_fp_sc.index)
yac_pred_svc_test = pd.DataFrame(svm_ac.predict(pbmcs_fp_ac), columns=["yac_pred_svc"]).set_index(pbmcs_fp_ac.index)
yma_pred_svc_test = pd.DataFrame(svm_ma.predict(pbmcs_fp_ma), columns=["yma_pred_svc"]).set_index(pbmcs_fp_ma.index)
stack_test = pd.concat([yat_pred_rf_test, yat_pred_xgb_test, yat_pred_svc_test,
yes_pred_rf_test, yes_pred_xgb_test, yes_pred_svc_test,
yke_pred_rf_test, yke_pred_xgb_test, yke_pred_svc_test,
ypc_pred_rf_test, ypc_pred_xgb_test, ypc_pred_svc_test,
yss_pred_rf_test, yss_pred_xgb_test, yss_pred_svc_test,
ycd_pred_rf_test, ycd_pred_xgb_test, ycd_pred_svc_test,
ycn_pred_rf_test, ycn_pred_xgb_test, ycn_pred_svc_test,
ykc_pred_rf_test, ykc_pred_xgb_test, ykc_pred_svc_test,
yce_pred_rf_test, yce_pred_xgb_test, yce_pred_svc_test,
ysc_pred_rf_test, ysc_pred_xgb_test, ysc_pred_svc_test,
yac_pred_rf_test, yac_pred_xgb_test, yac_pred_svc_test,
yma_pred_rf_test, yma_pred_xgb_test, yma_pred_svc_test,], axis=1)
stacked_model = load(os.path.join("classification", "ames", "stacked_model.joblib"))
y_pred = pd.DataFrame(stacked_model.predict(stack_test), columns=["Ames_class"]).set_index(pbmcs_fp_at.index)
ad_model = load(os.path.join("classification", "ames", "ad_8_0.5.joblib"))
y_ad = ad_measurement("Ames", stack_test, ad_model, 0.8258, 0.9770, z=0.5)
y_pred = pd.concat([y_pred, y_ad], axis=1)
return y_pred
def main():
df_name = input("Please type name of your csv file: ")
df = load_data(df_name)
fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma = compute_fps(df)
herg_fp_at, herg_fp_es, herg_fp_ke, herg_fp_pc, herg_fp_ss, herg_fp_cd, herg_fp_cn, herg_fp_kc, herg_fp_ce, herg_fp_sc, herg_fp_ac, herg_fp_ma = herg_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma)
mtor_fp_at, mtor_fp_es, mtor_fp_ke, mtor_fp_pc, mtor_fp_ss, mtor_fp_cd, mtor_fp_cn, mtor_fp_kc, mtor_fp_ce, mtor_fp_sc, mtor_fp_ac, mtor_fp_ma = mtor_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma)
pbmcs_fp_at, pbmcs_fp_es, pbmcs_fp_ke, pbmcs_fp_pc, pbmcs_fp_ss, pbmcs_fp_cd, pbmcs_fp_cn, pbmcs_fp_kc, pbmcs_fp_ce, pbmcs_fp_sc, pbmcs_fp_ac, pbmcs_fp_ma = pbmcs_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma)
ames_fp_at, ames_fp_es, ames_fp_ke, ames_fp_pc, ames_fp_ss, ames_fp_cd, ames_fp_cn, ames_fp_kc, ames_fp_ce, ames_fp_sc, ames_fp_ac, ames_fp_ma = ames_fp_sel(fp_at, fp_es, fp_ke, fp_pc, fp_ss, fp_cd, fp_cn, fp_kc, fp_ce, fp_sc, fp_ac, fp_ma)
herg_output = stacked_herg(herg_fp_at, herg_fp_es, herg_fp_ke, herg_fp_pc, herg_fp_ss, herg_fp_cd, herg_fp_cn, herg_fp_kc, herg_fp_ce, herg_fp_sc, herg_fp_ac, herg_fp_ma)
mtor_output = stacked_mtor(mtor_fp_at, mtor_fp_es, mtor_fp_ke, mtor_fp_pc, mtor_fp_ss, mtor_fp_cd, mtor_fp_cn, mtor_fp_kc, mtor_fp_ce, mtor_fp_sc, mtor_fp_ac, mtor_fp_ma)
pbmcs_output = stacked_pbmcs(pbmcs_fp_at, pbmcs_fp_es, pbmcs_fp_ke, pbmcs_fp_pc, pbmcs_fp_ss, pbmcs_fp_cd, pbmcs_fp_cn, pbmcs_fp_kc, pbmcs_fp_ce, pbmcs_fp_sc, pbmcs_fp_ac, pbmcs_fp_ma)
ames_output = stacked_ames(ames_fp_at, ames_fp_es, ames_fp_ke, ames_fp_pc, ames_fp_ss, ames_fp_cd, ames_fp_cn, ames_fp_kc, ames_fp_ce, ames_fp_sc, ames_fp_ac, ames_fp_ma)
predictions = pd.concat([herg_output, mtor_output, pbmcs_output, ames_output], axis=1)
print(predictions)
if __name__ == "__main__":
main()