- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroc_plot.py
More file actions
Latest commit
executable file
·64 lines (53 loc) · 1.54 KB
/
Copy pathroc_plot.py
File metadata and controls
executable file
·64 lines (53 loc) · 1.54 KB
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
#!/usr/bin/env python
frompylabimport*
frommatplotlibimportrcParams
frompprintimportpprint
importsys
fromitertoolsimportpermutations
defmain():
filename=sys.argv[1]
input=open(filename, 'r')
result= []
wt_score=0.0
forlineininput:
ifline[0] =='#': continue
data=line.split()
#if len(data) == 2:
if'WT'inline:
wt_score=eval(data[1])
eliflen(data) >2:
diff=eval(data[1]) -wt_score
label=data[2]
result.append((diff, label))
result.sort(key=lambdatup : tup[0], reverse=True)
pprint(result)
T, F=0, 0
x, y= [0.0], [0.0]
for (diff, label) inresult:
iflabel=='T': T+=1
else: F+=1
x.append(F)
y.append(T)
x= [a/ (F+0.0) forainx]
y= [b/ (T+0.0) forbiny]
old_x=0.0
area=0.0
foriinrange(len(x)):
width=x[i] -old_x
area+=width*y[i]
old_x=x[i]
print"Area under curve is: %.3f"%area
# Plotting
# set up the font
rcParams['font.family'] ='sans-serif'
rcParams['font.sans-serif'] ='Lucida Grande'
rcParams['axes.labelsize'] =14
plot(x, y, marker='o', markersize=4.0, linestyle='solid', c='#000000', linewidth=2.0)
t=np.arange(0.0, 1.2, 0.2)
plot(t, t, c='#990000', linestyle='dashed', linewidth=2.0)
xlabel("False Positive Rate")
ylabel("True Positive Rate")
ylim([0, 1.01])
xlim([-0.01, 1.01])
show()
main()