-
Notifications
You must be signed in to change notification settings - Fork 0
/
concordance.py
60 lines (40 loc) · 1.36 KB
/
concordance.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
from tools import Master_results
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data = Master_results()
def concordance_matrix(threshold):
M_Y_F_Y = 0
M_Y_F_N = 0
M_N_F_Y = 0
M_N_F_N = 0
for i in range(data.shape[0]):
if data.loc[i, "FoldX_ddG"] >= threshold:
if data.loc[i, "BoolPrediction"] == 1:
M_Y_F_Y = M_Y_F_Y + 1
elif data.loc[i, "BoolPrediction"] == 0:
M_N_F_Y = M_N_F_Y + 1
elif data.loc[i, "FoldX_ddG"] < threshold:
if data.loc[i, "BoolPrediction"] == 1:
M_Y_F_N = M_Y_F_N + 1
elif data.loc[i, "BoolPrediction"] == 0:
M_N_F_N = M_N_F_N + 1
return [M_Y_F_Y, M_Y_F_N, M_N_F_Y, M_N_F_N]
thresholds = [1.0, 1.5, 2.0]
for threshold in thresholds:
print(threshold, concordance_matrix(threshold))
print(concordance_matrix(1.5))
thresholds = np.arange(0, 5.1, 0.1)
values = []
for threshold in thresholds:
values.append(np.array(concordance_matrix(threshold)))
print(threshold)
total = np.sum(values[0])
values = np.stack(values)*100/total
for i in range(4):
plt.plot(values[:,i])
plt.legend(["Missense_Y_FoldX_Y", "Missense_Y_FoldX_N", "Missense_N_FoldX_Y", "Missense_N_FoldX_N"])
plt.xticks(range(0,51,10), [0,1,2,3,4,5])
plt.ylabel("%")
plt.xlabel("ddG Threshold")
plt.show()