-
Notifications
You must be signed in to change notification settings - Fork 0
/
knitr_report.Rmd
executable file
·694 lines (379 loc) · 30.7 KB
/
knitr_report.Rmd
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
---
title: "Biological Variation Report for `r input$analyte`"
always_allow_html: yes
output: pdf_document
---
```{r hello-random, echo=FALSE}
pxtablek <- function(x, ...) {
if(class(x)=='list'){
print(xtable::xtable(x[[1]], digits=x$digits, caption=paste('</br>',x$caption) ),type='html', ...)
}else{
print(xtable::xtable(x),type='html', ...)
}
}
opts_chunk$set(echo=FALSE, results='asis',fig.path='tempFiguresForKnitrReport/', fig.width=9, fig.height=7)
```
This report was created using the **BV** tool for analyzing biological variation data. **BV** is developed by **Turcosa Analytics** and can be accessed online at http://opensoft.turcosa.com.tr/BioVar/
Additional documentation for the **BV**, including instructions on how to download the application for offline use, can be found at https://github.com/selcukorkmaz/BioVar
# Introduction
The steps of analyzing the BV data can be divided into seven steps: (i) detecting outliers, (ii) controlling normality assumption, (iii) checking steady-state condition, (iv) checking homogeneity assumptions, (v) performing subset analysis for genders, (vi) performing analysis of variance and (vii) identifying analytical performance specifications. Here, we presented an online tool for the statistical analysis of the BV data based on guideline by Bartlett et al. (2015), the pipeline by Braga and Panteghini (2016) and the updated checklist by Aarsand et al. (2018).
Bartlett WA, Braga F, Carobene A, Coskun A, Prusa R, et al. A checklist for critical appraisal of studies of biological variation. Clin Chem Lab Med 2015; 53(6):879-85.
Braga F, Panteghini M. Generation of data on within-subject biological variation in laboratory medicine: An update. Crit Rev Clin Lab Sci 2016; 53(5):313-25.
Aarsand AK, Roraas T, Fernandez-Calle P, Ricos C, Diaz-Garzon J, et al. The Biological Variation Data Critical Appraisal Checklist: A Standard for Evaluating Studies on Biological Variation. Clin Chem 2018; 64(3):501-14.
Here are the abbreviations we used in this report:
**CV:** coefficient of variation
**CVA:** analytical CV
**CVI:** within CV
**CVG:** between CV
**II:** index of individuality
**RCV:** reference change values
*******
# 1. Outlier Detection
It is recommended that outlier detection should be performed using Cochran’s test and Reed’s criterion in three steps:
Step 1: Use the Cochran’s test to check outliers among replicates.
## 1.1. Table 1: Outliers in the sets of duplicate results using the Cochran test
```{r}
DT::datatable(outlierResults()[[1]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list(dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
*******
Step 2: Use the Cochran’s test to determine whether a subject distribution was greater or smaller than those of the group as a whole.
## 1.2. Table 2: Outliers in the variances of the results from each subject using the Cochran test
```{r}
DT::datatable(outlierResults()[[2]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
*******
Step 3: Use the Reed’s criterion to determine whether mean value of any subject is significantly greater or smaller compared to other subjects.
## 1.3 Table 3: Outliers in the variances of the results from each subject using the Cochran test
```{r}
DT::datatable(outlierResults()[[3]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
*******
# Normality Test
The Shapiro-Wilk test is one of the most widely used and powerful tests for checking normality assumption.
The normality control should be performed in two steps:
Step 1: The normality of each measurand
## 2.1. Table 1: On set of results from each individual
```{r}
DT::datatable(normalityResults()[[1]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
Step 2: The normality of mean values of all subjects
## 2.2. Table 2: On mean values of subjects
```{r}
DT::datatable(normalityResults()[[2]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
# 3. Steady-State
Subjects is considered in the steady-state, if the 95% confidence interval of the slope of the regression line contains 0.
## 3.1. Table 1: Linear regression result
```{r}
DT::datatable(steadyStateResult(), extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
# 4. Homogeneity
The homogeneity of within-subject and analytical variability should be checked using the Bartlett test.
## 4.1. Table 1: Homogeneity of analytical variability
```{r}
res = homogeneityAnalytical(dataSetWithoutOutliers(), subject = "subject", time = "time", replicate="replicate", alpha = input$alphaLevel, decimal = input$decimal, correction = TRUE, test = input$homogeneityTest)
DT::datatable(res, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
## 4.2. Table 2: Homogeneity of within-subject variability
```{r}
res = homogeneityWithin(dataSetWithoutOutliers(), subject = "subject", time = "time", replicate="replicate", alpha = input$alphaLevel, decimal = input$decimal, correction = TRUE , test = input$homogeneityTest)
DT::datatable(res, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
# 5. Subset Analysis
The significant differences in the CVI and CVG between gender groups (i.e. female and male) must be controlled in order to determine whether the estimates should be reported separately for genders. If the 95% confidence intervals of CVI and CVG overlap between genders, then, it is concluded that there is no significant differences between gender groups. Therefore, all-subjects results should be reported for CVI and CVG. In the case of non-overlapping confidence intervals, the results of CVI and CVG should be reported separately for each gender.
## 5.1. Table 1: Gender comparison for between-subject variation
```{r}
DT::datatable(subsetCVResults()[[1]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
## 5.2. Table 2: Gender comparison for within-subject variation
```{r}
DT::datatable(subsetCVResults()[[2]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
## 5.3. Table 3: Student's t test for mean differences of gender groups
```{r}
DT::datatable(subsetResults()[[2]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
The differences between mean values of genders can be compared using a Student t test. If there is no significant difference between mean values of males and females, all-subjects CVI and all-subjects CVG are used to calculate the analytical performance specifications . In the case of the significant difference between mean values of genders, the lowest of the two CVG estimate is used to calculate the analytical performance specifications
## 3.4. Table 4: Homogeneity test for average within-subject total variance
```{r}
DT::datatable(subsetResults()[[3]], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
```
# 6. Analysis of Variance
## 6.1. All subjects
### 6.1.1. Table 1: Reference Change Values (RCV) Results
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsAllOriginalLme$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && (input$showResult == "cv" || input$showResult == "mom" || input$showResult == "lnmom")){
result = DT::datatable(res$resultsAllCvAnova$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsAllTransformBackLnLme$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.1.2. Table 2: Mean and associated confidence interval of the measurand, index of individuality (II) and the number of samples (n)
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsAllOriginalLme$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsAllCvAnova$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsAllTransformBackLnLme$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.1.3. Table 3: Analysis of Variance Table
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsAllOriginalLme$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsAllCvAnova$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsAllTransformBackLnLme$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.1.4. Table 4: Analytical performance specifications
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsAllOriginalLme$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsAllCvAnova$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsAllTransformBackLnLme$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
## 6.2. Gender 1
### 6.2.1. Table 1: Reference Change Values (RCV) Results
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme1$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && (input$showResult == "cv" || input$showResult == "mom" || input$showResult == "lnmom")){
result = DT::datatable(res$resultsCvAnovaGender1$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme1$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.2.2. Table 2: Mean and associated confidence interval of the measurand, index of individuality (II) and the number of samples (n)
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme1$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsCvAnovaGender1$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme1$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.2.3. Table 3: Analysis of variance table
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme1$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsCvAnovaGender1$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme1$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.2.4. Table 4: Analytical performance specifications
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme1$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsCvAnovaGender1$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme1$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
## 6.3. Gender 2
### 6.3.1. Table 1: Reference Change Values (RCV) Results
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme2$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && (input$showResult == "cv" || input$showResult == "mom" || input$showResult == "lnmom")){
result = DT::datatable(res$resultsCvAnovaGender2$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme2$rcvResult, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.3.1. Mean and associated confidence interval of the measurand, index of individuality (II) and the number of samples (n)
```{r}
result = res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme2$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsCvAnovaGender2$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme2$CVresults[c(1:4,8,9)], extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.3.2. Table 3: Analysis of variance table
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme2$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsCvAnovaGender2$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme2$CVTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
### 6.3.3. Table 4: Analytical performance specifications
```{r}
res = analysisOfVarinceResults()
if(input$run && (input$showResult == "original" || input$showResult == "lnTransformed")){
result = DT::datatable(res$resultsOriginalGenderLme2$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "cv"){
result = DT::datatable(res$resultsCvAnovaGender2$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
if(input$run && input$showResult == "transformBack"){
result = DT::datatable(res$resultsTransformBackGenderLnLme2$errorTable, extensions = c('Buttons','KeyTable', 'Responsive'), options = list( dom = 'Bfrtip',buttons = list('copy', 'print', list(extend = 'collection', buttons = c('csv', 'excel', 'pdf'),text = 'Download')), keys = TRUE))
}
result
```
# 7. Plots
## Figure 1: Mean and absolute range plot before outlier detection
```{r}
data = dataAnalysis()
data$replicate.subject = as.numeric(paste0(data[,input$replicate], data[,input$subject]))
names = c(input$subject, input$gender, input$time, input$replicate, "replicate.subject", input$analyte)
dataFull = data[,names]
names(dataFull)[6] = "value"
dataFull = dataFull[complete.cases(dataFull),]
dataFull[dataFull$value <=0,"value"] = NA
dataFull = dataFull[complete.cases(dataFull),]
tbl = table(dataFull$subject)
naSubject = tbl[!(tbl%%2==0)]
naSubject2 = as.numeric(names(naSubject))
if(length(naSubject2) >0){
for(i in 1:length(naSubject2)){
nas3 = dataFull[dataFull$subject == naSubject2[i],]
tbl2 = table(nas3$time)
nas4 = tbl2[!(tbl2%%2==0)]
nas5 = as.numeric(names(nas4))
for(j in 1:length(nas5)){
dataFull[dataFull[,input$subject] == naSubject2[i] & dataFull[,input$time] == nas5[j],"value"] = NA
}
}
}
dataFull = dataFull[complete.cases(dataFull),]
dataFull = dataFull[with(dataFull, order(eval(parse(text=input$gender)))), ]
data_grp <- eval(substitute(group_by(dataFull, eval(parse(text=input$subject)))))
plotData <- dplyr::summarise(data_grp, N = n(), Mean = mean(value), Min = min(value), Max = max(value))
colnames(plotData)[1] = input$subject
gender = as.data.frame(data_grp[,c(input$subject, input$gender)][!duplicated(data_grp[,c(input$subject, input$gender)]), ])
plotData = merge(plotData, gender, by = input$subject)
plotData[,input$subject] <- as.factor(plotData[,input$subject])
plotData = plotData[with(plotData, order(eval(parse(text=input$gender)))), ]
p = ggplot(plotData, aes_string(y = "Mean", x =input$subject, color = input$gender)) +
geom_point() +
geom_errorbar(aes(ymax = Max, ymin = Min), width = 0.35) +
coord_flip() +
theme_bw(base_size = 14) +
ylab(input$analyte) +
xlab("Subjects")+
scale_x_discrete(limits=plotData[,input$subject])
p
```
## Figure 2: Mean and absolute range plot after step 1 outlier detection
```{r}
data = outlierResults()[[5]]
names = c(input$subject, input$gender, input$time, input$replicate, "replicate.subject", "value")
dataFull = data[,names]
data_grp <- eval(substitute(group_by(dataFull, eval(parse(text=input$subject)))))
plotData <- dplyr::summarise(data_grp, N = n(), Mean = mean(value), Min = min(value), Max = max(value))
colnames(plotData)[1] = input$subject
gender = as.data.frame(data_grp[,c(input$subject, input$gender)][!duplicated(data_grp[,c(input$subject, input$gender)]), ])
plotData = merge(plotData, gender, by = input$subject)
plotData[,input$subject] <- as.factor(plotData[,input$subject])
plotData = plotData[with(plotData, order(eval(parse(text=input$gender)))), ]
ggplot(plotData, aes_string(y = "Mean", x =input$subject, color = input$gender)) +
geom_point() +
geom_errorbar(aes(ymax = Max, ymin = Min), width = 0.35) +
coord_flip() +
theme_bw(base_size = 14) +
ylab(input$analyte) +
xlab("Subjects")+
scale_x_discrete(limits=plotData[,input$subject])
```
## Figure 3: Mean and absolute range plot after step 1 outlier detection
```{r}
data = outlierResults()[[6]]
names = c(input$subject, input$gender, input$time, input$replicate, "replicate.subject", "value")
dataFull = data[,names]
data_grp <- eval(substitute(group_by(dataFull, eval(parse(text=input$subject)))))
plotData <- dplyr::summarise(data_grp, N = n(), Mean = mean(value), Min = min(value), Max = max(value))
colnames(plotData)[1] = input$subject
gender = as.data.frame(data_grp[,c(input$subject, input$gender)][!duplicated(data_grp[,c(input$subject, input$gender)]), ])
plotData = merge(plotData, gender, by = input$subject)
plotData[,input$subject] <- as.factor(plotData[,input$subject])
plotData = plotData[with(plotData, order(eval(parse(text=input$gender)))), ]
ggplot(plotData, aes_string(y = "Mean", x =input$subject, color = input$gender)) +
geom_point() +
geom_errorbar(aes(ymax = Max, ymin = Min), width = 0.35) +
coord_flip() +
theme_bw(base_size = 14) +
ylab(input$analyte) +
xlab("Subjects")+
scale_x_discrete(limits=plotData[,input$subject])
```
## Figure 4: Mean and absolute range plot after step 3 outlier detection
```{r}
data = outlierResults()[[4]]
names(data) = c(input$subject, input$gender, input$time, input$replicate, "replicate.subject", "value")
dataFull = data
data_grp <- eval(substitute(group_by(dataFull, eval(parse(text=input$subject)))))
plotData <- dplyr::summarise(data_grp, N = n(), Mean = mean(value), Min = min(value), Max = max(value))
colnames(plotData)[1] = input$subject
gender = as.data.frame(data_grp[,c(input$subject, input$gender)][!duplicated(data_grp[,c(input$subject, input$gender)]), ])
plotData = merge(plotData, gender, by = input$subject)
plotData[,input$subject] <- as.factor(plotData[,input$subject])
plotData = plotData[with(plotData, order(eval(parse(text=input$gender)))), ]
ggplot(plotData, aes_string(y = "Mean", x =input$subject, color = input$gender)) +
geom_point() +
geom_errorbar(aes(ymax = Max, ymin = Min), width = 0.35) +
coord_flip() +
theme_bw(base_size = 14) +
ylab(input$analyte) +
xlab("Subjects")+
scale_x_discrete(limits=plotData[,input$subject])
```