desinez commited on
Commit
66dd119
·
1 Parent(s): 72a7da3

major updates in GUI

Browse files
4.2.0 ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Requirement already satisfied: nbformat in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (5.10.4)
2
+ Requirement already satisfied: fastjsonschema>=2.15 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from nbformat) (2.21.2)
3
+ Requirement already satisfied: jsonschema>=2.6 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from nbformat) (4.26.0)
4
+ Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from nbformat) (5.9.1)
5
+ Requirement already satisfied: traitlets>=5.1 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from nbformat) (5.14.3)
6
+ Requirement already satisfied: attrs>=22.2.0 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from jsonschema>=2.6->nbformat) (26.1.0)
7
+ Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from jsonschema>=2.6->nbformat) (2025.9.1)
8
+ Requirement already satisfied: referencing>=0.28.4 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from jsonschema>=2.6->nbformat) (0.37.0)
9
+ Requirement already satisfied: rpds-py>=0.25.0 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from jsonschema>=2.6->nbformat) (0.30.0)
10
+ Requirement already satisfied: platformdirs>=2.5 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from jupyter-core!=5.0.*,>=4.12->nbformat) (4.9.4)
11
+ Requirement already satisfied: typing-extensions>=4.4.0 in c:\users\sinel\anaconda3\envs\pvrecnet\lib\site-packages (from referencing>=0.28.4->jsonschema>=2.6->nbformat) (4.15.0)
backend/PvDeepSetNet/datasets/GUI_sample_dataset.csv ADDED
@@ -0,0 +1,556 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ patient_id,episode,marker,allele,country
2
+ P01,2.0,Chr02,Chr02-1,C1
3
+ P01,1.0,Chr13,Chr13-3,C1
4
+ P01,1.0,Chr14,Chr14-4,C1
5
+ P01,1.0,Chr14,Chr14-2,C1
6
+ P01,1.0,Chr01,Chr01-1,C1
7
+ P01,1.0,Chr09,Chr09-3,C1
8
+ P01,1.0,Chr07,Chr07-4,C1
9
+ P01,1.0,Chr05,Chr05-6,C1
10
+ P01,2.0,Chr01,Chr01-1,C1
11
+ P01,1.0,Chr03,Chr03-3,C1
12
+ P01,1.0,Chr02,Chr02-2,C1
13
+ P01,1.0,Chr08,Chr08-3,C1
14
+ P01,1.0,Chr02,Chr02-3,C1
15
+ P01,2.0,Chr09,Chr09-1,C1
16
+ P01,2.0,Chr10,Chr10-1,C1
17
+ P01,2.0,Chr11,Chr11-3,C1
18
+ P01,2.0,Chr13,Chr13-2,C1
19
+ P01,2.0,Chr08,Chr08-1,C1
20
+ P01,2.0,Chr14,Chr14-2,C1
21
+ P01,2.0,Chr07,Chr07-1,C1
22
+ P01,2.0,Chr03,Chr03-1,C1
23
+ P01,2.0,Chr02,Chr02-2,C1
24
+ P01,1.0,Chr11,Chr11-3,C1
25
+ P02,1.0,Chr01,Chr01-2,C2
26
+ P02,1.0,Chr01,Chr01-3,C2
27
+ P02,1.0,Chr07,Chr07-1,C2
28
+ P02,1.0,Chr02,Chr02-5,C2
29
+ P02,1.0,Chr02,Chr02-6,C2
30
+ P02,1.0,Chr03,Chr03-1,C2
31
+ P02,1.0,Chr03,Chr03-2,C2
32
+ P02,1.0,Chr05,Chr05-8,C2
33
+ P02,1.0,Chr08,Chr08-1,C2
34
+ P02,1.0,Chr09,Chr09-1,C2
35
+ P02,2.0,Chr05,Chr05-9,C2
36
+ P02,2.0,Chr08,Chr08-1,C2
37
+ P02,2.0,Chr13,Chr13-3,C2
38
+ P02,2.0,Chr13,Chr13-1,C2
39
+ P02,2.0,Chr14,Chr14-3,C2
40
+ P02,2.0,Chr11,Chr11-1,C2
41
+ P02,2.0,Chr10,Chr10-1,C2
42
+ P02,2.0,Chr09,Chr09-1,C2
43
+ P02,2.0,Chr02,Chr02-5,C2
44
+ P02,1.0,Chr10,Chr10-1,C2
45
+ P02,1.0,Chr11,Chr11-1,C2
46
+ P02,1.0,Chr13,Chr13-3,C2
47
+ P02,1.0,Chr13,Chr13-5,C2
48
+ P02,1.0,Chr14,Chr14-2,C2
49
+ P02,1.0,Chr14,Chr14-3,C2
50
+ P02,2.0,Chr01,Chr01-2,C2
51
+ P02,2.0,Chr02,Chr02-2,C2
52
+ P02,1.0,Chr09,Chr09-4,C2
53
+ P02,2.0,Chr03,Chr03-1,C2
54
+ P02,2.0,Chr03,Chr03-4,C2
55
+ P02,1.0,Chr05,Chr05-1,C2
56
+ P02,2.0,Chr07,Chr07-5,C2
57
+ P02,2.0,Chr07,Chr07-1,C2
58
+ P02,2.0,Chr09,Chr09-3,C2
59
+ P02,1.0,Chr07,Chr07-5,C2
60
+ P02,2.0,Chr11,Chr11-2,C2
61
+ P03,2.0,Chr09,Chr09-1,C1
62
+ P03,2.0,Chr13,Chr13-3,C1
63
+ P03,3.0,Chr05,Chr05-2,C1
64
+ P03,1.0,Chr02,Chr02-1,C1
65
+ P03,1.0,Chr03,Chr03-1,C1
66
+ P03,1.0,Chr05,Chr05-1,C1
67
+ P03,1.0,Chr07,Chr07-1,C1
68
+ P03,1.0,Chr08,Chr08-2,C1
69
+ P03,1.0,Chr08,Chr08-3,C1
70
+ P03,1.0,Chr11,Chr11-2,C1
71
+ P03,1.0,Chr13,Chr13-1,C1
72
+ P03,1.0,Chr14,Chr14-2,C1
73
+ P03,1.0,Chr01,Chr01-3,C1
74
+ P03,1.0,Chr09,Chr09-2,C1
75
+ P03,3.0,Chr02,Chr02-2,C1
76
+ P03,2.0,Chr08,Chr08-3,C1
77
+ P03,2.0,Chr07,Chr07-4,C1
78
+ P03,2.0,Chr11,Chr11-1,C1
79
+ P03,2.0,Chr11,Chr11-3,C1
80
+ P03,1.0,Chr14,Chr14-1,C1
81
+ P03,3.0,Chr09,Chr09-1,C1
82
+ P03,3.0,Chr14,Chr14-2,C1
83
+ P03,3.0,Chr13,Chr13-2,C1
84
+ P03,3.0,Chr11,Chr11-1,C1
85
+ P03,3.0,Chr10,Chr10-1,C1
86
+ P03,3.0,Chr07,Chr07-1,C1
87
+ P03,2.0,Chr14,Chr14-2,C1
88
+ P03,1.0,Chr01,Chr01-2,C1
89
+ P03,3.0,Chr03,Chr03-1,C1
90
+ P03,2.0,Chr03,Chr03-3,C1
91
+ P03,2.0,Chr03,Chr03-1,C1
92
+ P03,2.0,Chr07,Chr07-2,C1
93
+ P03,2.0,Chr07,Chr07-1,C1
94
+ P03,2.0,Chr02,Chr02-3,C1
95
+ P04,1.0,Chr01,Chr01-1,C1
96
+ P04,2.0,Chr02,Chr02-1,C1
97
+ P04,2.0,Chr07,Chr07-2,C1
98
+ P04,2.0,Chr08,Chr08-2,C1
99
+ P04,2.0,Chr13,Chr13-4,C1
100
+ P04,1.0,Chr13,Chr13-4,C1
101
+ P04,2.0,Chr14,Chr14-2,C1
102
+ P04,2.0,Chr09,Chr09-3,C1
103
+ P04,1.0,Chr02,Chr02-1,C1
104
+ P04,1.0,Chr03,Chr03-1,C1
105
+ P04,2.0,Chr11,Chr11-4,C1
106
+ P04,1.0,Chr07,Chr07-2,C1
107
+ P04,1.0,Chr11,Chr11-4,C1
108
+ P04,1.0,Chr09,Chr09-3,C1
109
+ P04,2.0,Chr01,Chr01-1,C1
110
+ P05,2.0,Chr09,Chr09-2,C2
111
+ P05,1.0,Chr08,Chr08-1,C2
112
+ P05,1.0,Chr09,Chr09-3,C2
113
+ P05,1.0,Chr09,Chr09-1,C2
114
+ P05,1.0,Chr10,Chr10-3,C2
115
+ P05,1.0,Chr11,Chr11-1,C2
116
+ P05,1.0,Chr14,Chr14-1,C2
117
+ P05,1.0,Chr03,Chr03-2,C2
118
+ P05,1.0,Chr03,Chr03-6,C2
119
+ P05,1.0,Chr02,Chr02-4,C2
120
+ P05,2.0,Chr07,Chr07-3,C2
121
+ P05,2.0,Chr10,Chr10-1,C2
122
+ P05,2.0,Chr07,Chr07-1,C2
123
+ P05,2.0,Chr09,Chr09-3,C2
124
+ P05,1.0,Chr07,Chr07-1,C2
125
+ P05,2.0,Chr09,Chr09-5,C2
126
+ P05,2.0,Chr09,Chr09-1,C2
127
+ P05,2.0,Chr11,Chr11-3,C2
128
+ P05,1.0,Chr01,Chr01-2,C2
129
+ P05,2.0,Chr11,Chr11-1,C2
130
+ P05,2.0,Chr13,Chr13-3,C2
131
+ P05,2.0,Chr13,Chr13-1,C2
132
+ P05,2.0,Chr13,Chr13-2,C2
133
+ P05,2.0,Chr14,Chr14-1,C2
134
+ P05,2.0,Chr14,Chr14-2,C2
135
+ P05,2.0,Chr14,Chr14-3,C2
136
+ P05,2.0,Chr08,Chr08-2,C2
137
+ P05,1.0,Chr05,Chr05-5,C2
138
+ P05,2.0,Chr08,Chr08-1,C2
139
+ P05,2.0,Chr07,Chr07-4,C2
140
+ P05,1.0,Chr13,Chr13-3,C2
141
+ P05,2.0,Chr01,Chr01-1,C2
142
+ P05,2.0,Chr02,Chr02-3,C2
143
+ P05,2.0,Chr02,Chr02-4,C2
144
+ P05,2.0,Chr03,Chr03-1,C2
145
+ P05,2.0,Chr01,Chr01-2,C2
146
+ P05,2.0,Chr03,Chr03-6,C2
147
+ P05,2.0,Chr05,Chr05-5,C2
148
+ P05,2.0,Chr05,Chr05-8,C2
149
+ P05,2.0,Chr05,Chr05-4,C2
150
+ P05,2.0,Chr03,Chr03-2,C2
151
+ P06,1.0,Chr03,Chr03-1,C2
152
+ P06,4.0,Chr02,Chr02-3,C2
153
+ P06,3.0,Chr05,Chr05-4,C2
154
+ P06,2.0,Chr11,Chr11-2,C2
155
+ P06,2.0,Chr13,Chr13-2,C2
156
+ P06,1.0,Chr02,Chr02-3,C2
157
+ P06,2.0,Chr02,Chr02-3,C2
158
+ P06,1.0,Chr07,Chr07-1,C2
159
+ P06,1.0,Chr11,Chr11-2,C2
160
+ P06,3.0,Chr02,Chr02-3,C2
161
+ P06,3.0,Chr01,Chr01-2,C2
162
+ P06,2.0,Chr01,Chr01-2,C2
163
+ P06,2.0,Chr03,Chr03-2,C2
164
+ P06,1.0,Chr10,Chr10-1,C2
165
+ P06,1.0,Chr09,Chr09-5,C2
166
+ P06,1.0,Chr09,Chr09-3,C2
167
+ P06,1.0,Chr08,Chr08-1,C2
168
+ P06,3.0,Chr03,Chr03-2,C2
169
+ P06,3.0,Chr07,Chr07-2,C2
170
+ P06,3.0,Chr10,Chr10-2,C2
171
+ P06,3.0,Chr09,Chr09-1,C2
172
+ P06,4.0,Chr08,Chr08-1,C2
173
+ P06,4.0,Chr07,Chr07-2,C2
174
+ P06,4.0,Chr05,Chr05-4,C2
175
+ P06,3.0,Chr14,Chr14-2,C2
176
+ P06,3.0,Chr08,Chr08-1,C2
177
+ P06,4.0,Chr11,Chr11-2,C2
178
+ P06,4.0,Chr13,Chr13-2,C2
179
+ P06,4.0,Chr09,Chr09-1,C2
180
+ P06,4.0,Chr14,Chr14-2,C2
181
+ P06,3.0,Chr13,Chr13-2,C2
182
+ P06,3.0,Chr11,Chr11-2,C2
183
+ P06,2.0,Chr14,Chr14-2,C2
184
+ P06,2.0,Chr05,Chr05-4,C2
185
+ P06,2.0,Chr07,Chr07-2,C2
186
+ P06,2.0,Chr08,Chr08-1,C2
187
+ P06,2.0,Chr09,Chr09-1,C2
188
+ P06,2.0,Chr10,Chr10-2,C2
189
+ P06,4.0,Chr10,Chr10-2,C2
190
+ P07,2.0,Chr07,Chr07-1,C1
191
+ P07,2.0,Chr08,Chr08-2,C1
192
+ P07,2.0,Chr13,Chr13-1,C1
193
+ P07,2.0,Chr14,Chr14-1,C1
194
+ P07,2.0,Chr01,Chr01-2,C1
195
+ P07,2.0,Chr09,Chr09-2,C1
196
+ P07,1.0,Chr14,Chr14-1,C1
197
+ P07,2.0,Chr11,Chr11-1,C1
198
+ P07,2.0,Chr05,Chr05-1,C1
199
+ P07,1.0,Chr10,Chr10-1,C1
200
+ P07,2.0,Chr02,Chr02-1,C1
201
+ P07,1.0,Chr01,Chr01-2,C1
202
+ P07,1.0,Chr13,Chr13-1,C1
203
+ P07,1.0,Chr11,Chr11-2,C1
204
+ P07,1.0,Chr02,Chr02-1,C1
205
+ P07,1.0,Chr03,Chr03-1,C1
206
+ P07,1.0,Chr05,Chr05-1,C1
207
+ P07,1.0,Chr07,Chr07-2,C1
208
+ P07,1.0,Chr08,Chr08-2,C1
209
+ P07,2.0,Chr03,Chr03-1,C1
210
+ P08,1.0,Chr11,Chr11-3,C1
211
+ P08,1.0,Chr07,Chr07-1,C1
212
+ P08,1.0,Chr01,Chr01-1,C1
213
+ P08,1.0,Chr09,Chr09-1,C1
214
+ P08,1.0,Chr08,Chr08-1,C1
215
+ P08,1.0,Chr02,Chr02-2,C1
216
+ P08,2.0,Chr02,Chr02-3,C1
217
+ P08,2.0,Chr09,Chr09-1,C1
218
+ P08,2.0,Chr14,Chr14-2,C1
219
+ P08,2.0,Chr13,Chr13-2,C1
220
+ P08,2.0,Chr11,Chr11-4,C1
221
+ P08,2.0,Chr10,Chr10-3,C1
222
+ P08,2.0,Chr07,Chr07-3,C1
223
+ P08,2.0,Chr05,Chr05-1,C1
224
+ P08,2.0,Chr03,Chr03-1,C1
225
+ P08,1.0,Chr13,Chr13-2,C1
226
+ P08,1.0,Chr03,Chr03-1,C1
227
+ P08,1.0,Chr10,Chr10-1,C1
228
+ P08,1.0,Chr14,Chr14-2,C1
229
+ P09,1.0,Chr11,Chr11-3,C2
230
+ P09,2.0,Chr08,Chr08-1,C2
231
+ P09,2.0,Chr07,Chr07-1,C2
232
+ P09,2.0,Chr05,Chr05-3,C2
233
+ P09,2.0,Chr03,Chr03-4,C2
234
+ P09,2.0,Chr02,Chr02-5,C2
235
+ P09,2.0,Chr11,Chr11-3,C2
236
+ P09,2.0,Chr01,Chr01-2,C2
237
+ P09,1.0,Chr13,Chr13-3,C2
238
+ P09,1.0,Chr10,Chr10-1,C2
239
+ P09,1.0,Chr09,Chr09-1,C2
240
+ P09,1.0,Chr08,Chr08-1,C2
241
+ P09,1.0,Chr07,Chr07-1,C2
242
+ P09,2.0,Chr10,Chr10-1,C2
243
+ P09,1.0,Chr14,Chr14-3,C2
244
+ P09,1.0,Chr03,Chr03-4,C2
245
+ P09,2.0,Chr13,Chr13-3,C2
246
+ P09,2.0,Chr14,Chr14-3,C2
247
+ P09,1.0,Chr02,Chr02-5,C2
248
+ P09,1.0,Chr01,Chr01-2,C2
249
+ P09,2.0,Chr09,Chr09-1,C2
250
+ P09,1.0,Chr05,Chr05-3,C2
251
+ P10,2.0,Chr02,Chr02-3,C1
252
+ P10,2.0,Chr14,Chr14-2,C1
253
+ P10,2.0,Chr13,Chr13-3,C1
254
+ P10,2.0,Chr03,Chr03-1,C1
255
+ P10,2.0,Chr05,Chr05-8,C1
256
+ P10,2.0,Chr10,Chr10-2,C1
257
+ P10,2.0,Chr10,Chr10-1,C1
258
+ P10,2.0,Chr07,Chr07-2,C1
259
+ P10,2.0,Chr08,Chr08-6,C1
260
+ P10,2.0,Chr14,Chr14-1,C1
261
+ P10,2.0,Chr08,Chr08-4,C1
262
+ P10,2.0,Chr13,Chr13-2,C1
263
+ P10,2.0,Chr02,Chr02-2,C1
264
+ P10,2.0,Chr11,Chr11-2,C1
265
+ P10,2.0,Chr09,Chr09-2,C1
266
+ P10,1.0,Chr10,Chr10-2,C1
267
+ P10,1.0,Chr02,Chr02-3,C1
268
+ P10,1.0,Chr11,Chr11-4,C1
269
+ P10,1.0,Chr13,Chr13-2,C1
270
+ P10,1.0,Chr03,Chr03-1,C1
271
+ P10,1.0,Chr05,Chr05-1,C1
272
+ P10,1.0,Chr07,Chr07-3,C1
273
+ P10,1.0,Chr08,Chr08-3,C1
274
+ P10,1.0,Chr14,Chr14-2,C1
275
+ P10,2.0,Chr01,Chr01-2,C1
276
+ P10,2.0,Chr11,Chr11-1,C1
277
+ P10,1.0,Chr09,Chr09-1,C1
278
+ P10,1.0,Chr01,Chr01-1,C1
279
+ P11,1.0,Chr02,Chr02-2,C1
280
+ P11,1.0,Chr10,Chr10-1,C1
281
+ P11,1.0,Chr08,Chr08-1,C1
282
+ P11,1.0,Chr03,Chr03-1,C1
283
+ P11,1.0,Chr05,Chr05-2,C1
284
+ P11,1.0,Chr07,Chr07-1,C1
285
+ P11,1.0,Chr13,Chr13-2,C1
286
+ P11,1.0,Chr11,Chr11-3,C1
287
+ P11,1.0,Chr09,Chr09-1,C1
288
+ P11,2.0,Chr02,Chr02-1,C1
289
+ P11,2.0,Chr02,Chr02-2,C1
290
+ P11,2.0,Chr03,Chr03-3,C1
291
+ P11,2.0,Chr03,Chr03-2,C1
292
+ P11,2.0,Chr07,Chr07-1,C1
293
+ P11,2.0,Chr07,Chr07-3,C1
294
+ P11,2.0,Chr05,Chr05-4,C1
295
+ P11,2.0,Chr11,Chr11-1,C1
296
+ P11,2.0,Chr08,Chr08-1,C1
297
+ P11,2.0,Chr09,Chr09-1,C1
298
+ P11,1.0,Chr01,Chr01-1,C1
299
+ P11,2.0,Chr01,Chr01-1,C1
300
+ P11,1.0,Chr14,Chr14-2,C1
301
+ P11,2.0,Chr14,Chr14-1,C1
302
+ P12,1.0,Chr14,Chr14-5,C2
303
+ P12,2.0,Chr11,Chr11-3,C2
304
+ P12,2.0,Chr01,Chr01-1,C2
305
+ P12,1.0,Chr13,Chr13-2,C2
306
+ P12,1.0,Chr11,Chr11-3,C2
307
+ P12,1.0,Chr10,Chr10-2,C2
308
+ P12,1.0,Chr07,Chr07-2,C2
309
+ P12,1.0,Chr07,Chr07-3,C2
310
+ P12,1.0,Chr07,Chr07-4,C2
311
+ P12,2.0,Chr13,Chr13-2,C2
312
+ P12,3.0,Chr07,Chr07-3,C2
313
+ P12,2.0,Chr14,Chr14-5,C2
314
+ P12,3.0,Chr14,Chr14-5,C2
315
+ P12,3.0,Chr13,Chr13-2,C2
316
+ P12,3.0,Chr10,Chr10-2,C2
317
+ P12,3.0,Chr09,Chr09-2,C2
318
+ P12,3.0,Chr08,Chr08-1,C2
319
+ P12,2.0,Chr02,Chr02-3,C2
320
+ P12,1.0,Chr05,Chr05-6,C2
321
+ P12,1.0,Chr01,Chr01-1,C2
322
+ P12,1.0,Chr03,Chr03-1,C2
323
+ P12,3.0,Chr02,Chr02-3,C2
324
+ P12,2.0,Chr05,Chr05-6,C2
325
+ P12,2.0,Chr03,Chr03-1,C2
326
+ P12,2.0,Chr08,Chr08-1,C2
327
+ P12,2.0,Chr09,Chr09-2,C2
328
+ P12,2.0,Chr10,Chr10-2,C2
329
+ P12,1.0,Chr02,Chr02-3,C2
330
+ P12,2.0,Chr07,Chr07-3,C2
331
+ P13,1.0,Chr03,Chr03-1,C1
332
+ P13,2.0,Chr05,Chr05-1,C1
333
+ P13,2.0,Chr07,Chr07-2,C1
334
+ P13,2.0,Chr08,Chr08-2,C1
335
+ P13,2.0,Chr10,Chr10-1,C1
336
+ P13,2.0,Chr11,Chr11-2,C1
337
+ P13,2.0,Chr13,Chr13-1,C1
338
+ P13,1.0,Chr13,Chr13-1,C1
339
+ P13,1.0,Chr11,Chr11-2,C1
340
+ P13,2.0,Chr14,Chr14-1,C1
341
+ P13,2.0,Chr03,Chr03-1,C1
342
+ P13,2.0,Chr09,Chr09-2,C1
343
+ P13,2.0,Chr02,Chr02-1,C1
344
+ P13,1.0,Chr09,Chr09-2,C1
345
+ P13,1.0,Chr01,Chr01-2,C1
346
+ P13,1.0,Chr02,Chr02-1,C1
347
+ P13,1.0,Chr10,Chr10-1,C1
348
+ P13,1.0,Chr08,Chr08-2,C1
349
+ P13,1.0,Chr07,Chr07-2,C1
350
+ P13,1.0,Chr05,Chr05-1,C1
351
+ P13,2.0,Chr01,Chr01-2,C1
352
+ P13,1.0,Chr14,Chr14-1,C1
353
+ P14,4.0,Chr14,Chr14-2,C1
354
+ P14,3.0,Chr14,Chr14-2,C1
355
+ P14,4.0,Chr01,Chr01-2,C1
356
+ P14,4.0,Chr09,Chr09-2,C1
357
+ P14,3.0,Chr10,Chr10-1,C1
358
+ P14,3.0,Chr08,Chr08-1,C1
359
+ P14,3.0,Chr07,Chr07-1,C1
360
+ P14,3.0,Chr05,Chr05-2,C1
361
+ P14,1.0,Chr02,Chr02-2,C1
362
+ P14,1.0,Chr03,Chr03-3,C1
363
+ P14,4.0,Chr11,Chr11-4,C1
364
+ P14,3.0,Chr11,Chr11-3,C1
365
+ P14,4.0,Chr10,Chr10-1,C1
366
+ P14,4.0,Chr07,Chr07-1,C1
367
+ P14,4.0,Chr07,Chr07-2,C1
368
+ P14,4.0,Chr05,Chr05-1,C1
369
+ P14,4.0,Chr05,Chr05-5,C1
370
+ P14,4.0,Chr03,Chr03-2,C1
371
+ P14,4.0,Chr03,Chr03-1,C1
372
+ P14,4.0,Chr03,Chr03-3,C1
373
+ P14,4.0,Chr02,Chr02-2,C1
374
+ P14,4.0,Chr02,Chr02-1,C1
375
+ P14,4.0,Chr08,Chr08-2,C1
376
+ P14,3.0,Chr13,Chr13-2,C1
377
+ P14,4.0,Chr11,Chr11-2,C1
378
+ P14,2.0,Chr07,Chr07-2,C1
379
+ P14,2.0,Chr14,Chr14-1,C1
380
+ P14,2.0,Chr14,Chr14-2,C1
381
+ P14,2.0,Chr13,Chr13-1,C1
382
+ P14,2.0,Chr11,Chr11-2,C1
383
+ P14,2.0,Chr11,Chr11-4,C1
384
+ P14,2.0,Chr10,Chr10-1,C1
385
+ P14,2.0,Chr08,Chr08-2,C1
386
+ P14,2.0,Chr02,Chr02-2,C1
387
+ P14,2.0,Chr01,Chr01-1,C1
388
+ P14,2.0,Chr05,Chr05-1,C1
389
+ P14,1.0,Chr09,Chr09-3,C1
390
+ P14,1.0,Chr01,Chr01-1,C1
391
+ P14,1.0,Chr14,Chr14-2,C1
392
+ P14,1.0,Chr13,Chr13-4,C1
393
+ P14,1.0,Chr11,Chr11-4,C1
394
+ P14,1.0,Chr08,Chr08-1,C1
395
+ P14,1.0,Chr07,Chr07-1,C1
396
+ P14,1.0,Chr05,Chr05-1,C1
397
+ P14,2.0,Chr03,Chr03-1,C1
398
+ P14,2.0,Chr09,Chr09-2,C1
399
+ P15,2.0,Chr01,Chr01-1,C1
400
+ P15,2.0,Chr09,Chr09-1,C1
401
+ P15,1.0,Chr11,Chr11-1,C1
402
+ P15,1.0,Chr13,Chr13-5,C1
403
+ P15,2.0,Chr13,Chr13-5,C1
404
+ P15,2.0,Chr13,Chr13-1,C1
405
+ P15,2.0,Chr11,Chr11-1,C1
406
+ P15,2.0,Chr08,Chr08-2,C1
407
+ P15,2.0,Chr08,Chr08-1,C1
408
+ P15,2.0,Chr07,Chr07-1,C1
409
+ P15,2.0,Chr05,Chr05-1,C1
410
+ P15,2.0,Chr03,Chr03-3,C1
411
+ P15,2.0,Chr02,Chr02-1,C1
412
+ P15,1.0,Chr13,Chr13-1,C1
413
+ P15,1.0,Chr07,Chr07-2,C1
414
+ P15,1.0,Chr08,Chr08-1,C1
415
+ P15,1.0,Chr08,Chr08-2,C1
416
+ P15,1.0,Chr02,Chr02-1,C1
417
+ P15,1.0,Chr05,Chr05-1,C1
418
+ P15,2.0,Chr03,Chr03-1,C1
419
+ P15,2.0,Chr14,Chr14-1,C1
420
+ P15,1.0,Chr09,Chr09-2,C1
421
+ P15,1.0,Chr09,Chr09-1,C1
422
+ P15,1.0,Chr14,Chr14-1,C1
423
+ P15,1.0,Chr07,Chr07-1,C1
424
+ P15,1.0,Chr03,Chr03-1,C1
425
+ P16,2.0,Chr07,Chr07-5,C2
426
+ P16,2.0,Chr09,Chr09-2,C2
427
+ P16,1.0,Chr11,Chr11-2,C2
428
+ P16,1.0,Chr11,Chr11-1,C2
429
+ P16,1.0,Chr13,Chr13-1,C2
430
+ P16,1.0,Chr14,Chr14-1,C2
431
+ P16,2.0,Chr02,Chr02-5,C2
432
+ P16,2.0,Chr02,Chr02-2,C2
433
+ P16,2.0,Chr03,Chr03-1,C2
434
+ P16,1.0,Chr05,Chr05-12,C2
435
+ P16,2.0,Chr05,Chr05-7,C2
436
+ P16,1.0,Chr09,Chr09-1,C2
437
+ P16,1.0,Chr03,Chr03-5,C2
438
+ P16,2.0,Chr10,Chr10-1,C2
439
+ P16,2.0,Chr11,Chr11-1,C2
440
+ P16,2.0,Chr13,Chr13-1,C2
441
+ P16,2.0,Chr14,Chr14-5,C2
442
+ P16,1.0,Chr10,Chr10-2,C2
443
+ P16,1.0,Chr08,Chr08-1,C2
444
+ P16,1.0,Chr07,Chr07-3,C2
445
+ P16,2.0,Chr07,Chr07-4,C2
446
+ P16,1.0,Chr01,Chr01-1,C2
447
+ P16,1.0,Chr02,Chr02-7,C2
448
+ P17,1.0,Chr05,Chr05-6,C2
449
+ P17,2.0,Chr05,Chr05-5,C2
450
+ P17,2.0,Chr05,Chr05-6,C2
451
+ P17,2.0,Chr07,Chr07-5,C2
452
+ P17,2.0,Chr07,Chr07-2,C2
453
+ P17,2.0,Chr08,Chr08-1,C2
454
+ P17,2.0,Chr09,Chr09-3,C2
455
+ P17,2.0,Chr09,Chr09-1,C2
456
+ P17,2.0,Chr01,Chr01-2,C2
457
+ P17,1.0,Chr03,Chr03-1,C2
458
+ P17,2.0,Chr02,Chr02-4,C2
459
+ P17,1.0,Chr01,Chr01-1,C2
460
+ P17,2.0,Chr14,Chr14-1,C2
461
+ P17,1.0,Chr13,Chr13-2,C2
462
+ P17,1.0,Chr14,Chr14-5,C2
463
+ P17,1.0,Chr11,Chr11-3,C2
464
+ P17,1.0,Chr10,Chr10-2,C2
465
+ P17,1.0,Chr09,Chr09-2,C2
466
+ P17,1.0,Chr07,Chr07-3,C2
467
+ P17,2.0,Chr13,Chr13-2,C2
468
+ P17,1.0,Chr02,Chr02-3,C2
469
+ P17,2.0,Chr10,Chr10-1,C2
470
+ P17,2.0,Chr03,Chr03-1,C2
471
+ P18,1.0,Chr03,Chr03-4,C2
472
+ P18,1.0,Chr05,Chr05-3,C2
473
+ P18,1.0,Chr07,Chr07-1,C2
474
+ P18,1.0,Chr08,Chr08-1,C2
475
+ P18,1.0,Chr09,Chr09-1,C2
476
+ P18,1.0,Chr10,Chr10-1,C2
477
+ P18,1.0,Chr13,Chr13-3,C2
478
+ P18,1.0,Chr11,Chr11-3,C2
479
+ P18,1.0,Chr14,Chr14-3,C2
480
+ P18,2.0,Chr01,Chr01-2,C2
481
+ P18,2.0,Chr10,Chr10-1,C2
482
+ P18,2.0,Chr02,Chr02-5,C2
483
+ P18,2.0,Chr03,Chr03-4,C2
484
+ P18,2.0,Chr05,Chr05-3,C2
485
+ P18,2.0,Chr07,Chr07-1,C2
486
+ P18,2.0,Chr08,Chr08-1,C2
487
+ P18,2.0,Chr09,Chr09-1,C2
488
+ P18,2.0,Chr10,Chr10-2,C2
489
+ P18,2.0,Chr11,Chr11-3,C2
490
+ P18,2.0,Chr13,Chr13-3,C2
491
+ P18,2.0,Chr14,Chr14-3,C2
492
+ P18,1.0,Chr01,Chr01-2,C2
493
+ P18,1.0,Chr02,Chr02-5,C2
494
+ P19,2.0,Chr07,Chr07-4,C1
495
+ P19,2.0,Chr14,Chr14-2,C1
496
+ P19,3.0,Chr14,Chr14-1,C1
497
+ P19,3.0,Chr10,Chr10-1,C1
498
+ P19,3.0,Chr11,Chr11-1,C1
499
+ P19,2.0,Chr13,Chr13-3,C1
500
+ P19,3.0,Chr07,Chr07-1,C1
501
+ P19,3.0,Chr03,Chr03-1,C1
502
+ P19,3.0,Chr02,Chr02-1,C1
503
+ P19,2.0,Chr01,Chr01-3,C1
504
+ P19,1.0,Chr14,Chr14-1,C1
505
+ P19,2.0,Chr10,Chr10-1,C1
506
+ P19,2.0,Chr08,Chr08-2,C1
507
+ P19,2.0,Chr07,Chr07-5,C1
508
+ P19,2.0,Chr05,Chr05-2,C1
509
+ P19,2.0,Chr03,Chr03-1,C1
510
+ P19,2.0,Chr03,Chr03-3,C1
511
+ P19,1.0,Chr09,Chr09-1,C1
512
+ P19,1.0,Chr09,Chr09-2,C1
513
+ P19,3.0,Chr13,Chr13-2,C1
514
+ P19,1.0,Chr01,Chr01-2,C1
515
+ P19,2.0,Chr02,Chr02-3,C1
516
+ P19,1.0,Chr14,Chr14-2,C1
517
+ P19,1.0,Chr02,Chr02-1,C1
518
+ P19,1.0,Chr02,Chr02-2,C1
519
+ P19,1.0,Chr03,Chr03-3,C1
520
+ P19,1.0,Chr03,Chr03-1,C1
521
+ P19,1.0,Chr05,Chr05-1,C1
522
+ P19,1.0,Chr05,Chr05-4,C1
523
+ P19,1.0,Chr07,Chr07-2,C1
524
+ P19,1.0,Chr07,Chr07-1,C1
525
+ P19,1.0,Chr07,Chr07-3,C1
526
+ P19,1.0,Chr08,Chr08-1,C1
527
+ P19,1.0,Chr08,Chr08-2,C1
528
+ P19,1.0,Chr10,Chr10-1,C1
529
+ P19,1.0,Chr11,Chr11-1,C1
530
+ P19,1.0,Chr11,Chr11-5,C1
531
+ P19,1.0,Chr13,Chr13-1,C1
532
+ P19,1.0,Chr13,Chr13-2,C1
533
+ P19,1.0,Chr13,Chr13-4,C1
534
+ P19,3.0,Chr09,Chr09-2,C1
535
+ P19,1.0,Chr01,Chr01-1,C1
536
+ P20,2.0,Chr07,Chr07-3,C2
537
+ P20,1.0,Chr14,Chr14-2,C2
538
+ P20,2.0,Chr08,Chr08-1,C2
539
+ P20,2.0,Chr09,Chr09-4,C2
540
+ P20,2.0,Chr10,Chr10-2,C2
541
+ P20,2.0,Chr11,Chr11-2,C2
542
+ P20,2.0,Chr13,Chr13-4,C2
543
+ P20,2.0,Chr14,Chr14-2,C2
544
+ P20,1.0,Chr02,Chr02-8,C2
545
+ P20,2.0,Chr03,Chr03-3,C2
546
+ P20,1.0,Chr03,Chr03-3,C2
547
+ P20,1.0,Chr07,Chr07-3,C2
548
+ P20,1.0,Chr09,Chr09-1,C2
549
+ P20,1.0,Chr10,Chr10-2,C2
550
+ P20,1.0,Chr11,Chr11-2,C2
551
+ P20,1.0,Chr13,Chr13-4,C2
552
+ P20,2.0,Chr05,Chr05-7,C2
553
+ P20,2.0,Chr02,Chr02-8,C2
554
+ P20,2.0,Chr01,Chr01-1,C2
555
+ P20,1.0,Chr01,Chr01-1,C2
556
+ P20,1.0,Chr08,Chr08-1,C2
backend/PvDeepSetNet/src/DeepSets/DeepSets_pipeline.py CHANGED
@@ -1,7 +1,8 @@
1
  import json
