Mercurial > repos > guerler > springsuite
annotate spring_roc.py @ 31:3071750405c9 draft
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
author | guerler |
---|---|
date | Tue, 24 Nov 2020 17:12:07 +0000 |
parents | b0e195a47df7 |
children | b300ddbbf9d0 |
rev | line source |
---|---|
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
1 #! /usr/bin/env python |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
2 import argparse |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
3 import math |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
4 import random |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
5 from os.path import isfile |
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
6 from datetime import datetime |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
7 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
8 from matplotlib import pyplot as plt |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
9 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
10 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
11 def getIds(rawIds): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
12 return rawIds.split("|") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
13 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
14 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
15 def getCenterId(rawId): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
16 elements = rawId.split("|") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
17 if len(elements) > 1: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
18 return elements[1] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
19 return rawId |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
20 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
21 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
22 def getOrganism(rawId): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
23 elements = rawId.split("_") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
24 return elements[-1] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
25 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
26 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
27 def getKey(a, b): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
28 if a > b: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
29 name = "%s_%s" % (a, b) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
30 else: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
31 name = "%s_%s" % (b, a) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
32 return name |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
33 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
34 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
35 def getPercentage(rate, denominator): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
36 if denominator > 0: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
37 return 100.0 * rate / denominator |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
38 return 0.0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
39 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
40 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
41 def getFilter(filterName): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
42 print("Loading target organism(s)...") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
43 filterSets = dict() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
44 with open(filterName) as filterFile: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
45 for line in filterFile: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
46 columns = line.split() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
47 for colIndex in [0, 1]: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
48 if colIndex >= len(columns): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
49 break |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
50 colEntry = columns[colIndex] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
51 id = getCenterId(colEntry) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
52 organism = getOrganism(colEntry) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
53 if organism not in filterSets: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
54 filterSets[organism] = set() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
55 filterSets[organism].add(id) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
56 print("Organism(s) in set: %s." % filterSets.keys()) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
57 return filterSets |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
58 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
59 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
60 def getReference(fileName, filterA=None, filterB=None, minScore=None, aCol=0, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
61 bCol=1, scoreCol=-1, separator=None, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
62 skipFirstLine=False, filterValues=list()): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
63 index = dict() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
64 count = 0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
65 with open(fileName) as fp: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
66 line = fp.readline() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
67 if skipFirstLine: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
68 line = fp.readline() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
69 while line: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
70 ls = line.split(separator) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
71 if separator is not None: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
72 aList = getIds(ls[aCol]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
73 bList = getIds(ls[bCol]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
74 else: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
75 aList = [getCenterId(ls[aCol])] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
76 bList = [getCenterId(ls[bCol])] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
77 validEntry = False |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
78 for a in aList: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
79 for b in bList: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
80 skip = False |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
81 if a == "-" or b == "-": |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
82 skip = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
83 if filterA is not None: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
84 if a not in filterA and b not in filterA: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
85 skip = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
86 if filterB is not None: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
87 if a not in filterB and b not in filterB: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
88 skip = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
89 for f in filterValues: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
90 if len(ls) > f[0]: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
91 columnEntry = ls[f[0]].lower() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
92 searchEntry = f[1].lower() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
93 if columnEntry.find(searchEntry) == -1: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
94 skip = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
95 if not skip: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
96 name = getKey(a, b) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
97 if name not in index: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
98 validEntry = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
99 if scoreCol >= 0 and len(ls) > scoreCol: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
100 score = float(ls[scoreCol]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
101 skip = False |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
102 if minScore is not None: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
103 if minScore > score: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
104 return index, count |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
105 if not skip: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
106 index[name] = score |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
107 else: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
108 index[name] = 1.0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
109 if validEntry: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
110 count = count + 1 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
111 line = fp.readline() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
112 return index, count |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
113 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
114 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
115 def getXY(prediction, positive, positiveCount, negative): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
116 sortedPrediction = sorted(prediction.items(), key=lambda x: x[1], |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
117 reverse=True) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
118 positiveTotal = positiveCount |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
119 negativeTotal = len(negative) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
120 x = list([0]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
121 y = list([0]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
122 xMax = 0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
123 topCount = 0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
124 topMCC = 0.0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
125 topPrecision = 0.0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
126 topScore = 0.0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
127 tp = 0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
128 fp = 0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
129 count = 0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
130 for (name, score) in sortedPrediction: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
131 found = False |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
132 if name in positive: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
133 found = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
134 tp = tp + 1 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
135 if name in negative: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
136 found = True |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
137 fp = fp + 1 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
138 precision = 0.0 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
139 if tp > 0 or fp > 0: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
140 precision = tp / (tp + fp) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
141 fn = positiveTotal - tp |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
142 tn = negativeTotal - fp |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
143 denom = (tp+fp)*(tp+fn)*(tn+fp)*(tn+fn) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
144 if denom > 0.0: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
145 mcc = (tp*tn-fp*fn)/math.sqrt(denom) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
146 if mcc >= topMCC: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
147 topMCC = mcc |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
148 topScore = score |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
149 topCount = count |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
150 topPrecision = precision |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
151 if found: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
152 yValue = getPercentage(tp, tp + fn) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
153 xValue = getPercentage(fp, fp + tn) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
154 y.append(yValue) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
155 x.append(xValue) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
156 xMax = max(xValue, xMax) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
157 count = count + 1 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
158 print("Top ranking prediction %s." % str(sortedPrediction[0])) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
159 print("Total count of prediction set: %s (precision=%1.2f)." % |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
160 (topCount, topPrecision)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
161 print("Total count of positive set: %s." % len(positive)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
162 print("Total count of negative set: %s." % len(negative)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
163 print("Matthews-Correlation-Coefficient: %s at Score >= %s." % |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
164 (round(topMCC, 2), topScore)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
165 return x, y, xMax |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
166 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
167 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
168 def main(args): |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
169 # load source files |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
170 filterSets = getFilter(args.input) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
171 filterKeys = list(filterSets.keys()) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
172 filterA = filterSets[filterKeys[0]] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
173 if len(filterKeys) > 1: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
174 filterB = filterSets[filterKeys[1]] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
175 else: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
176 filterB = filterA |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
177 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
178 # identify biogrid filter options |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
179 filterValues = [] |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
180 if args.method: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
181 filterValues.append([11, args.method]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
182 if args.experiment: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
183 filterValues.append([12, args.experiment]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
184 if args.throughput: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
185 filterValues.append([17, args.throughput]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
186 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
187 # process biogrid database |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
188 print("Loading positive set from BioGRID file...") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
189 positive, positiveCount = getReference(args.biogrid, aCol=23, bCol=26, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
190 separator="\t", filterA=filterA, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
191 filterB=filterB, skipFirstLine=True, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
192 filterValues=filterValues) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
193 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
194 # rescan biogrid database to identify set of putative interactions |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
195 if filterValues: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
196 print("Filtered entries by (column, value): %s" % filterValues) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
197 print("Loading putative set from BioGRID file...") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
198 putative, putativeCount = getReference(args.biogrid, aCol=23, bCol=26, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
199 separator="\t", filterA=filterA, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
200 filterB=filterB, |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
201 skipFirstLine=True) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
202 print("Found %s." % putativeCount) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
203 else: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
204 putative = positive |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
205 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
206 # process prediction file |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
207 print("Loading prediction file...") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
208 prediction, _ = getReference(args.input, scoreCol=2) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
209 |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
210 # get subcellular locations from UniProt export |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
211 locations = dict() |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
212 if isfile(args.locations): |
31
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
213 regions = list() |
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
214 if args.regions: |
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
215 regions = args.regions.split(",") |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
216 with open(args.locations) as locFile: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
217 for line in locFile: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
218 searchKey = "SUBCELLULAR LOCATION" |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
219 searchPos = line.find(searchKey) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
220 if searchPos != -1: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
221 uniId = line.split()[0] |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
222 locStart = searchPos + len(searchKey) + 1 |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
223 locId = line[locStart:].split()[0] |
31
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
224 if regions: |
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
225 if locId not in regions: |
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
226 continue |
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
227 if uniId in filterA or uniId in filterB: |
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
228 locations[uniId] = locId |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
229 print("Found %d subcellular locations." % (len(list(locations.keys())))) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
230 |
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
231 # estimate background noise |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
232 print("Estimating background noise...") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
233 negative = set() |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
234 filterAList = sorted(list(filterA)) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
235 filterBList = sorted(list(filterB)) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
236 negativeRequired = positiveCount |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
237 random.seed(0) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
238 totalAttempts = int(len(filterAList) * len(filterBList) / 2) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
239 while totalAttempts > 0: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
240 totalAttempts = totalAttempts - 1 |
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
241 nameA = random.choice(filterAList) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
242 nameB = random.choice(filterBList) |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
243 if locations: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
244 if nameA not in locations or nameB not in locations: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
245 continue |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
246 if locations[nameA] == locations[nameB]: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
247 continue |
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
248 key = getKey(nameA, nameB) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
249 if key not in putative and key not in negative: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
250 negative.add(key) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
251 negativeRequired = negativeRequired - 1 |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
252 if negativeRequired == 0: |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
253 break |
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
254 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
255 # create plot |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
256 print("Producing plot data...") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
257 print("Total count in prediction file: %d." % len(prediction)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
258 print("Total count in positive file: %d." % len(positive)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
259 plt.ylabel('True Positive Rate (%)') |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
260 plt.xlabel('False Positive Rate (%)') |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
261 title = " vs. ".join(filterSets) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
262 plt.suptitle(title) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
263 if filterValues: |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
264 filterAttributes = list(map(lambda x: x[1], filterValues)) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
265 plt.title("BioGRID filters: %s" % filterAttributes, fontsize=10) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
266 x, y, xMax = getXY(prediction, positive, positiveCount, negative) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
267 plt.plot(x, y) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
268 plt.plot([0, xMax], [0, xMax]) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
269 plt.savefig(args.output, format="png") |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
270 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
271 |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
272 if __name__ == "__main__": |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
273 parser = argparse.ArgumentParser(description='Create ROC plot.') |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
274 parser.add_argument('-i', '--input', help='Input prediction file.', required=True) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
275 parser.add_argument('-b', '--biogrid', help='BioGRID interaction database file', required=True) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
276 parser.add_argument('-l', '--locations', help='UniProt export table with subcellular locations', required=False) |
31
3071750405c9
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7-dirty"
guerler
parents:
30
diff
changeset
|
277 parser.add_argument('-r', '--regions', help='Comma-separated regions', required=False) |
30
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
278 parser.add_argument('-e', '--experiment', help='Type (physical/genetic)', default="", required=False) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
279 parser.add_argument('-t', '--throughput', help='Throughput (low/high)', default="", required=False) |
b0e195a47df7
"planemo upload commit b306c715d8284c097220bc5c8461399fdc05eac7"
guerler
parents:
29
diff
changeset
|
280 parser.add_argument('-m', '--method', help='Method e.g. Two-hybrid', default="", required=False) |
29
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
281 parser.add_argument('-o', '--output', help='Output (png)', required=True) |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
282 args = parser.parse_args() |
41353488926c
"planemo upload commit 1c0a60f98e36bccb6d6c85ff82a8d737a811b4d5"
guerler
parents:
diff
changeset
|
283 main(args) |