-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.R
3519 lines (3050 loc) · 164 KB
/
app.R
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
library(shiny)
library(shinyBS)
library(shinyWidgets)
library(shinythemes)
library(rgoslin)
library(janitor)
library(ggplot2)
library(png)
library(grid)
library(DT)
library(dplyr)
library(flexdashboard)
#Connect to database
db = readRDS("db/PreanDatab.RDS")
fc = db$fc
an = db$an
con = db$con
ref = db$ref
#Filter respresented substance classes for each matrix (needs to be done only once)
plasma.mtrx = an$an_class[an$an_id%in%(fc$an_id[fc$prean_id %in% con$prean_id[con$matrix == "Plasma"]])] %>% unique() %>% sort() %>% as.list()
serum.mtrx = an$an_class[an$an_id%in%(fc$an_id[fc$prean_id %in% con$prean_id[con$matrix == "Serum"]])] %>% unique() %>% sort() %>% as.list()
plasma.an = an$an_name[an$an_id%in%(fc$an_id[fc$prean_id %in% con$prean_id[con$matrix == "Plasma"]])] %>% unique() %>% sort() %>% as.list()
serum.an = an$an_name[an$an_id%in%(fc$an_id[fc$prean_id %in% con$prean_id[con$matrix == "Serum"]])] %>% unique() %>% sort() %>% as.list()
all.filt.plasm <- unlist(plasma.an)
all.parse.plasm <- parseLipidNames(all.filt.plasm) %>% suppressMessages() %>% suppressWarnings()
all.filt.serum <- unlist(serum.an)
all.parse.serum <- parseLipidNames(all.filt.serum) %>% suppressMessages() %>% suppressWarnings()
cc.fc = fc$an_id[which(fc$prean_id %in% con$prean_id[grep("1|2",con$exp_id)])] %>% unique()
cc.mtrx = an[which(an$an_id %in% cc.fc),]
cc.fc = fc[which(fc$prean_id %in% con$prean_id[grep("1|2",con$exp_id)]),]
cc.class = cc.mtrx$an_class %>% unique() %>% as.list()
#Images for matrix selection menu
drops = data.frame(val = c("Plasma","Serum"))
drops$img <- c(sprintf('<img src="drops/plasma.png" width = 14px><div class="jhr">%s</div></img>',drops$val[1]),
sprintf('<img src="drops/serum.png" width = 14px><div class="jhr">%s</div></img>',drops$val[2]))
#Warning flags for "Protocol search","Sample search" & "Data filtering mode"
flags <- c('<img src="flags/red.png" height="24"></img>',
'<img src="flags/yel.png" height="24"></img>',
'<img src="flags/gre.png" height="24"></img>',
'<img src="flags/tra.png" height="24"></img>',
'<img src="flags/x.png" height="24"></img>',
'<img src="flags/gra.png" height="24"></img>')
#Warning flags for "Analyte search"
an.flag <- c("an.flags/moon.png",
"an.flags/golf.png",
"an.flags/looking.png",
"an.flags/sea.png")
#Protocol names
prots <- c("A1","B1","A2","B2","C1","C2")
#QR code for contacting
#qr <- c("contact/qr.png")
#Protocol depictions
pr.png <- c("protos/a1a2.png",
"protos/b1b2.png",
"protos/c1c2.png")
trend = c('<img src="trend/trend_up.png" height="24"></img>',
'<img src="trend/trend_down.png" height="24"></img>',
'<img src="trend/trend_stable.png" height="24"></img>')
#Colors for pie plot
co <- c(red = "#cd6960",
yel = "#f4d13b",
gre = "#afe68b",
tra = "#f0f0f0",
x = "#4c4c4c",
gra = "#a0a0a0")
#Function for generating pie plot
MyPie <- function(x){
piecol = co[flags %in% x]
ordered.flags = flags[match(x,flags)]
piex = c(table(ordered.flags))
piex = piex[match(flags,names(piex))] %>% na.omit()
piex = data.frame(value = piex,
group = factor(names(piex),levels = c('<img src="flags/red.png" height="24"></img>',
'<img src="flags/yel.png" height="24"></img>',
'<img src="flags/gre.png" height="24"></img>',
'<img src="flags/tra.png" height="24"></img>',
'<img src="flags/x.png" height="24"></img>',
'<img src="flags/gra.png" height="24"></img>')),
bar = 1)
ggplot(piex,aes(y = value, fill = factor(group), x = bar)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = as.vector(piecol)) +
coord_flip() +
theme_void() +
theme(legend.position = "none",
plot.margin = margin(24,0,0,0))
}
#Download information
download.guide.cc = c("<ul><li>date = The date of your query</li>
<li>mode = Your chosen mode of protocol recommendation</li>
<li>query = Substance classes from your query</li>
<li>stability thresholds [%] = Chosen (or default) stability thresholds</li>
<li>recommendation = Overall sampling protocol recommendation (please also see provided PDFs)</li>
<li>analyte = A list of analytes with their respective protocols</li>
<li>ref = References for the shown estimation</li></ul>")
download.guide.samp = c("<ul><li>date = The date of your query</li>
<li>query = Substance classes from your query</li>
<li>stability thresholds [%] = Chosen (or default) stability thresholds</li>
<li>time to centrifugation [min] = Sample processing delay between collection and centrifugation. Chosen value and it's analyte individual approximation by experimental data</li>
<li>time to freeze [min] = Sample processing delay between centrifugation and freezing. Chosen value and it's analyte individual approximation by experimental data</li>
<li>temp. (during time to centr.)[°C] = Sample processing temperature during time to centrifugation</li>
<li>temp. (during time to freeze)[°C] = Sample processing temperature during time to freeze</li>
<li>status = stability estimation corresponding to each analyte depending on the chosen conditions</li>
<li>ref = References for the shown estimation</li></ul>")
download.guide.samp.serum = c("<ul><li>date = The date of your query</li>
<li>query = Substance classes from your query</li>
<li>stability thresholds [%] = Chosen (or default) stability thresholds</li>
<li>time to centrifugation [min] = Sample processing delay between collection and centrifugation. Chosen value and it's analyte individual approximation by experimental data</li>
<li>time to freeze [min] = Sample processing delay between centrifugation and freezing. Chosen value and it's analyte individual approximation by experimental data</li>
<li>temp. (during time to freeze)[°C] = Sample processing temperature during time to freeze</li>
<li>status = stability estimation corresponding to each analyte depending on the chosen conditions</li>
<li>ref = References for the shown estimation</li></ul>")
download.guide.an = c("<ul><li>date = The date of your query</li>
<li>query = Analyte from your query<</li>
<li>centr_dur = Duration of centrifugation</li>
<li>stability thresholds [%] = Chosen (or default) stability thresholds</li>
<li>recommendation = Overall sampling protocol recommendation (please also see provided PDFs)</li>
<li>time to centrifugation [min] = Sample processing delay between collection and centrifugation. Chosen value and it's analyte individual approximation by experimental data</li>
<li>time to freeze [min] = Sample processing delay between centrifugation and freezing. Chosen value and it's analyte individual approximation by experimental data</li>
<li>temp. (during time to centr.)[°C] = Sample processing temperature during time to centrifugation</li>
<li>temp. (during time to freeze)[°C] = Sample processing temperature during time to freeze</li>
<li>status = stability estimation corresponding to each analyte depending on the chosen conditions</li>
<li>trend = Indicator of exceedance of stability thresholds under given condition (including direction)</li>
<li>ref = References for the shown estimation</li></ul>")
download.guide.an.serum = c("<ul><li>date = The date of your query</li>
<li>query = Analyte from your query<</li>
<li>centr_dur = Duration of centrifugation</li>
<li>stability thresholds [%] = Chosen (or default) stability thresholds</li>
<li>recommendation = Overall sampling protocol recommendation (please also see provided PDFs)</li>
<li>time to centrifugation [min] = Sample processing delay between collection and centrifugation. Chosen value and it's analyte individual approximation by experimental data</li>
<li>time to freeze [min] = Sample processing delay between centrifugation and freezing. Chosen value and it's analyte individual approximation by experimental data</li>
<li>temp. (during time to freeze)[°C] = Sample processing temperature during time to freeze</li>
<li>status = stability estimation corresponding to each analyte depending on the chosen conditions</li>
<li>trend = Indicator of exceedance of stability thresholds under given condition (including direction)</li>
<li>ref = References for the shown estimation</li></ul>")
impressum = c("<p>Fraunhofer-Institut für Translationale Medizin und Pharmakologie ITMP<br>
Theodor-Stern-Kai 7<br>
60596 Frankfurt a. M.<br>
Telefon: +49 69 6301-80231<br>
Fax: +49 69 6301-7617<br>
Email: info@itmp.fraunhofer.de<br>
www.itmp.fraunhofer.de<br>
ist eine rechtlich nicht selbständige Einrichtung der<br>
Fraunhofer-Gesellschaft zur Förderung der angewandten
Forschung e.V.<br>
Hansastraße 27 c<br>
80686 München<br>
Telefon: +49 89 1205-0<br>
Fax: +49 89 1205-7531<br>
www.fraunhofer.de</p>")
about = c("<p>ALISTER v1.0 was developed on R version 4.1.2 (2021-11-01) and shiny version 1.7.4 <br>
The code, including a detailed tutorial for the application are published under MIT license and publicly available under github.com/Fraunhofer-ITMP/alister.</pr>")
serum.guide = c("Pre-analytical data on serum stability is pretty sparse within our database right now. This is why we cant offer the
input for pre-analytical variation to be as flexible as in plasma search modes. We hope to include more data on serum
stability in the future.")
samp.pro = data.frame(centr = c(60,240,60,240,1440,1440),
freeze = c(60,240,60,240,120,120),
temp = c(0,0,21,21,0,21))
# Define UI for application that draws a histogram
ui <- fluidPage(
theme = shinytheme("paper"),
sidebarLayout(
sidebarPanel(
HTML('<center><img src="alister_akronym.png" height = "320"></center>'),
pickerInput("mtrx",h4(strong("Biomatrix")), choices = drops$val, choicesOpt = list(content = drops$img)),
uiOutput("mode"),
helpText("You can query the database for individual analytes (more detailed) or whole lipid & metabolite classes (for a broader overview)."),
tags$head(tags$style("
.jhr{
display: inline;
vertical-align: middle;
padding-left: 8px;
}")),
#Conditional Panel: Protocol search - Plasma====
conditionalPanel(condition = "input.mode == `Protocol search` & input.mtrx == `Plasma`",
multiInput("look_cc",
label = "Search compound classes",
choices = cc.class,
selected = "Oxylipins"),
actionButton("ab.clear.cc","Clear all"),
helpText("Select compound classes by clicking on the left and deselect by clicking on the right side."),
radioButtons("radio.cc.mode",
"",
choices = list("Maximize stable analytes" = 1,
"Majority vote" = 2),
selected = 2),
bsCollapse(bsCollapsePanel("Info",helpText("Depending on whether you want to maximize the number of analytes,
that are likely stable or just want to ensure, that most of the
measured analytes are stable different protocols might be suitable.
`Choose `Maximize stable analytes` in order to choose the strictes
of the protocols identified for your chosen compound class or choose
`Majority Vote` in order to choose the protocol, that is identified
most often."))),
checkboxInput("own.thresh.cc", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The lower
threshold poses as the critical cut-off for singular foldchanges (default is 20%). The upper
fold change is the critical cut-off for summed up fold changes (default is 30%)."),
uiOutput("own.t.cc"),
HTML('<center><img src="sym/pdf.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_protos_cl","Download"),align = "center"),
br(),
br(),
helpText("Download all of our sample handling protocols visualized as flow charts."),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_cl","Download"),align = "center"),
br(),
br(),
helpText("All information from your query can be downloaded in as a .csv-Table. Click below for a detailed description of the output variables."),
bsCollapse(bsCollapsePanel("Variable explanation",uiOutput("FeatList1", style = "info"))),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.cc", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.cc", style = "info")))
),
#Conditional Panel: Sample Search - Plasma====
conditionalPanel(condition = "input.mode == `Sample search` & input.mtrx == `Plasma`",
helpText("In this mode you can define the pre-analytical conditions, that are true for your samples. In additiona, when selecting a class, you will receive a recommendation based on the present presented data, as to whether compounds from the lipid class should still be considered for measurement."),
multiInput("look_samp",
label = "Search compound classes",
choices = plasma.mtrx,#as.list(sort(unique(an$an_class))),
selected = "Endocannabinoids & EC-like"),
fluidRow(
column(3,actionButton("ab.all","Select all")),
column(6,actionButton("ab.clear","Clear all"))
),
helpText("Select compound classes by clicking on the left and deselect by clicking on the right side."),
fluidRow(
#column(9,sliderInput("slide.temp", h5(strong("Temperature [°C]")), min = 0, max = 24, value = 0)),
h5(strong("Temperature [°C]")),
column(9,gaugeOutput("gauge.temp")),
column(3,numericInput("num.temp", "", min = 0, max = 24, value = 0))
),
uiOutput("help.sec.samp.1"),
checkboxInput("sec.temp.samp","Other temperature after centrifugation", value = F),
fluidRow(
#column(9,uiOutput("post.temp.samp.slide")),
column(9,uiOutput("gauge.post.temp.samp")),
column(3,uiOutput("post.temp.samp.num"))
),
uiOutput("help.sec.samp.2"),
helpText("Intermediate storing temperature during sample processing."),
fluidRow(
h5(strong("Delay until centrifugation [min]")),
#column(9, sliderInput("slide.time1", h5(strong("Delay until centrifugation [min]")), min = 1, max = 1440, value = 60)),
column(9,gaugeOutput("gauge.time1")),
column(3, numericInput("num.time1", "", min = 1, max = 1440, value = 60))
),
helpText("Average duration in sample processing between blood drawing and centrifugation."),
fluidRow(
h5(strong("Delay until final storage [min]")),
#column(9,sliderInput("slide.time2", h5(strong("Delay until final storage [min]")), min = 1, max = 240, value = 60)),
column(9,gaugeOutput("gauge.time2")),
column(3,numericInput("num.time2", "", min = 1, max = 240, value = 60))
),
helpText("Average duration in sample processing between centrifugation and transfer to deep freezer."),
checkboxInput("own.thresh.samp", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The lower
threshold poses as the critical cut-off for singular foldchanges (default is 20%). The upper
fold change is the critical cut-off for summed up fold changes (default is 30%)."),
uiOutput("own.t.samp"),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_s", label = "Download"),align = "center"),
br(),
br(),
helpText("All information from your query can be downloaded in as a .csv-Table. Click below for a detailed description of the output variables."),
bsCollapse(bsCollapsePanel("Variable explanation",uiOutput("FeatList2", style = "info"))),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.samp.p", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.samp", style = "info")))
),
#Conditional Panel: Analyte search - Plasma====
conditionalPanel(condition = "input.mode == `Analyte search` & input.mtrx == `Plasma`",
selectInput("look_an", h4(strong("Analyte")), choices = plasma.an, selected = 1),
helpText("Look up a specific analytes"),
#radioButtons("an.radio.tube", h5(strong("Blood sampling tube")), choices = list(c("K3EDTA"),c("GlucoExact"))),
helpText("Get stability information on your selected analyte by entering your sampling protocol below."),
fluidRow(
h5(strong("Temperature [°C]")),
#column(9,sliderInput("an.slide.temp", h5(strong("Temperature [°C]")), min = 0, max = 24, value = 0)),
column(9,gaugeOutput("an.gauge.temp")),
column(3,numericInput("an.num.temp", "", min = 0, max = 24, value = 0))
),
uiOutput("help.sec.an.1"),
checkboxInput("sec.temp.an","Other temperature after centrifugation", value = F),
fluidRow(
column(9,uiOutput("post.temp.an.gauge")),
#column(9,uiOutput("post.temp.an.slide")),
column(3,uiOutput("post.temp.an.num"))
),
uiOutput("help.sec.an.2"),
helpText("Intermediate storing temperature during sample processing."),
fluidRow(
h5(strong("Delay until centrifugation [min]")),
column(9,gaugeOutput("an.gauge.time1")),
#column(9, sliderInput("an.slide.time1", h5(strong("Delay until centrifugation [min]")), min = 1, max = 1440, value = 60)),
column(3, numericInput("an.num.time1", "", min = 1, max = 1440, value = 60))
),
helpText("Average duration in sample processing between blood drawing and centrifugation."),
fluidRow(
h5(strong("Delay until final storage [min]")),
column(9,gaugeOutput("an.gauge.time2")),
#column(9,sliderInput("an.slide.time2", h5(strong("Delay until final storage [min]")), min = 1, max = 240, value = 60)),
column(3,numericInput("an.num.time2", "", min = 1, max = 240, value = 60))
),
helpText("Average duration in sample processing between centrifugation and transfer to deep freezer."),
checkboxInput("own.thresh.an", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The lower
threshold poses as the critical cut-off for singular foldchanges (default is 20%). The upper
fold change is the critical cut-off for summed up fold changes (default is 30%)."),
uiOutput("own.t.an"),
HTML('<center><img src="sym/pdf.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_protos_an","Download"),align = "center"),
br(),
br(),
helpText("Download our sample handling protocols visualized as flow charts."),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_an","Download"),align = "center"),
br(),
br(),
helpText("All information that the results are based on can be downloaded in as a .csv-Table. Click below for a detailed description of the output variables."),
bsCollapse(bsCollapsePanel("Variable explanation",uiOutput("FeatList3", style = "info"))),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.an.p", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.an", style = "info")))
),
#Conditional Panel: Data filtering mode - Plasma====
conditionalPanel(condition = "input.mode == `Data filtering mode` & input.mtrx == `Plasma`",
h4(strong("Data filtering")),
helpText("In data filtering mode you are able to upload your own analysis results, enter your pre-analytical conditions and filter out potentially unstable analytes.
Your data is expected to have samples in rows and analytes in columns.
We will not store or analyze your measurements. When in doubt, you can even upload an empty table,
with just column names."),
fileInput("csvtable","Choose CSV-file for filtering",
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
radioButtons("sep","Separator",
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ","),
fluidRow(
h5(strong("Temperature [°C]")),
column(9,gaugeOutput("filt.gauge.temp")),
#column(9,sliderInput("filt.slide.temp", h5(strong("Temperature [°C]")), min = 0, max = 24, value = 0)),
column(3,numericInput("filt.num.temp", "", min = 0, max = 24, value = 0))
),
uiOutput("help.sec.filt.1"),
checkboxInput("sec.temp.filt","Other temperature after centrifugation", value = F),
fluidRow(
column(9,uiOutput("post.temp.filt.gauge")),
column(3,uiOutput("post.temp.filt.num"))
),
uiOutput("help.sec.filt.2"),
helpText("Intermediate storing temperature during sample processing."),
fluidRow(
h5(strong("Delay until centrifugation [min]")),
column(9,gaugeOutput("filt.gauge.time1")),
#column(9, sliderInput("filt.slide.time1", h5(strong("Delay until centrifugation [min]")), min = 1, max = 1440, value = 60)),
column(3, numericInput("filt.num.time1", "", min = 1, max = 1440, value = 60))
),
helpText("Average duration in sample processing between blood drawing and centrifugation."),
fluidRow(
h5(strong("Delay until final storage [min]")),
column(9,gaugeOutput("filt.gauge.time2")),
#column(9,sliderInput("filt.slide.time2", h5(strong("Delay until final storage [min]")), min = 1, max = 240, value = 60)),
column(3,numericInput("filt.num.time2", "", min = 1, max = 240, value = 60))
),
helpText("Average duration in sample processing between centrifugation and transfer to deep freezer."),
checkboxInput("own.thresh.filt", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The lower
threshold poses as the critical cut-off for singular foldchanges (default is 20%). The upper
fold change is the critical cut-off for summed up fold changes (default is 30%)."),
uiOutput("own.t.filt"),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_filt","Download"),align = "center"),
helpText("Your input will not be saved after your session has ended. It will also be not encrypted when uploaded on to the servers. Download your filtered data here"),
br(),
br(),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.filt.p", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.filt", style = "info")))
),
#Conditional Panel: Sample search - Serum====
conditionalPanel(condition = "input.mode == `Sample search` & input.mtrx == `Serum`",
helpText("In this mode you can define the preanalytical conditions, that are true for your samples. When selecting a class in addition, you will receive a recommendation based on the present data, on whether compounds from the lipid class should still be considered for measurement."),
helpText(serum.guide),
multiInput("look_samp_serum",
label = "Search compound classes",
choices = serum.mtrx,#as.list(sort(unique(an$an_class))),
selected = "Ceramides"),
fluidRow(
column(3,actionButton("ab.all_serum","Select all")),
column(6,actionButton("ab.clear_serum","Clear all"))
),
helpText("Select compound classes by clicking on the left and deselect by clicking on the right side."),
fluidRow(
h5(strong("Temperature [°C]")),
column(9,gaugeOutput("gauge.temp_serum")),
#column(9,sliderInput("slide.temp_serum", h5(strong("Temperature [°C]")), min = 0, max = 24, value = 21)),
column(3,numericInput("num.temp_serum", "", min = 0, max = 24, value = 21))
),
helpText("Intermediate storing temperature during clotting."),
fluidRow(
column(9,sliderTextInput("slide.time2_serum", h5(strong("Delay until final storage [min]")), choices = c(180,480,1440), selected = 1440, grid = T))
),
helpText("Average duration in sample processing between centrifugation and transfer to deep freezer."),
checkboxInput("own.thresh.samp_serum", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The selected
threshold is the maximum allowed fold change occuring in serum during post-centrifugation
processing delay (default is 20%)."),
uiOutput("own.t.samp_serum"),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_s_serum","Download"),align = "center"),
br(),
br(),
helpText("All information from your query can be downloaded in as a .csv-Table. Click below for a detailed description of the output variables."),
bsCollapse(bsCollapsePanel("Variable explanation",uiOutput("FeatList2_serum", style = "info"))),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.samp.s", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.samp.serum", style = "info")))
),
#Conditional Panel: Analyte search - Serum====
conditionalPanel(condition = "input.mode == `Analyte search` & input.mtrx == `Serum`",
selectInput("look_an_serum", h4(strong("Analyte")), choices = serum.an, selected = 1),
helpText("Looking up a specific analytes"),
#radioButtons("an.radio.tube", h5(strong("Blood sampling tube")), choices = list(c("K3EDTA"),c("GlucoExact"))),
helpText(serum.guide),
helpText("Get stability information on your selected analyte by entering your sampling protocol below."),
fluidRow(
h5(strong("Temperature [°C]")),
column(9,gaugeOutput("an.gauge.temp_serum")),
#column(9,sliderInput("an.slide.temp_serum", h5(strong("Temperature [°C]")), min = 0, max = 24, value = 21)),
column(3,numericInput("an.num.temp_serum", "", min = 0, max = 24, value = 21))
),
helpText("Intermediate storing temperature during clotting."),
fluidRow(
column(9,sliderTextInput("an.slide.time2_serum", h5(strong("Delay until final storage [min]")), choices = list(180,480,1440), selected = 1440, grid = T))
),
helpText("Average duration in sample processing between centrifugation and transfer to deep freezer."),
checkboxInput("own.thresh.an_serum", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The selected
threshold is the maximum allowed fold change occuring in serum during post-centrifugation
processing delay (default is 20%)."),
uiOutput("own.t.an_serum"),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_an_serum","Download"),align = "center"),
br(),
br(),
helpText("All information that the results are based on can be downloaded in as a .csv-Table. Click below for a detailed description of the output variables."),
bsCollapse(bsCollapsePanel("Variable explanation",uiOutput("FeatList3_serum", style = "info"))),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.an.s", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.an.serum", style = "info")))
),
#Conditional Panel: Data filtering mode - Serum====
conditionalPanel(condition = "input.mode == `Data filtering mode` & input.mtrx == `Serum`",
h4(strong("Data filtering")),
helpText("In data filtering mode you are able to upload your own analysis results, enter your pre-analytical conditions and filter out potentially unstable analytes.
Your data is expected to have samples in rows and analytes in columns.
We will not store or analyze your measurements. When in doubt, you can even upload an empty table,
with just column names."),
helpText(serum.guide),
fileInput("csvtable_serum","Choose CSV-file for filtering",
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
radioButtons("sep_serum","Separator",
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ","),
fluidRow(
h5(strong("Temperature [°C]")),
column(9,gaugeOutput("filt.gauge.temp_serum")),
#column(9,sliderInput("filt.slide.temp_serum", h5(strong("Temperature [°C]")), min = 0, max = 24, value = 21)),
column(3,numericInput("filt.num.temp_serum","",min = 0, max = 24, value = 21))
),
helpText("Intermediate storing temperature during clotting."),
fluidRow(
column(9,sliderTextInput("filt.slide.time2_serum", h5(strong("Delay until final storage [min]")), choices = list(180,480,1440), selected = 1440, grid = T))
),
helpText("Average duration in sample processing between centrifugation and transfer to deep freezer."),
checkboxInput("own.thresh.filt_serum", "Define individual stability thresholds", value = FALSE),
helpText("ALISTER defines stability by setting cut-offs for fold changes specific
to analytes subjected to certain pre-analytical conditions. The selected
threshold is the maximum allowed fold change occuring in serum during post-centrifugation
processing delay (default is 20%)."),
uiOutput("own.t.filt_serum"),
HTML('<center><img src="sym/csv.png" height = "90" width="90"></center>'),
column(12,downloadButton("download_filt_serum","Download"),align = "center"),
helpText("Your input will not be saved after your session has ended. It will also be not encrypted when uploaded on to the servers. Download your filtered data here"),
br(),
br(),
bsCollapse(bsCollapsePanel("Publishing Notes",uiOutput("imp.filt.s", style = "info"))),
bsCollapse(bsCollapsePanel("About",uiOutput("about.filt.serum", style = "info")))
)
),
mainPanel(h1(strong("Results"), align = "left"),
modalDialog(
HTML('<center><img src="limits/stamp.png" height = "160" width="160"></center>'),
tags$div(#tags$br(),
h4("Disclaimer",align = "center"),
tags$br(),
"We cannot assume any liability for the content of external pages. The operators of those linked pages are solely responsible for their content.",
tags$br(),
tags$br(),
"We make every reasonable effort to ensure that the content of this Web site is kept up to date, and that it is accurate and complete. Nevertheless, the possibility of errors cannot be entirely ruled out. We do not give any warranty in respect of the timeliness,
accuracy or completeness of material published on this Web site, and disclaim all liability for (material or non-material) loss or damage incurred by third parties arising from the use of content obtained from the Web site.",
tags$br(),
tags$br(),
"Registered trademarks and proprietary names, and copyrighted text and images, are not generally indicated as such on our Web pages. But the absence of such indications in no way implies that these names,
images or text belong to the public domain in the context of trademark or copyright law."),
size = "l",
easyClose = FALSE,
footer = modalButton("Agree")
),
#Main Panel: Protocol search - Plasma====
conditionalPanel(
condition = "input.mode == `Protocol search` & input.mtrx == `Plasma`",
h4(textOutput("text.cl")),
textOutput("pr"),
br(),
uiOutput("downpr_cc"),
bsModal("popup_cc","Recommended protocol","downpr_cc", uiOutput("show.prot.cc")),
br(),
dataTableOutput("clt"),
br(),
bsCollapse(bsCollapsePanel("Citation",dataTableOutput("cl.ref"))),
fluidRow(
column(4,img(src='leg/legcc.PNG', height = "200", align = "left")),
column(6,plotOutput("cc.pie", height = "150",width = "450"))
)
),
#Main Panel: Sample search - Plasma====
conditionalPanel(
condition = "input.mode == `Sample search` & input.mtrx == `Plasma`",
h4(textOutput("pr.s")),
br(),
helpText("If experimental data from our data base do not exactly match the conditions you entered,\nthe conditions most close to your entry are considered.\nYou can hover your mouse over each row in order to see this approximation."),
textOutput("inter.time1"),
br(),
dataTableOutput("con_s"),
br(),
bsCollapse(bsCollapsePanel("Citation",dataTableOutput("samp.ref"))),
fluidRow(
column(4,HTML('<center><img src="leg/legsamps.PNG" height = "220"></center>')),
column(8,plotOutput("samp.pie", height = "75",width = "450"))
)
),
#Main Panel: Analyte search - Plasma====
conditionalPanel(
condition = "input.mode == `Analyte search` & input.mtrx == `Plasma`",
h3(textOutput("text.an")),
fluidRow(
column(12,uiOutput("own.prot.an.sym"),
column(9,
strong(h4("General protocol recommendation")),
textOutput("an.rec"),
br(),
uiOutput("downpr_an"),
bsModal("popup_an","Recommended protocol","downpr_an", uiOutput("show.prot.an")),
strong(h4("Assessment of your protocol")),
textOutput("prot.an.rec"),
helpText("If experimental data from our data base do not exactly match the conditions you entered,\nthe conditions most close to your entry are considered.\nYou can click on `Details` below in order to see the data used in this approximation."),
)
)
),
br(),
bsCollapse(bsCollapsePanel("Details", dataTableOutput("an.detail")),
bsCollapsePanel("Citation", dataTableOutput("an.ref")))
),
#Main Panel: Data filtering mode - Plasma====
conditionalPanel(
condition = "input.mode == `Data filtering mode` & input.mtrx == `Plasma`",
helpText("In this panel your data will be analyzed in real time and metabolite stability will be assessed depending on the pre-analytical conditions you entered. If experimental data from our data base do not exactly match the conditions you entered,\nthe conditions most close to your entry are considered.\nYou can hover your mouse over each row in order to see this approximation."),
strong(textOutput("upload.status")),
dataTableOutput("csvfilt"),
bsCollapse(bsCollapsePanel("Citation",dataTableOutput("filt.ref"))),
fluidRow(
column(4,img(src='leg/legfilt.PNG', height = "200", align = "left")),
column(8,plotOutput("filt.pie", height = "75",width = "450"))
)
),
#Main Panel: Sample search - Serum====
conditionalPanel(
condition = "input.mode == `Sample search` & input.mtrx == `Serum`",
h4(textOutput("pr.s_serum")),
br(),
helpText("If experimental data from our data base do not exactly match the conditions you entered,\nthe conditions most close to your entry are considered.\nYou can hover your mouse over each row in order to see this approximation."),
br(),
dataTableOutput("con_s_serum"),
br(),
bsCollapse(bsCollapsePanel("Citation",dataTableOutput("samp.ref_serum"))),
fluidRow(
column(4,img(src='leg/legsamps2.PNG', height = "200", align = "left")),
column(8,plotOutput("samp.pie_serum", height = "75",width = "450")),
)
),
#Main Panel: Analyte search - Serum====
conditionalPanel(
condition = "input.mode == `Analyte search` & input.mtrx == `Serum`",
h3(textOutput("text.an_serum")),
fluidRow(
column(12,uiOutput("own.prot.an.sym_serum"),
column(9,
strong(h4("Assessment of your protocol")),
textOutput("prot.an.rec_serum"),
helpText("If experimental data from our data base do not exactly match the conditions you entered,\nthe conditions most close to your entry are considered.\nYou can click on `Details` below in order to see the data used in this approximation.")))
),
br(),
bsCollapse(bsCollapsePanel("Details", dataTableOutput("an.detail_serum")),
bsCollapsePanel("Citation", dataTableOutput("an.ref_serum")))
),
#Main Panel: Data filtering mode - Serum====
conditionalPanel(
condition = "input.mode == `Data filtering mode` & input.mtrx == `Serum`",
helpText("In this panel your data will be analyzed in real time and metabolite stability will be assessed depending on the pre-analytical conditions you entered.
A version of your dataset, where unstable analytes were filtered out can be accessed by clicking on `Download` to the left. If experimental data from our data base do not exactly match the conditions you entered,\nthe conditions most close to your entry are considered.\nYou can hover your mouse over each row in order to see this approximation."),
strong(textOutput("upload.status_serum")),
dataTableOutput("csvfilt_serum"),
bsCollapse(bsCollapsePanel("Citation",dataTableOutput("filt.ref_serum"))),
fluidRow(
column(4,img(src='leg/legfilt2.PNG', height = "200", align = "left")),
column(8,plotOutput("filt.pie_serum", height = "75",width = "450"))
)
),
)
)
)
server <- function(input, output, session) {
#Sidebar Info====
output$FeatList1 <- renderUI(HTML(download.guide.cc))
output$FeatList2 <- renderUI(HTML(download.guide.samp))
output$FeatList3 <- renderUI(HTML(download.guide.an))
output$FeatList2_serum <- renderUI(HTML(download.guide.samp.serum))
output$FeatList3_serum <- renderUI(HTML(download.guide.an.serum))
output$imp.cc <- renderUI(HTML(impressum))
output$imp.samp.p <- renderUI(HTML(impressum))
output$imp.an.p <- renderUI(HTML(impressum))
output$imp.filt.p <- renderUI(HTML(impressum))
output$imp.samp.s <- renderUI(HTML(impressum))
output$imp.an.s <- renderUI(HTML(impressum))
output$imp.filt.s <- renderUI(HTML(impressum))
output$about.cc <- renderUI(HTML(about))
output$about.samp <- renderUI(HTML(about))
output$about.an <- renderUI(HTML(about))
output$about.filt <- renderUI(HTML(about))
output$about.samp.serum <- renderUI(HTML(about))
output$about.an.serum <- renderUI(HTML(about))
output$about.filt.serum <- renderUI(HTML(about))
output$mode <- renderUI({
if (input$mtrx == "Plasma"){
selectInput("mode",
h5(strong("Search mode")),
choices = list(c("Sample search"),
c("Analyte search"),
c("Data filtering mode"),
c("Protocol search")),
selected = 1)
} else if (input$mtrx == "Serum"){
selectInput("mode",
h3(strong("Search mode")),
choices = list(c("Sample search"),
c("Analyte search"),
c("Data filtering mode")),
selected = 1)
}
})
# Protocol search - Plasma####
output$own.t.cc <- renderUI({
req(input$own.thresh.cc == TRUE)
sliderInput("own.t.cc",
h5(strong("Stability Threshold [%]")),
min = 0,
max = 100,
step = 5,
value = c(20,30))
})
mult_names_cc <- reactive({
names <- input$look_cc
if (length(names) > 1){
names <- paste("Currently looking at", paste(names, collapse = ", "))
} else if (length(names) == 1){
names <- paste("Currently looking at", names)
} else {
names <- c()
}
return(names)
})
output$text.cl <- renderText({mult_names_cc()})
rv.multi.cc = reactiveValues(data = NULL)
observeEvent(input$ab.clear.cc,{
rv.multi.cc$data = character(0)
})
observeEvent(input$ab.clear.cc,{
updateMultiInput(session = session,
inputId = "look_cc",
selected = rv.multi.cc$data)
})
mult_class <- reactive({
if(is.null(input$look_cc)){
cl <- NA
} else {
lookup <- input$look_cc
cl_list = lapply(lookup,function(x){return(an[which(an[,3] %in% x[1]),1])})
cl <- unlist(cl_list)
}
return(cl)
})
#anincl is a list of analytes from the queried class (FC/Prean)
#exp_wise calculated the foldchanges
#p.tests look up the fitting protocol and stores the results in p.rec (transformed to output table)
#not.p finds analytes, that do not conform with chosen protocol and gives them a yellow flag
#main.p gives a statement of which protocol is recommended
tab_class <- reactive({
if(is.null(input$look_cc)){
p.rec <- data.frame(protocol = NA, status = NA)
} else {
#Load list with analyte ids
cl <- mult_class()
all_cl <- cc.fc[which(!is.na(match(cc.fc$an_id,cl))),]
all_con <- con[unique(match(all_cl$prean_id,con$prean_id)),]
all_con <- all_con[all_con$matrix == "Plasma",]
all_con$prean_temp = cut(all_con$prean_temp, breaks = c(-Inf,8,16,Inf), labels = c(0,NA,21))
all_con = subset(all_con, `blood_tube` == "K3EDTA")
all_cl <- all_cl[all_cl$prean_id %in% all_con$prean_id,]
## Define stability thresholds----
if(input$own.thresh.cc == TRUE){
thresh1 = input$own.t.cc[1]/100
thresh2.1 = 1-input$own.t.cc[2]/100
thresh2.2 = 1+input$own.t.cc[2]/100
} else {
thresh1 = 0.2
thresh2.1 = 0.7
thresh2.2 = 1.3
}
uni.an = as.list(unique(all_cl$an_name))
uni.ind = lapply(uni.an,function(x){all_cl[which(all_cl$an_name %in% x),]})
uni.ind = lapply(uni.ind,function(x){return(x[unique(match(unique(x$prean_id),x$prean_id)),])})
uni.con = lapply(uni.ind,function(x){all_con[which(all_con$prean_id %in% x$prean_id),]})
names(uni.ind) = unlist(uni.an)
names(uni.con) = unlist(uni.an)
uni.exp = lapply(uni.con,function(x){as.list(unique(x$exp_id))})
uni.prot = lapply(seq_along(uni.con),function(i){
lapply(seq_along(uni.exp[[i]]),function(j){
time.to.centr = uni.con[[i]][which((uni.con[[i]]$exp_id == uni.exp[[i]][[j]])&(uni.con[[i]]$centr_time>0)),]
time.to.freeze = uni.con[[i]][which((uni.con[[i]]$exp_id == uni.exp[[i]][[j]])&(uni.con[[i]]$freeze_time>0)),]
return(list(time.to.centr = time.to.centr,
time.to.freeze = time.to.freeze))
})
})
names(uni.prot) = unlist(uni.an)
#Any missing conditions?
any.na = lapply(uni.prot,function(x){lapply(x,function(y){lapply(y,function(z){return(nrow(z)>0)})})})
any.na = lapply(any.na,function(x){lapply(x,function(y){any(!unlist(y))})})
#all.na = lapply(any.na,function(x){all(!unlist(x))}) %>% unlist() %>% which()
#Clear experiments,that dont contribute to assessment
if(any(unlist(any.na))){
uni.prot = lapply(seq_along(uni.prot),function(i){return(uni.prot[[i]][-which(unlist(any.na[[i]]))])})
}
all.na = sapply(uni.prot,function(x){length(x) == 0}) %>% which()
#Clear analytes, with insufficient data (no data at all)
if(length(all.na) > 0){
na.ind = uni.ind[all.na]
rem.ind = uni.ind[-all.na]
rem.prot = uni.prot[-all.na]
} else {
na.ind = NULL
rem.ind = uni.ind
rem.prot = uni.prot
}
names(rem.prot) = names(rem.ind)
exact.prot = lapply(rem.prot,function(x){
lapply(x,function(y){
ttc = merge(samp.pro,y[[1]],by.y = c("centr_time","prean_temp"),by.x = c("centr","temp"),all.x = T, sort = T);
ttc = ttc[order(ttc$centr),];
ttf = merge(samp.pro,y[[2]],by.y = c("freeze_time","prean_temp"),by.x = c("freeze","temp"),all.x = T);
ttf = ttf[order(ttf$centr),];
return(list(centr.fc = ttc,freeze.fc = ttf))
})
})
#Obtain pre-analytical conditions for protocol construction
fc.prot = lapply(seq_along(exact.prot),function(i){
lapply(seq_along(exact.prot[[i]]),function(j){
ttc.fc = merge(exact.prot[[i]][[j]]$centr.fc,rem.ind[[i]],by = "prean_id", all.x = T);
ttc.fc = ttc.fc[order(ttc.fc$centr),];
ttf.fc = merge(exact.prot[[i]][[j]]$freeze.fc,rem.ind[[i]],by = "prean_id", all.x = T);
ttf.fc = ttf.fc[order(ttf.fc$centr),];
return(list(ttc.fc = ttc.fc, ttf.fc = ttf.fc))
})
})
#Obtain references
fc.prot.ref = lapply(seq_along(fc.prot),function(i){
x = lapply(seq_along(fc.prot[[i]]),function(j){
expid = fc.prot[[i]][[j]]$ttc.fc$exp_id %>% na.omit %>% unique
return(expid)
})
y = paste(x,collapse = ",")
return(y)
})
#Construct data.frame with fold changes needed for protocol assessment
df.prot = lapply(fc.prot,function(x){
lapply(x,function(y){
prot.df = data.frame(centr = y[[1]]$fc, freeze = y[[2]]$fc)
return(prot.df)
})
})
#Test for thresholds
df.test = lapply(df.prot,function(x){
lapply(x,function(y){
z = abs(y-1);
sum.z = abs(rowSums(y)-1);
#In the following tests surpassing the thresholds results in TRUE
test.z = rowSums(z>0.2) %>% as.logical();
test.sum.z = sum.z<thresh2.1 | sum.z>thresh2.2;
z = test.z|test.sum.z;
})
})
vec.test = lapply(df.test,function(x){
z = lapply(x,function(y){
a = which(y)
b = which(!y)
if(length(a)<1 & length(b)<1){
c = 0
} else if(length(a)<1 & length(b)>=1){
c = max(b,na.rm = T)
} else if(length(a)>=1){
c = min(a,na.rm = T)-1
}
return(c)
})
return(z)
})
df.test = lapply(seq_along(vec.test),function(i){
min.red = Reduce(min,vec.test[[i]])
ident.red = Reduce(identical,vec.test[[i]])
df = data.frame(analyte = names(rem.prot)[i],
protocol = if(min.red == 0){
"A1"
}else{
prots[min.red]
},
status = if(min.red == 0){
"<img src=\"flags/x.png\" height=\"24\"></img>"
}else if(ident.red){
"<img src=\"flags/gre.png\" height=\"24\"></img>"
}else{
"<img src=\"flags/yel.png\" height=\"24\"></img>"
})
})
p.rec = do.call(rbind,df.test) %>% as.data.frame()
p.rec$reference = fc.prot.ref
p.rec = p.rec[order(p.rec$analyte),]
#Add red flags in case of majority vote
if(input$radio.cc.mode == 2){
most.p = names(table(p.rec$protocol))[which.max(table(p.rec$protocol))]
not.p = prots[-c(grep(most.p,prots):6)]
never.p = grep("x",p.rec$status)
p.rec$status[which(!is.na(match(p.rec$protocol,not.p)))] <- flags[1]
#Add black flags back in
p.rec$status[never.p] = flags[5]
}
return(p.rec)
}
})
#Table rendering
output$clt <- renderDataTable({datatable(tab_class(), escape = F, rownames = F)})
#Text output for cc search (plasma)
class_prot <- reactive({
if(is.null(input$look_cc)){
main.p <- c("Please select at least one analyte group")
} else {
p.rec <- tab_class()
if(input$radio.cc.mode == 2){
sort.p <- names(table(p.rec$protocol))[which.max(table(p.rec$protocol))]
if(length(sort.p) > 0){
main.p <- paste("Your query is run in `Majority Vote`-Mode. When analyzing all samples, this results in protocol ", sort.p,".", sep = "")
} else {
main.p <- c("Based on the present data we cant give you specific sample processing recommendations. We suggest to inspect detailed stability data on your analytes of interest using the `Analyte Search`.")
}
} else if (input$radio.cc.mode == 1){
sort.p <- names(table(p.rec$protocol))
if(length(sort.p) > 0){
sort.p <- prots[min(match(sort.p,prots))]
main.p <- paste("Your query is run in `Maximize stable analytes`-mode. When analyzing all samples, this results in protocol ", sort.p,".", sep = "")
} else {
main.p <- c("Based on the present data we cant give you specific sample processing recommendations. We suggest to inspect detailed stability data on your analytes of interest using the `Analyte Search`.")
}
}
}
return(main.p)
})
#Text rendering
output$pr <- renderText({class_prot()})
#Plot generation
cc.plot <- reactive({
p.rec <- tab_class()
if(!is.null(input$look_cc)){
MyPie(p.rec$status)
} else {
MyPie(flags[4])
}
})
#Plot rendering
output$cc.pie <- renderPlot({cc.plot()})
#PDF popup generation
which.prot.cc <- reactive({
if(!is.null(input$look_cc)){
p.rec <- tab_class()
if(input$radio.cc.mode == 2){
sort.p <- names(table(p.rec$protocol))[which.max(table(p.rec$protocol))]
if(length(sort.p) > 0){
if(sort.p == "A1"|sort.p == "A2"){
wpcc <- pr.png[1]
} else if (sort.p == "B1"|sort.p == "B2"){
wpcc <- pr.png[2]
} else {
wpcc <- pr.png[3]
}
}
} else if (input$radio.cc.mode == 1){
sort.p <- names(table(p.rec$protocol))