2
  import torch
3
  from sklearn.metrics import r2_score
4
- from DeepSets import DataPreprocessor, PvDeepSet_model
 
5
 
6
 
7
 
@@ -10,35 +11,50 @@ def run_prediction(data, mode='prediction'):
10
  #-------------------------------------#
11
  # 1. perform basic preprocess
12
  #-------------------------------------#
13
-
14
- preprocessed_data, meta_df = (
15
- data
16
- .pipe(DataPreprocessor.removing_single_episode_patients)
17
- .pipe(DataPreprocessor.calculate_population_Allele_frequencies, population='country')
18
- .pipe(DataPreprocessor.calculate_MOIs)
19
- .pipe(DataPreprocessor.paired_episode_assigner)
20
- )
21
- tensors = DataPreprocessor.build_deepsets_tensors(df=preprocessed_data, mode=mode)
22
- loaded_data = DataPreprocessor.load_tensor(tensors, mode)
23
 
24
- #-------------------------------------#
25
- # 2. model prediction and evaluation
26
- #-------------------------------------#
27
 
28
  if mode == 'prediction':
 
 
 
 
 
 
 
 
 
 
 
 
29
  return PvDeepSet_model.run_prediction(meta_df=meta_df,
30
- pair_id=tensors['pair_id'],
31
- data_loader = loaded_data,
32
- basic_summary=True)
33
  elif mode == 'evaluation':
 
 
 
 
 
 
 
 
