-
Notifications
You must be signed in to change notification settings - Fork 0
/
PieChartAndVennDia.py
283 lines (256 loc) · 15.5 KB
/
PieChartAndVennDia.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
import matplotlib.pyplot as plt
from matplotlib_venn import venn2_unweighted
from Tkinter import *
import tkMessageBox
class PieCharts():
''' Pie charts for the detected outlier genes are generated'''
### Pie chart for Median rule, Generalized ESD, Adjusted box plt and Modified Z-Score###\
def pie_chart_medianRule_gesd_abplot_mzs(self,x,y,z,t,q,k):
labels = 'GESD ','Median R.','Common Outliers','Adjusted BoxPlot ','Non-Outliers','M. Z-Score'
sizes=[len(x),len(y)-len(z),len(z),len(t)-len(z),len(q)+len(z)-len(x)-len(t)-len(y)-len(k),len(k)]
#sizes=[len(self.gesd_outlier_list),len(self.medianRule_outlier_list)-len(self.common),len(self.common),len(self.abplot_outlier_list)-len(self.common),len(self.cancersets)+len(self.common)-len(self.medianRule_outlier_list)-len(self.abplot_outlier_list)-len(self.gesd_outlier_list)]
colors = ['gold', 'red','yellowgreen','lightcoral','lightskyblue','blue']
explode = (0, 0.1,0,0,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=270)
plt.axis('equal')
plt.title('Gene Level Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_mzs_gesd_abplot_mzs.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
### Pie chart for Median rule, Generalized ESD and Adjusted box plt ###
def pie_chart_medianRule_gesd_abplot(self,x,y,z,t,q):
labels = 'GESD ','Median R.','Common Outliers','Adjusted B.P. ','Non-Outliers'
sizes=[len(x),len(y)-len(z),len(z),len(t)-len(z),len(q)+len(z)-len(x)-len(t)-len(y)]
#sizes=[len(self.gesd_outlier_list),len(self.medianRule_outlier_list)-len(self.common),len(self.common),len(self.abplot_outlier_list)-len(self.common),len(self.cancersets)+len(self.common)-len(self.medianRule_outlier_list)-len(self.abplot_outlier_list)-len(self.gesd_outlier_list)]
colors = ['gold', 'red','yellowgreen','lightcoral','lightskyblue']
explode = (0, 0.1,0,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Level Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_mzs_gesd_abplot.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Median Rule, Modified Z-Score and Adjusted box plt ###
def pie_chart_medianRule_mzs_abplot(self,x,y,z,t,q):
labels = 'M. Z-Score','Median R.','Common Outlier','Adjusted B.P. ','Non-Outliers'
sizes=[len(x),len(y)-len(z),len(y),len(t)-len(z),len(q)+len(z)-len(y)-len(t)-len(x)]
#sizes=[len(self.mzs_outlier_list),len(self.medianRule_outlier_list)-len(self.common),len(self.common),len(self.abplot_outlier_list)-len(self.common),len(self.cancersets)+len(self.common)-len(self.medianRule_outlier_list)-len(self.abplot_outlier_list)-len(self.mzs_outlier_list)]
colors = ['gold', 'red','yellowgreen','lightcoral','lightskyblue']
explode = (0, 0.1,0,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_mzs_gesd_abplot.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Median Rule, Modified Z-Score and Generalized ESD ###
def pie_chart_medianRule_mzs_gesd(self,x,y,z,t,q):
labels = 'M. Z-Score','Median R.','Common Outlier','GESD ','Non-Outliers'
sizes=[len(x)-len(z),len(y),len(z),len(t)-len(z),len(q)+len(z)-len(y)-len(x)-len(t)]
#sizes=[len(self.mzs_outlier_list)-len(self.common),len(self.medianRule_outlier_list),len(self.common),len(self.gesd_outlier_list)-len(self.common),len(self.cancersets)+len(self.common)-len(self.medianRule_outlier_list)-len(self.mzs_outlier_list)-len(self.gesd_outlier_list)]
colors = ['gold', 'red','yellowgreen','lightcoral','lightskyblue']
explode = (0, 0.1,0,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=0)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_mzs_gesd_abplot.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Median Rule and Generalized ESD ####
def pie_chart_medianRule_gesd(self,x,y,z):
labels = 'Median R.','GESD ','Non-Outliers'
sizes=[len(x),len(y),len(z)-len(x)-len(y)]
#sizes=[len(self.medianRule_outlier_list),len(self.gesd_outlier_list),len(self.cancersets)-len(self.medianRule_outlier_list)-len(self.gesd_outlier_list)]
colors = ['gold', 'lightskyblue','yellowgreen']
explode = (0, 0.1,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_abplot_gesd.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Median Rule and Modified Z-Score ####
def pie_chart_medianRule_mzs(self,x,y,z):
labels = 'M. Z-Score','Median R.','Non-Outliers'
sizes=[len(x),len(y),len(z)-len(x)-len(y)]
#sizes=[len(self.mzs_outlier_list),len(self.medianRule_outlier_list),len(self.cancersets)-len(self.medianRule_outlier_list)-len(self.mzs_outlier_list)]
colors = ['gold', 'lightskyblue','lightcoral']
explode = (0, 0.1,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_medianRule_mzs.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Median Rule ####
def pie_chart_medianRule(self,x,y):
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
labels = 'Median R.','Non-Outliers'
sizes=[len(x),len(y)-len(x)]
#sizes=[len(self.medianRule_outlier_list),len(self.cancersets)-len(self.medianRule_outlier_list)]
colors = ['gold', 'lightskyblue']
explode = (0, 0.1)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.03)
plt.savefig('pie_chart_medianrule.pdf')
plt.close()
return
### Pie chart for Modified Z-Score ####
def pie_chart_mzs(self,x,y):
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
labels = 'M. Z-Score','Non-Outliers'
sizes=[len(x),len(y)-len(x)]
#sizes=[len(self.mzs_outlier_list),len(self.cancersets)-len(self.mzs_outlier_list)]
colors = ['gold', 'lightskyblue']
explode = (0, 0.1)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.03)
plt.savefig('pie_chart_mzs.pdf')
plt.close()
return
### Pie chart for Generalized ESD ####
def pie_chart_gesd(self,x,y):
labels = 'GESD','Non-Outliers'
sizes=[len(x),len(y)-len(x)]
#sizes=[len(self.gesd_outlier_list),len(self.cancersets)-len(self.gesd_outlier_list)]
colors = ['gold', 'lightskyblue']
explode = (0, 0.1)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.03)
plt.savefig('pie_chart_gesd.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Adjusted Box plot ####
def pie_chart_abplot(self,x,y):
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
labels = 'Adjusted B.P.','Non-Outliers'
sizes=[len(x),len(y)-len(x)]
#sizes=[len(self.abplot_outlier_list),len(self.cancersets)-len(self.abplot_outlier_list)]
colors = ['gold', 'lightskyblue']
explode = (0, 0.1)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=120)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.03)
plt.savefig('pie_chart_abplot.pdf')
plt.close()
return
### Pie chart for Adjusted Box plot and Mofidied Z-Score ####
def pie_chart_abplot_mzs(self,x,y,z):
labels = 'M. Z-Score','Adjusted B.P.','Non-Outliers'
sizes=[len(x),len(y),len(z)-len(y)-len(x)]
#sizes=[len(self.mzs_outlier_list),len(self.abplot_outlier_list),len(self.cancersets)-len(self.abplot_outlier_list)-len(self.mzs_outlier_list)]
colors = ['gold', 'lightskyblue','lightcoral']
explode = (0, 0.1,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_abplot_mzs.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Adjusted Box plot and Generalized Z-Score ####
def pie_chart_abplot_gesd(self,x,y,z):
labels = 'Adjusted B.P.','GESD ','Non-Outliers'
sizes=[len(x),len(y),len(z)-len(x)-len(y)]
#sizes=[len(self.abplot_outlier_list),len(self.gesd_outlier_list),len(self.cancersets)-len(self.abplot_outlier_list)-len(self.gesd_outlier_list)]
colors = ['gold', 'lightskyblue','yellowgreen']
explode = (0, 0.1,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_abplot_gesd.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Modified Z-score plot and Generalized Z-Score ####
def pie_chart_mzs_gesd(self,x,y,z,t):
labels = 'M. Z-Score','GESD ','Common Outlier','Non-Outliers'
sizes=[len(x)-len(z),len(y)-len(z),len(z),len(t) + len(z)-len(x)-len(y)]
#sizes=[len(self.mzs_outlier_list),len(self.gesd_outlier_list),len(self.cancersets)-len(self.mzs_outlier_list)-len(self.gesd_outlier_list)]
colors = ['gold', 'lightskyblue','yellowgreen','red']
explode = (0, 0.1,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_mzs_gesd.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Adjusted Box plot, Modified Z-Score and Generalized ESD ####
def pie_chart_abplot_mzs_gesd(self,x,y,z,t,q):
labels = 'M. Z-Score','Adjusted B.P.','Common Outlier','GESD','Non-Outliers'
sizes=[len(x)-len(z),len(y),len(z),len(t)-len(z),len(q)+len(z)-len(y)-len(x)]
#sizes=[len(self.mzs_outlier_list)-len(self.common),len(self.abplot_outlier_list),len(self.common),len(self.gesd_outlier_list)-len(self.common),len(self.cancersets)+len(self.common)-len(self.abplot_outlier_list)-len(self.mzs_outlier_list)]
colors = ['gold', 'red','yellowgreen','lightcoral','lightskyblue']
explode = (0, 0.1,0,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=180)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_mzs_gesd_abplot.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
### Pie chart for Adjusted Box plot and Median Rule ####
def pie_chart_abplot_medianrule(self,x,y,z,t):
labels = 'Median R.','Adjusted B.P.','Common Outlier','Non-Outliers'
sizes=[len(x)-len(z),len(y)-len(z),len(z),len(t)+len(z)-len(y)-len(x)]
#sizes=[len(self.medianRule_outlier_list)-len(self.common),len(self.abplot_outlier_list),len(self.common),len(self.cancersets)+len(self.common)-len(self.abplot_outlier_list)-len(self.medianRule_outlier_list)]
colors = [ 'red','yellowgreen','gold','lightskyblue']
explode = (0, 0.1,0,0)
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('equal')
plt.title('Gene Based Outlier Detection Pie Chart ', bbox={'facecolor':'white'},y=1.05)
plt.savefig('pie_chart_median ruleabplot.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
class VennDiagrams():
'''Pie charts for the detected outlier genes are generated'''
#### Venn Diagram for Modified Z-Score and Modified Z-Score ###
def venn_diagram_gesd_mzs(self,algo1,algo2,commons):
commonOutlier=len(commons)
first=len(algo1)-commonOutlier
second=len(lgo2)-commonOutlier
venn2_unweighted(subsets=(first,second,commonOutlier),set_labels=('modified Z-score','Generalized ESD',''))
plt.title('Venn Diagram of Dataset')
plt.savefig('Venn_Diagram_abplot_mzs.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
#### Venn Diagram for Adjusted box plot and Median Rule ###
def venn_diagram_abplt_medianrule(self,algo1,algo2,commons):
commonOutlier=len(commons)
first=len(algo1)-commonOutlier
second=len(algo2)-commonOutlier
venn2_unweighted(subsets=(first,second,commonOutlier),set_labels=('Median Rule','Adjusted Box-Plot',''))
plt.title('Venn Diagram of Dataset')
plt.savefig('Venn_Diagram_abplot_mzs.pdf')
plt.close()
tkMessageBox.showinfo(title='Attention',message='Image was saved into selected diretory')
return
venndiagram= VennDiagrams()
piechart= PieCharts()