34
  return PvDeepSet_model.run_evaluation(meta_df=meta_df,
35
- pair_id=tensors['pair_id'],
36
- data_loader=loaded_data,
37
- probability_plot = True,
38
- metrics=True,
39
- confusion_matrix=True,
40
- basic_summary=True)
41
  else:
42
- return 'incorrect mode'
43
-
 
 
44
 
 
1
  import json
2
  import torch
3
  from sklearn.metrics import r2_score
4
+ from .Preprocess import DataPreprocessor
5
+ from .Model_result import PvDeepSet_model
6
 
7
 
8
 
 
11
  #-------------------------------------#
12
  # 1. perform basic preprocess
13
  #-------------------------------------#
14
+ if ('loci' in data.columns) and (not 'marker' in data.columns):
15
+ data.rename(columns={'loci':'marker'}, inplace=True)
16
+ if ('haplotype' in data.columns) and (not 'allele' in data.columns):
17
+ data.rename(columns={'haplotype':'allele'}, inplace=True)
18
+ if ('region' in data.columns) and (not 'country' in data.columns):
19
+ data.rename(columns={'region':'country'}, inplace=True)
 
 
 
 
20
 
 
 
 
21
 
22
  if mode == 'prediction':
23
+ req_column = ['patient_id', 'episode', 'marker', 'allele', 'country']
24
+ data, meta_df = (
25
+ data
26
+ .pipe(DataPreprocessor.removing_single_episode_patients)
27
+ .pipe(DataPreprocessor.calculate_population_Allele_frequencies, population='country')
28
+ .pipe(DataPreprocessor.calculate_MOIs)
29
+ .pipe(DataPreprocessor.paired_episode_assigner)
30
+ )
31
+
32
+ tensors = DataPreprocessor.build_deepsets_tensors(df=data, mode=mode)
33
+ loaded_data = DataPreprocessor.load_tensor(tensors, mode)
34
+
35
  return PvDeepSet_model.run_prediction(meta_df=meta_df,
36
+ pair_id=tensors['pair_id'],
37
+ data_loader = loaded_data,
38
+ basic_summary=True)
39
  elif mode == 'evaluation':
40
+ req_column = ['pair_id', 'episode', 'marker', 'allele', 'country', 'prior_C', 'prior_L', 'prior_I', 'post_C', 'post_L', 'post_I']
41
+
42
+ data = DataPreprocessor.calculate_MOIs(data)
43
+ meta_df = data[['pair_id', 'patient_id', 'episode']].drop_duplicates().reset_index(drop=True)
44
+
45
+ tensors = DataPreprocessor.build_deepsets_tensors(df=data, mode=mode)
46
+ loaded_data = DataPreprocessor.load_tensor(tensors, mode)
47
+
48
  return PvDeepSet_model.run_evaluation(meta_df=meta_df,
49
+ pair_id=tensors['pair_id'],
50
+ data_loader=loaded_data,
51
+ probability_plot = True,
52
+ metrics=True,
53
+ confusion_matrix=True,
54
+ basic_summary=True)
55
  else:
56
+ return 'incorrect mode'
57
+
58
+
59
+
60
 
backend/PvDeepSetNet/src/DeepSets/Model_result.py CHANGED
@@ -1,16 +1,16 @@
1
- import torch
2
  import json
 
3
  import pandas as pd
4
- from DeepSets import PvDeepSets
5
- from sklearn.metrics import classification_report, confusion_matrix
6
-
7
-
8
-
9
-
10
  import numpy as np
11
  import seaborn as sns
12
  import matplotlib.pyplot as plt
 
13
  from sklearn.metrics import r2_score
 
 
 
 
14
 
15
 
16
  class PvDeepSet_model:
@@ -21,7 +21,11 @@ class PvDeepSet_model:
21
  #-------------------------------------#
22
 
23
  # reading allele dictionary
24
- with open('allele_dict.json', 'r') as file:
 
 
 
 
25
  allele_to_id = json.load(file)
26
 
27
  # Define the device
@@ -33,7 +37,10 @@ class PvDeepSet_model:
33
  model = PvDeepSets(n_alleles=n_alleles)
34
  print(n_alleles)
35
  # Load the weights (state_dict)
36
- model.load_state_dict(torch.load("../src/DeepSets/pv_deepsets_weights20260402.pth", map_location=device))
 
 
 
37
 
38
  return device, model
39
 
@@ -109,19 +116,147 @@ class PvDeepSet_model:
109
  # Apply the logic to create the new column
110
  results_df['predicted_class'] = results_df.apply(classify_row, axis=1)
111
 
112
- def get_basic_summary(result_df):
113
- return f"\n--- Prediction Summary --- {result_df['predicted_class'].value_counts()} --------------------------\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
 
115
  results_df = results_df.merge(meta_df, left_on='pair_id', right_on='sample_id_paired', how='inner')
116
 
117
  columns = ['pair_id', 'patient_id', 'true_episode', 'prob_C', 'prob_L', 'prob_I', 'predicted_class']
118
  results = {
119
  'results_table':results_df[columns],
120
- 'basic_summary': get_basic_summary(results_df)
 
121
  }
122
 
123
  return results
124
-
125
  def run_evaluation(meta_df,
126
  pair_id,
127
  data_loader,
 
1
+ import os
2
  import json
3
+ import torch
4
  import pandas as pd
 
 
 
 
 
 
5
  import numpy as np
6
  import seaborn as sns
7
  import matplotlib.pyplot as plt
8
+ import plotly.express as px
9
  from sklearn.metrics import r2_score
10
+ from DeepSets import PvDeepSets
11
+ from sklearn.metrics import classification_report, confusion_matrix
12
+
13
+
14
 
15
 
16
  class PvDeepSet_model:
 
21
  #-------------------------------------#
22
 
23
  # reading allele dictionary
24
+ # Get the directory where Model_result.py is located
25
+ base_path = os.path.dirname(__file__)
26
+ file_path = os.path.join(base_path, 'allele_dict.json')
27
+
28
+ with open(file_path, 'r') as file:
29
  allele_to_id = json.load(file)
30
 
31
  # Define the device
 
37
  model = PvDeepSets(n_alleles=n_alleles)
38
  print(n_alleles)
39
  # Load the weights (state_dict)
40
+ # Get the directory where Preprocess.py is located
41
+ base_path = os.path.dirname(__file__)
42
+ file_path = os.path.join(base_path, 'pv_deepsets_weights20260402.pth')
43
+ model.load_state_dict(torch.load(file_path, weights_only=True, map_location=device))
44
 
45
  return device, model
46
 
 
116
  # Apply the logic to create the new column
117
  results_df['predicted_class'] = results_df.apply(classify_row, axis=1)
118
 
119
+ dist_df = results_df['predicted_class'].value_counts().reset_index()
120
+ dist_df.columns = ['class', 'count']
121
+
122
+
123
+ # fig = px.bar(
124
+ # dist_df, x='class', y='count',
125
+ # color='class', title="Classification Distribution",
126
+ # template="plotly_white"
127
+ # )
128
+ def plot_donut_count(df):
129
+ # 1. Prepare the data
130
+ # Assuming 'df' is your processed dataframe from the previous step
131
+ counts_df = df['predicted_class'].value_counts().reset_index()
132
+ counts_df.columns = ['Class', 'Count']
133
+ map_rec = {'C':'C (Recrudescence)', 'L': 'L (Relapse)', 'I':'I (Reinfection)'}
134
+
135
+ counts_df['Class'] = counts_df['Class'].map(map_rec)
136
+
137
+ # 2. Create the Donut Chart
138
+ fig = px.pie(
139
+ counts_df,
140
+ values='Count',
141
+ names='Class',
142
+ hole=0.5, # This creates the "donut" effect
143
+ color='Class',
144
+ # Keeping colors consistent: Orange (C), Yellow (L), Teal (I)
145
+ color_discrete_map={
146
+ 'C (Recrudescence)': '#ff4d00',
147
+ 'L (Relapse)': '#e6b400',
148
+ 'I (Reinfection)': '#1fb3c4'
149
+ },
150
+ template="plotly_white"
151
+ )
152
+
153
+ # 3. Refine the layout to match your previous style
154
+ fig.update_layout(
155
+ margin=dict(l=20, r=20, t=60, b=20),
156
+ height=500,
157
+ paper_bgcolor='white',
158
+ # Horizontal legend at the top
159
+ legend=dict(
160
+ orientation="h",
161
+ yanchor="bottom",
162
+ y=1.05,
163
+ xanchor="center",
164
+ x=0.5,
165
+ title=None
166
+ )
167
+ )
168
+
169
+ # 4. Enhance the traces (labels and percentages)
170
+ fig.update_traces(
171
+ textposition='inside',
172
+ textinfo='percent+label', # Shows the Class name and %
173
+ marker=dict(line=dict(color='#FFFFFF', width=2)) # Adds a small white gap between segments
174
+ )
175
+
176
+ return fig
177
+
178
+
179
+ def plot_probability_dist(df):
180
+
181
+ df = df.copy()
182
+ df = df[['pair_id', 'prob_C', 'prob_L','prob_I','predicted_class']].drop_duplicates().reset_index(drop=True)
183
+
184
+ # Grouped and sorted blocks
185
+ df_C = df[df.predicted_class == 'C'].sort_values('prob_C', ascending=False).reset_index(drop=True)
186
+ df_L = df[df.predicted_class == 'L'].sort_values('prob_L', ascending=False).reset_index(drop=True)
187
+ df_I = df[df.predicted_class == 'I'].sort_values('prob_I', ascending=False).reset_index(drop=True)
188
+
189
+ df_sorted = pd.concat([df_C, df_L, df_I], ignore_index=True)
190
+
191
+ df_long = df_sorted.melt(
192
+ id_vars=['pair_id'],
193
+ value_vars=['prob_C', 'prob_L', 'prob_I'],
194
+ var_name='Probability_Type',
195
+ value_name='Probability'
196
+ )
197
+
198
+ fig = px.bar(
199
+ df_long,
200
+ x="pair_id",
201
+ y="Probability",
202
+ color="Probability_Type",
203
+ color_discrete_sequence=['#ff4d00', '#e6b400', '#1fb3c4'],
204
+ category_orders={"pair_id": df_sorted['pair_id'].tolist()},
205
+ template="plotly_white" # Sets white background and clean gridlines
206
+ )
207
+
208
+ fig.update_layout(
209
+ title=None,
210
+ margin=dict(l=50, r=20, t=60, b=50), # Adjusted for axis labels
211
+ height=500,
212
+ paper_bgcolor='white',
213
+ plot_bgcolor='white',
214
+
215
+ # Horizontal legend at the top
216
+ legend=dict(
217
+ orientation="h",
218
+ yanchor="bottom",
219
+ y=1.02,
220
+ xanchor="center",
221
+ x=0.5,
222
+ title=None
223
+ ),
224
+
225
+ xaxis=dict(
226
+ title="Samples", # Restored the label
227
+ showticklabels=False, # Keeps specific IDs hidden for cleanliness
228
+ ticks="",
229
+ linecolor='black', # Adds a crisp base line
230
+ showgrid=False
231
+ ),
232
+
233
+ yaxis=dict(
234
+ title="Probability",
235
+ range=[0, 1],
236
+ tickformat=".1f",
237
+ linecolor='black',
238
+ gridcolor='lightgrey' # Subtle grid for probability reference
239
+ ),
240
+
241
+ bargap=0
242
+ )
243
+
244
+ return fig
245
+
246
+ donut_plot = plot_donut_count(results_df)
247
+ probability_dist_plot = plot_probability_dist(results_df)
248
 
249
  results_df = results_df.merge(meta_df, left_on='pair_id', right_on='sample_id_paired', how='inner')
250
 
251
  columns = ['pair_id', 'patient_id', 'true_episode', 'prob_C', 'prob_L', 'prob_I', 'predicted_class']
252
  results = {
253
  'results_table':results_df[columns],
254
+ 'donut_plot': donut_plot,
255
+ 'distribution_plot': probability_dist_plot
256
  }
257
 
258
  return results
259
+ @staticmethod
260
  def run_evaluation(meta_df,
261
  pair_id,
262
  data_loader,
backend/PvDeepSetNet/src/DeepSets/Preprocess.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import pandas as pd
2
  import numpy as np
3
  import torch
@@ -152,7 +153,11 @@ class DataPreprocessor:
152
 
153
 
154
  # reading allele dictionary
155
- with open('allele_dict.json', 'r') as file:
 
 
 
 
156
  allele_to_id = json.load(file)
157
 
158
  # build tensor for target variable only if the mode == evaluation
 
1
+ import os
2
  import pandas as pd
3
  import numpy as np
4
  import torch
 
153
 
154
 
155
  # reading allele dictionary
156
+ # Get the directory where Preprocess.py is located
157
+ base_path = os.path.dirname(__file__)
158
+ file_path = os.path.join(base_path, 'allele_dict.json')
159
+
160
+ with open(file_path, 'r') as file:
161
  allele_to_id = json.load(file)
162
 
163
  # build tensor for target variable only if the mode == evaluation
backend/PvDeepSetNet/src/DeepSets/__init__.py CHANGED
@@ -1,4 +1,3 @@
1
- from .Build_tensors import build_deepsets_tensors
2
  from .Preprocess import DataPreprocessor
3
  from .Model import PvDeepSets
4
  from .DeepSets_pipeline import run_prediction
 
 
1
  from .Preprocess import DataPreprocessor
2
  from .Model import PvDeepSets
3
  from .DeepSets_pipeline import run_prediction
backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc CHANGED
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/DeepSets_pipeline.cpython-310.pyc differ
 
backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc CHANGED
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/Model_result.cpython-310.pyc differ
 
backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc CHANGED
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/Preprocess.cpython-310.pyc differ
 
backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc CHANGED
Binary files a/backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc and b/backend/PvDeepSetNet/src/DeepSets/__pycache__/__init__.cpython-310.pyc differ
 
backend/PvDeepSetNet/tests/temp.ipynb CHANGED
The diff for this file is too large to render. See raw diff
 
backend/__pycache__/main.cpython-310.pyc ADDED
Binary file (1.27 kB). View file
 
backend/main.py CHANGED
@@ -1,24 +1,53 @@
1
- # backend/main.py
2
  from fastapi import FastAPI, UploadFile, File
 
 
 
 
3
  import uvicorn
4
 
5
  app = FastAPI()
6
 
 
 
 
7
  @app.post("/upload-data")
8
  async def upload_data(file: UploadFile = File(...)):
9
- # Your logic to save file and trigger preprocessing
10
- return {"dataset_id": "test_id_123"}
 
 
11
 
12
  @app.post("/predict")
13
  async def predict(data: dict):
14
- # Your Deep Sets Model Inference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  return {
16
- "prediction": "Relapse",
17
- "confidence": 0.85,
18
- "probabilities": {"C": 0.1, "L": 0.85, "I": 0.05}
19
  }
20
 
21
- # Add your MOI and Allele Frequency endpoints here...
22
-
23
  if __name__ == "__main__":
24
  uvicorn.run(app, host="127.0.0.1", port=8000)
 
 
1
  from fastapi import FastAPI, UploadFile, File
2
+ import pandas as pd
3
+ import io
4
+ import plotly.io as pio # For converting Plotly figures to JSON
5
+ from PvDeepSetNet.src.DeepSets import run_prediction # Your packaged model
6
  import uvicorn
7
 
8
  app = FastAPI()
9
 
10
+ # Temporary storage for demonstration
11
+ storage = {}
12
+
13
  @app.post("/upload-data")
14
  async def upload_data(file: UploadFile = File(...)):
15
+ contents = await file.read()
16
+ dataset_id = "ds_001" # In a real app, use: str(uuid.uuid4())
17
+ storage[dataset_id] = contents
18
+ return {"dataset_id": dataset_id}
19
 
20
  @app.post("/predict")
21
  async def predict(data: dict):
22
+ dataset_id = data.get("dataset_id")
23
+
24
+ # 1. Retrieve data from storage
25
+ file_bytes = storage.get(dataset_id)
26
+ if not file_bytes:
27
+ return {"error": "Dataset not found"}
28
+
29
+ df = pd.read_csv(io.BytesIO(file_bytes))
30
+
31
+ # 2. Run the real PvDeepSetNet model
32
+ # Note: run_prediction now returns 3 items: table, text, and a plotly figure
33
+ model_output = run_prediction(df)
34
+
35
+ res_df = model_output['results_table']
36
+ # The figure object generated inside your model processing file
37
+ fig1 = model_output.get('donut_plot')
38
+ fig2 = model_output.get('distribution_plot')
39
+
40
+ # 3. Serialize the Plotly Figure to JSON
41
+ # This allows the plot to be sent over the internet as a string
42
+ plot_json1 = pio.to_json(fig1) if fig1 else None
43
+ plot_json2 = pio.to_json(fig2) if fig2 else None
44
+
45
+
46
  return {
47
+ "results_table": res_df.to_dict('records'),
48
+ "plot_json1": plot_json1, # The serialized figure
49
+ "plot_json2": plot_json2 # The serialized figure
50
  }
51
 
 
 
52
  if __name__ == "__main__":
53
  uvicorn.run(app, host="127.0.0.1", port=8000)
frontend/app.py CHANGED
@@ -1,267 +1,273 @@
1
  import dash
2
- from dash import dcc, html, Input, Output, State, dash_table
3
  import dash_bootstrap_components as dbc
4
- import plotly.express as px
5
  import pandas as pd
 
6
  import base64
7
  import io
8
-
9
- # Import your custom API service
10
  from services.api import PvRecNetAPI
11
 
12
- # 1. Initialize the Dash App
13
  app = dash.Dash(
14
  __name__,
15
  external_stylesheets=[dbc.themes.FLATLY],
16
- title="PvRecNet Malaria System"
 
17
  )
18
 
19
- # 2. Define the Layout
20
- app.layout = dbc.Container([
21
- # Browser-side storage for the dataset ID
22
  dcc.Store(id='dataset-id-store', storage_type='session'),
23
-
24
- # Header
25
- dbc.Row(dbc.Col(html.H1("PvRecNet: Malaria Recurrence Classifier", className="text-center my-4"), width=12)),
26
 
27
- dbc.Tabs([
28
- # --- TAB 1: PREDICTION WORKFLOW ---
29
- dbc.Tab(label="Prediction Workflow", children=[
30
- dbc.Row([
31
- # Left Column: Controls
32
- dbc.Col([
33
- dbc.Card([
34
- dbc.CardHeader(html.B("Step 1: Upload & Action")),
35
- dbc.CardBody([
36
- dcc.Upload(
37
- id='upload-data',
38
- children=html.Div(['Drag/Drop or ', html.A('Select CSV')]),
39
- style={
40
- 'width': '100%', 'height': '60px', 'lineHeight': '60px',
41
- 'borderWidth': '1px', 'borderStyle': 'dashed',
42
- 'borderRadius': '5px', 'textAlign': 'center'
43
- }
44
- ),
45
- html.Div(id='upload-status', className="mt-2"),
46
- html.Hr(),
47
- dbc.Button(
48
- "Run Deep Sets Prediction",
49
- id="predict-btn",
50
- color="primary",
51
- disabled=True,
52
- className="w-100"
53
- ),
54
- html.Small("Note: Prediction uses the data currently in the table.",
55
- className="text-muted mt-2 d-block")
56
- ])
57
- ])
58
- ], md=4),
59
 
60
- # Right Column: Interactive Data Preview
61
- dbc.Col([
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  dbc.Card([
63
- dbc.CardHeader(html.B("Step 2: Interactive Data Workbench")),
64
  dbc.CardBody([
65
- dcc.Loading(id="loading-preview", children=[
66
- dash_table.DataTable(
67
- id='preview-table',
68
- columns=[], # <--- CRITICAL: Initialize as empty list
69
- data=[], # <--- CRITICAL: Initialize as empty list
70
-
71
- # Interactivity
72
- editable=True,
73
- # filter_action="native",
74
- sort_action="native",
75
- sort_mode="multi",
76
- row_deletable=True,
77
-
78
- # Pagination & Scrolling
79
- page_action="native",
80
- page_current=0,
81
- page_size=15,
82
- fixed_rows={'headers': True},
83
-
84
- style_table={
85
- 'height': '450px',
86
- 'overflowY': 'auto',
87
- 'overflowX': 'auto',
88
- },
89
-
90
- # Visual Styling
91
- style_header={
92
- 'backgroundColor': '#f8f9fa',
93
- 'fontWeight': 'bold',
94
- 'border': '1px solid #dee2e6'
95
- },
96
- style_cell={
97
- 'textAlign': 'left',
98
- 'font-family': 'Segoe UI, Tahoma, Geneva, Verdana, sans-serif',
99
- 'minWidth': '120px', 'width': '150px', 'maxWidth': '300px',
100
- 'padding': '8px'
101
- },
102
- style_data_conditional=[
103
- {'if': {'row_index': 'odd'}, 'backgroundColor': 'rgb(250, 250, 250)'},
104
- {'if': {'state': 'active'}, 'backgroundColor': 'rgba(0, 123, 255, 0.1)', 'border': '1px solid #007bff'}
105
- ]
106
- )
107
  ])
108
  ])
109
- ])
110
- ], md=8)
111
- ], className="mt-4"),
112
 
113
- # Bottom Row: Inference Results
114
- dbc.Row([
115
- dbc.Col([
116
- dbc.Card([
117
- dbc.CardHeader(html.B("Step 3: Model Output")),
118
- dbc.CardBody(dcc.Loading(id="prediction-output"))
119
- ], className="mt-4 mb-5")
120
- ], width=12)
121
- ])
 
 
 
122
  ]),
123
 
124
- # --- TAB 2: ANALYTICS TOOLS ---
125
- dbc.Tab(label="Analytics Tools", children=[
126
- dbc.Row([
127
- dbc.Col([
128
- dbc.Card([
129
- dbc.CardHeader(html.B("Genomic Analytics")),
130
- dbc.CardBody([
131
- html.P("These tools operate on the uploaded dataset ID independently of the classifier."),
132
- dbc.Button("Compute MOI", id="moi-btn", color="info", className="me-2"),
133
- dbc.Button("Compute Allele Freq", id="freq-btn", color="secondary"),
134
- html.Hr(),
135
- dcc.Loading(id="analytics-output")
136
- ])
 
 
 
 
 
137
  ])
138
- ], md=12)
139
- ], className="mt-4")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  ])
141
- ])
142
- ], fluid=True)
 
 
 
 
 
 
 
 
 
143
 
144
- # --- CALLBACKS ---
 
 
 
 
 
 
 
 
 
145
 
146
- # 1. Handle File Upload, API Registration, and Table Population
147
  @app.callback(
148
- Output('dataset-id-store', 'data'),
149
- Output('upload-status', 'children'),
150
- Output('predict-btn', 'disabled'),
151
- Output('preview-table', 'data'),
152
- Output('preview-table', 'columns'),
153
- Output('preview-table', 'fixed_rows'), # NEW: Dynamic fixed rows
154
- Input('upload-data', 'contents'),
155
- State('upload-data', 'filename'),
156
  prevent_initial_call=True
157
  )
158
- def handle_upload_and_preview(contents, filename):
159
- if not contents:
160
- return dash.no_update
161
-
162
- try:
163
- content_type, content_string = contents.split(',')
164
- decoded = base64.b64decode(content_string)
165
- df = pd.read_csv(io.BytesIO(decoded))
166
-
167
- preview_cols = []
168
- for i in df.columns:
169
- column_type = 'numeric' if pd.api.types.is_numeric_dtype(df[i]) else 'text'
170
- preview_cols.append({"name": i, "id": i, "editable": True, "type": column_type})
171
 
172
- api_response = PvRecNetAPI.upload_dataset(decoded, filename)
173
- dataset_id = api_response.get("dataset_id")
174
-
175
- # We now return {'headers': True} as the last argument
176
- return dataset_id, dbc.Alert(f"Loaded {filename}", color="success"), False, \
177
- df.head(200).to_dict('records'), preview_cols, {'headers': True}
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  except Exception as e:
180
- # Return {'headers': False} on error to keep it from crashing
181
  return None, dbc.Alert(f"Error: {str(e)}", color="danger"), True, [], [], {'headers': False}
182
 
183
- # 2. Run Model Prediction
184
  @app.callback(
185
  Output('prediction-output', 'children'),
186
  Input('predict-btn', 'n_clicks'),
187
  State('dataset-id-store', 'data'),
188
  prevent_initial_call=True
189
  )
190
- def run_model_inference(n_clicks, dataset_id):
191
- if not dataset_id:
192
- return dbc.Alert("No dataset found. Please upload a file first.", color="warning")
193
-
194
  try:
195
- # Call Backend API
196
  res = PvRecNetAPI.run_prediction(dataset_id)
197
-
198
- # Plotly Bar Chart for Probability
199
- probs = res.get('probabilities', {})
200
- fig = px.bar(
201
- x=list(probs.keys()),
202
- y=list(probs.values()),
203
- labels={'x': 'Class', 'y': 'Probability'},
204
- title="Deep Sets Probability Distribution",
205
- color=list(probs.keys()),
206
- template="plotly_white"
207
- )
208
-
209
- return html.Div([
210
- dbc.Row([
211
- dbc.Col([
212
- html.Div([
213
- html.H4("Classification Result"),
214
- html.H2(res['prediction'], className="text-primary"),
215
- html.P(f"Model Confidence: {res['confidence']:.2%}")
216
- ], className="p-3 border rounded bg-light")
217
- ], md=4),
218
- dbc.Col([
219
- dcc.Graph(figure=fig, style={'height': '300px'})
220
- ], md=8)
221
- ])
222
- ])
223
- except Exception as e:
224
- return dbc.Alert(f"Inference Failed: {str(e)}", color="danger")
225
 
226
- # 3. Analytics Tools (MOI & Allele Frequency)
227
- @app.callback(
228
- Output('analytics-output', 'children'),
229
- Input('moi-btn', 'n_clicks'),
230
- Input('freq-btn', 'n_clicks'),
231
- State('dataset-id-store', 'data'),
232
- prevent_initial_call=True
233
- )
234
- def handle_analytics(moi_n, freq_n, dataset_id):
235
- if not dataset_id:
236
- return dbc.Alert("No data available for analytics. Go to Prediction tab to upload.", color="warning")
237
-
238
- ctx = dash.callback_context
239
- button_id = ctx.triggered[0]['prop_id'].split('.')[0]
240
 
241
- try:
242
- if button_id == "moi-btn":
243
- res = PvRecNetAPI.get_moi(dataset_id)
244
- return html.Div([
245
- html.H5("Multiplicity of Infection (MOI) Table"),
246
- dash_table.DataTable(
247
- data=res,
248
- page_size=10,
249
- filter_action="native",
250
- sort_action="native",
251
- style_table={'overflowX': 'auto'}
252
- )
253
- ])
254
-
255
- elif button_id == "freq-btn":
256
- res = PvRecNetAPI.get_allele_freq(dataset_id)
257
- # Assuming res is a list of {'allele': str, 'frequency': float}
258
- fig = px.pie(res, names='allele', values='frequency', title="Allele Frequency Distribution")
259
- return dcc.Graph(figure=fig)
260
-
261
- except Exception as e:
262
- return dbc.Alert(f"Analytical Tool Error: {str(e)}", color="danger")
263
 
264
- # 4. Main Entry Point
265
  if __name__ == '__main__':
266
- # Using app.run() for modern Dash compatibility
267
  app.run(debug=True, port=8050)
 
1
  import dash
2
+ from dash import dcc, html, Input, Output, State, dash_table, callback_context
3
  import dash_bootstrap_components as dbc
 
4
  import pandas as pd
5
+ import json
6
  import base64
7
  import io
 
 
8
  from services.api import PvRecNetAPI
9
 
10
+ # 1. Initialize App
11
  app = dash.Dash(
12
  __name__,
13
  external_stylesheets=[dbc.themes.FLATLY],
14
+ title="PvRecNet Malaria System",
15
+ suppress_callback_exceptions=True
16
  )
17
 
18
+ # 2. Define the Main App Layout (Navigation + Page Container)
19
+ app.layout = html.Div([
20
+ dcc.Location(id='url', refresh=False), # Tracks the URL
21
  dcc.Store(id='dataset-id-store', storage_type='session'),
22
+ html.Div(id='page-content') # Where different pages will be rendered
23
+ ])
 
24
 
25
+ # --- PAGE 1: THE HELP / GUIDELINE PAGE ---
26
+ # --- PAGE 1: THE HELP / GUIDELINE PAGE ---
27
+ def render_help_page():
28
+ return dbc.Container([
29
+ dbc.Row([
30
+ dbc.Col([
31
+ # Back Button
32
+ dbc.Button("← Back to System", href="/", color="link", className="mt-4 p-0 text-decoration-none"),
33
+
34
+ html.Div([
35
+ # Header Section
36
+ html.Div([
37
+ html.H1("System Guidelines & Documentation", className="display-5 text-primary"),
38
+ html.P([
39
+ "PvRecNet is a deep learning-based model for ",
40
+ html.B(html.I("Plasmodium vivax")), # 1. Bold & Italic
41
+ " recurrence classification."
42
+ ], className="lead"),
43
+ ], className="mb-5"),
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ # 4. Visual Appeal: Use Cards for Sections
46
+ dbc.Row([
47
+ # Section: Description
48
+ dbc.Col([
49
+ html.H5("Model Description", className="text-info"),
50
+ html.P([
51
+ "Our architecture differentiates between ",
52
+ html.B("Recrudescence, Relapse, and Reinfection"),
53
+ ". It is trained on probabilistic outputs from ",
54
+ html.A("Pv3Rs", href="https://github.com/aimeertaylor/Pv3Rs", target="_blank"), # 2. Link
55
+ " to ensure robust genomic classification."
56
+ ]),
57
+ ], md=6),
58
+
59
+ # Section: Data Requirements
60
+ dbc.Col([
61
+ html.H5("Data Requirements", className="text-info"),
62
+ html.P("Your dataset must contain these exact columns:"),
63
+ html.Div([
64
+ dbc.Badge("patient_id", color="primary", className="me-1"),
65
+ dbc.Badge("episode", color="primary", className="me-1"),
66
+ dbc.Badge("marker", color="primary", className="me-1"),
67
+ dbc.Badge("allele", color="primary", className="me-1"),
68
+ dbc.Badge("region", color="primary", className="me-1"),
69
+ ], className="mb-3"),
70
+ html.Small("Note: marker = loci, allele = haplotype, region = country.", className="text-muted")
71
+ ], md=6),
72
+ ], className="mb-4"),
73
+
74
+ html.Hr(),
75
+
76
+ # Section: Limitations
77
+ html.H4("⚠️ Scope & Limitations", className="mt-4 text-warning"),
78
+ html.Ul([
79
+ html.Li([html.B("Dependency on Pv3Rs: "), "Since the model is trained on the probabilistic outputs of Pv3Rs, its accuracy is bounded by Pv3Rs. Systematic errors in Pv3Rs may be replicated."]),
80
+ html.Li([html.B("Data Requirements: "), "Currently works only with amplicon sequencing datasets containing multiple markers and alleles."]),
81
+ html.Li([html.B("Episode Constraints: "), "Designed specifically for paired-episode classifications; it does not address scenarios with more than two episodes per individual as a single classification."]),
82
+ html.Li([html.B("Generalization: "), "The model may not generalize well to genetic markers or alleles unobserved during training."]),
83
+ html.Li([html.B("Protocol Dependent: "), "Trained specifically on ", html.A("pvAmpSeq", href="https://pubmed.ncbi.nlm.nih.gov/40492072/", target="_blank"), "; it only generalizes when using the same markers and allele names specified in that protocol."]),
84
+
85
+ ], className="text-secondary"),
86
+
87
+ # 4 & 5. Sample Dataset Section (Visual Highlight)
88
  dbc.Card([
 
89
  dbc.CardBody([
90
+ dbc.Row([
91
+ dbc.Col([
92
+ html.H4("Practice with Sample Data", className="card-title"),
93
+ html.P("Download our demonstration file to see how the markers and episodes should be formatted."),
94
+ ], md=8),
95
+ dbc.Col([
96
+ dbc.Button(
97
+ "📥 Download Sample CSV",
98
+ id="download-sample-btn",
99
+ color="success",
100
+ className="w-100 mt-2"
101
+ ),
102
+ dcc.Download(id="download-sample-csv"),
103
+ ], md=4),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  ])
105
  ])
106
+ ], color="light", className="mt-5 border-start border-success border-4"),
 
 
107
 
108
+ ], className="p-5 bg-white shadow-sm rounded-3 mb-5")
109
+ ], md=10, className="offset-md-1")
110
+ ])
111
+ ], fluid=True)
112
+
113
+ # --- PAGE 2: THE MAIN SYSTEM (Tabs) ---
114
+ def render_main_app():
115
+ return dbc.Container([
116
+ dbc.Row([
117
+ dbc.Col(html.H1("PvRecNet", className="text-center my-4", style={"color":'#113d59'}), width=10),
118
+ # Help Link in Top Right
119
+ dbc.Col(html.A("Help & Guidelines", href="/help", className="text-muted", style={"marginTop": "30px", "display": "block"}), width=2)
120
  ]),
121
 
122
+ dbc.Tabs(id="main-tabs", active_tab="tab-intro", children=[
123
+ # Tab 0: Welcome / Landing
124
+ dbc.Tab(label="Welcome", tab_id="tab-intro", active_label_style={"color": '#113d59', "fontWeight": "bold"}, children=[
125
+ dbc.Container([
126
+ dbc.Row([
127
+ dbc.Col([
128
+ html.Div([
129
+ html.H2("Welcome to PvRecNet", className="display-5 mt-5", style={"color":'#113d59'}),
130
+ html.P("Deep Learning support for Malaria Recurrence Classification.", className="lead"),
131
+ html.P([
132
+ "Please see our ",
133
+ html.A("Help Page", href="/help", style={"fontWeight": "bold"}),
134
+ " to understand exactly how the system works and how to format your data."
135
+ ]),
136
+ html.Hr(),
137
+ dbc.Button("Get Started →", id="get-started-btn", color="primary", size="lg", className="mt-3 shadow")
138
+ ], className="p-5 bg-light border rounded-3 text-center")
139
+ ], md=8, className="offset-md-2")
140
  ])
141
+ ], fluid=True)
142
+ ]),
143
+
144
+ # Tab 1: Prediction Workflow
145
+ dbc.Tab(label="Prediction Workflow", tab_id="tab-predict", children=[
146
+ dbc.Row([
147
+ dbc.Col([
148
+ dbc.Card([
149
+ dbc.CardHeader(html.B("Step 1: Upload Data")),
150
+ dbc.CardBody([
151
+ dcc.Upload(id='upload-data', children=html.Div(['Drag/Drop or Select CSV']),
152
+ style={'width': '100%', 'height': '60px', 'lineHeight': '60px', 'borderWidth': '1px', 'borderStyle': 'dashed', 'borderRadius': '5px', 'textAlign': 'center'}),
153
+ html.Div(id='upload-status', className="mt-2"),
154
+ html.Hr(),
155
+ dbc.Button("Run Deep Sets Prediction", id="predict-btn", color="primary", disabled=True, className="w-100")
156
+ ])
157
+ ])
158
+ ], md=4),
159
+ dbc.Col([
160
+ dbc.Card([
161
+ dbc.CardHeader(html.B("Step 2: Data Workbench")),
162
+ dbc.CardBody(dcc.Loading(dash_table.DataTable(
163
+ id='preview-table', columns=[], data=[], export_format='csv', editable=True,
164
+ filter_action="native", sort_action="native", page_size=10,
165
+ style_table={'height': '350px', 'overflowY': 'auto'},
166
+ style_header={'backgroundColor': '#f8f9fa', 'fontWeight': 'bold'},
167
+ style_cell={'textAlign': 'left', 'padding': '10px'}
168
+ )))
169
+ ])
170
+ ], md=8)
171
+ ], className="mt-4"),
172
+ dbc.Row(dbc.Col(dbc.Card([dbc.CardHeader(html.B("Step 3: Model Results")), dbc.CardBody(dcc.Loading(id="prediction-output"))], className="mt-4 mb-5"), width=12))
173
+ ]),
174
+
175
+ # # Tab 2: Analytics Tools
176
+ # dbc.Tab(label="Analytics Tools", tab_id="tab-analytics", children=[
177
+ # dbc.Row(dbc.Col(dbc.Card([
178
+ # dbc.CardHeader(html.B("Genomic Analytics")),
179
+ # dbc.CardBody([
180
+ # dbc.Button("Compute MOI", id="moi-btn", color="info", className="me-2"),
181
+ # dbc.Button("Compute Allele Freq", id="freq-btn", color="secondary"),
182
+ # html.Hr(), dcc.Loading(id="analytics-output")
183
+ # ])
184
+ # ], className="mt-4"), md=12))
185
+ # ])
186
  ])
187
+ ], fluid=True)
188
+
189
+ @app.callback(
190
+ Output("download-sample-csv", "data"),
191
+ Input("download-sample-btn", "n_clicks"),
192
+ prevent_initial_call=True,
193
+ )
194
+ def download_sample_data(n_clicks):
195
+ # Create a small dummy dataframe that matches your 5 required columns
196
+ sample_df = pd.read_csv('../backend/PvDeepSetNet/datasets/GUI_sample_dataset.csv')
197
+ return dcc.send_data_frame(sample_df.to_csv, "pvrecnet_sample_data.csv", index=False)
198
 
199
+ # --- ROUTER CALLBACK ---
200
+ @app.callback(
201
+ Output('page-content', 'children'),
202
+ Input('url', 'pathname')
203
+ )
204
+ def display_page(pathname):
205
+ if pathname == '/help':
206
+ return render_help_page()
207
+ else:
208
+ return render_main_app()
209
 
210
+ # --- NAVIGATION CALLBACK ---
211
  @app.callback(
212
+ Output("main-tabs", "active_tab"),
213
+ Input("get-started-btn", "n_clicks"),
 
 
 
 
 
 
214
  prevent_initial_call=True
215
  )
216
+ def navigate_to_predict(n_clicks):
217
+ return "tab-predict" if n_clicks else "tab-intro"
 
 
 
 
 
 
 
 
 
 
 
218
 
219
+ # --- FUNCTIONAL CALLBACKS (Upload, Predict, Analytics) ---
 
 
 
 
 
220
 
221
+ @app.callback(
222
+ [Output('dataset-id-store', 'data'), Output('upload-status', 'children'), Output('predict-btn', 'disabled'),
223
+ Output('preview-table', 'data'), Output('preview-table', 'columns'), Output('preview-table', 'fixed_rows')],
224
+ [Input('upload-data', 'contents')], [State('upload-data', 'filename')], prevent_initial_call=True
225
+ )
226
+ def handle_upload(contents, filename):
227
+ if not contents: return dash.no_update
228
+ try:
229
+ decoded = base64.b64decode(contents.split(',')[1])
230
+ df = pd.read_csv(io.BytesIO(decoded))
231
+ cols = [{"name": i, "id": i, "editable": True, "type": 'numeric' if pd.api.types.is_numeric_dtype(df[i]) else 'text'} for i in df.columns]
232
+ res = PvRecNetAPI.upload_dataset(decoded, filename)
233
+ return res.get("dataset_id"), dbc.Alert(f"Ready: {filename}", color="success"), False, df.to_dict('records'), cols, {'headers': True}
234
  except Exception as e:
 
235
  return None, dbc.Alert(f"Error: {str(e)}", color="danger"), True, [], [], {'headers': False}
236
 
 
237
  @app.callback(
238
  Output('prediction-output', 'children'),
239
  Input('predict-btn', 'n_clicks'),
240
  State('dataset-id-store', 'data'),
241
  prevent_initial_call=True
242
  )
243
+ def run_predict(n_clicks, dataset_id):
 
 
 
244
  try:
 
245
  res = PvRecNetAPI.run_prediction(dataset_id)
246
+ fig1 = json.loads(res['plot_json1'])
247
+ fig2 = json.loads(res['plot_json2'])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
 
249
+ table = dash_table.DataTable(data=res['results_table'], columns=[{"name": i, "id": i} for i in pd.DataFrame(res['results_table']).columns], export_format='csv', page_size=10, style_table={'height': '400px', 'overflowY': 'auto'})
250
+ return html.Div([dbc.Row([dbc.Col([dcc.Graph(figure=fig1), dcc.Graph(figure=fig2)], md=5), dbc.Col(table, md=7)])])
251
+ except Exception as e: return dbc.Alert(f"Error: {str(e)}", color="danger")
 
 
 
 
 
 
 
 
 
 
 
252
 
253
+ # @app.callback(
254
+ # Output('analytics-output', 'children'),
255
+ # [Input('moi-btn', 'n_clicks'), Input('freq-btn', 'n_clicks')],
256
+ # State('dataset-id-store', 'data'),
257
+ # prevent_initial_call=True
258
+ # )
259
+ # def handle_analytics(moi_n, freq_n, dataset_id):
260
+ # ctx = callback_context
261
+ # bid = ctx.triggered[0]['prop_id'].split('.')[0]
262
+ # try:
263
+ # if bid == "moi-btn":
264
+ # res = PvRecNetAPI.get_moi(dataset_id)
265
+ # return dash_table.DataTable(data=res, columns=[{"name": i, "id": i} for i in pd.DataFrame(res).columns], export_format='csv')
266
+ # else:
267
+ # res = PvRecNetAPI.get_allele_freq(dataset_id)
268
+ # import plotly.express as px
269
+ # return dcc.Graph(figure=px.pie(res, names='allele', values='frequency'))
270
+ # except Exception as e: return dbc.Alert(str(e), color="danger")
 
 
 
 
271
 
 
272
  if __name__ == '__main__':
 
273
  app.run(debug=True, port=8050)