-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport_summary.Rmd
618 lines (392 loc) · 19.6 KB
/
report_summary.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
---
output:
word_document:
fig_caption: true
fig_height: 10
fig_width: 10
reference_docx: bootstrap/initial/data/summaryTemplate.docx
toc: false
keep_md: false
params:
summary_title: ""
strata: NULL
---
```{r introduction, include = FALSE}
# INTRODUCTION ################################################################
# This markdown documents and integrated scripts analyse biological
# maturity stagings.
# The output is a .docx template that includes
# the results of the analysis and should be used as a standard for
# reporting of maturity staging comparisons.
```
```{r chunk_setup, include=FALSE}
# CHUNK SETUPS #################################################################
knitr::opts_chunk$set(echo = FALSE, warning = FALSE,
message=FALSE, results = 'asis', dpi=400)
```
```{r pander_settings, include = FALSE}
# PANDER OPTIONS ##############################################################
panderOptions('table.split.table', Inf)
panderOptions('keep.trailing.zeros', TRUE)
panderOptions('table.alignment.default', "center")
panderOptions('knitr.auto.asis', FALSE)
group <- "adv"
# from extrafont
# font_import(pattern=c("Cali"))
# loadfonts(device="win")
```
---
title: `r config$summary_title`
---
# Executive summary
Text?
*Overview table*
<!-- Stock, Total number of samples (NSample), Preparation method, PA (sex and maturity), CU (sex and maturity), Number of readers (basic and advanced) text -->
```{r overview_statistics_all}
overview_statistics_all <-
c(Stock=unique(ad_long_all$stock),
NSample = length(unique(ad_long_all$SampleID)),
CU_sex = cu_tab_sex_all[nrow(cu_tab_sex_all), "Total"],
CU_mat = cu_tab_maturity_all[nrow(cu_tab_maturity_all), "Total"],
PA_sex = pa_tab_sex_all[nrow(pa_tab_sex_all), "Total"],
PA_mat = pa_tab_maturity_all[nrow(pa_tab_maturity_all), "Total"],
N_basic=length(unique(ad_long_all$reader))-length(unique(ad_long_adv$reader)),
N_adv=length(unique(ad_long_adv$reader)))
# Table caption
set.caption('**Table X:** Overview table: Stock; Total number of samples (NSample); coefficient of unalikeability (CU) for sex (CU_sex) and maturity (CU_maturity); percentage of agreement (PA) for sex (PA_sex) and for maturity (PA_maturity); number of basic readers (N_basic) and number of advanced readers (N_adv).')
# Output table
pander(style_table0(overview_statistics_all), missing="")
```
# Overview of samples and advanced stagers
Text?
\br
```{r sample_overview}
# Table caption
set.caption(
paste(
"**Table X:** Overview of the number of samples (num) by length category used for the exchange event number ",
config$event_id,
". The range of maturity stages (mat_stages), modal maturity stages (modal_mat_stages), sex categories (sex_cat) and modal sex categories (modal_sex_cat) for those individuals within the length range are also presented.",
sep = ""
)
)
# Output table
pander(style_table0(sample_data_overview), style = "simple")
```
\br
```{r participants_overview}
# PARTICIPATANTS OVERVIEW #####################################################
# Table caption
set.caption('**Table X:** Overview of maturity stagers.')
# Output table
pander(style_table0(filter(stager_data, Expertise!="Basic")))
```
<!-- ## Advanced stagers -->
<!-- **All samples included** -->
# Results overview
**Multimodal cases**
If there were available histological samples for all the fish individuals in the exchange event, no multiple modes are expected, however, if there were no hitology samples for some of them, multiple maturity stage modes could be found. In the next table this information is presented for the sex category determination.
<!-- Total number of samples (NSample), number (CountMM) and percentage of multimodal cases (PercMM) text -->
```{r summary_multiple_modes_sex}
histN=ad %>% subset(DoesSampleHaveHistologyImage=="Yes") %>% select(FishID) %>% unique() %>% dim()
allN=ad_long_all %>% select(FishID) %>% unique() %>% dim()
perc_not_Hist=100-round(100*histN[1]/allN[1], 0)
summary_multiple_modes_sex_all <-
c(NSample = length(unique(ad_long_all$FishID)),
Nhist=histN[1],
Perc_not_Hist=perc_not_Hist,
PercMM_traditional=unique(ifelse(multimode_cases_tab_traditional_Sex_all$NModes_trad=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_traditional_Sex_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))),
PercMM_linear_weight=unique(ifelse(multimode_cases_tab_linear_Sex_all$NModes_linear=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_linear_Sex_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))),
PercMM_negexp_weight=unique(ifelse(multimode_cases_tab_negexp_Sex_all$NModes_negexp=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_negexp_Sex_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))),
PercMM_multistage=unique(ifelse(multimode_cases_tab_multistage_Sex_all$NModes_multistage=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_multistage_Sex_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))))
# Table caption
set.caption('**Table X:** Summary of statistics for sex staging; Total number of fish individuals studied (NSample), number of fish individuals with histological samples (Nhist), percentage of fish individuals without histology (Perc_not_Hist). The percentage of cases (fish samples) with multiple modes depending on the approach to weight the experience of the stager which will be considered when defining the fish sex stage mode. PercMM_traditional shows the percentage of the total samples for which multiple modes are obtained when all the stagers are equally weighted. PercMM_linear_weight shows the percentage of the total samples for which multiple modes are obtained when the weight assigned to the different stagers decreases linearly with the experience, while in the PercMM_negexp the weight applied decreases with a negative exponential shape with the experience. The PercMM_multistage shows the percentage of multiple mode cases when a combination of the different methodologies is used, as explained in the material and methods section')
# Output table
pander(style_table0(summary_multiple_modes_sex_all), missing="")
```
If there were available histological samples for all the fish individuals in the exchange event, no multiple modes are expected, however, if there were no hitology samples for some of them, multiple maturity stage modes could be found. In the next table this information is presented for the maturity staging.
<!-- Total number of samples (NSample), number (CountMM) and percentage of multimodal cases (PercMM) text -->
```{r summary_multiple_modes_maturity}
if(!isTRUE(config$maturity_hist)){
histN=ad %>% subset(DoesSampleHaveHistologyImage=="Yes") %>% select(FishID) %>% unique() %>% dim()
allN=ad_long_all %>% select(FishID) %>% unique() %>% dim()
perc_not_Hist=100-round(100*histN[1]/allN[1], 0)
summary_multiple_modes_maturity_all <-
c(NSample = length(unique(ad_long_all$FishID)),
Nhist=histN[1],
Perc_not_Hist=perc_not_Hist,
PercMM_traditional=unique(ifelse(multimode_cases_tab_traditional_Maturity_all$NModes_trad=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_traditional_Maturity_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))),
PercMM_linear_weight=unique(ifelse(multimode_cases_tab_linear_Maturity_all$NModes_linear=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_linear_Maturity_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))),
PercMM_negexp_weight=unique(ifelse(multimode_cases_tab_negexp_Maturity_all$NModes_negexp=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_negexp_Maturity_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))),
PercMM_multistage=unique(ifelse(multimode_cases_tab_multistage_Maturity_all$NModes_multistage=="zero", paste(0,"%"), paste(round((nrow(multimode_cases_tab_multistage_Maturity_all)/length(unique(ad_long_all$SampleID)))*100, digits=0),"%"))))
# Table caption
set.caption('**Table X:** Summary of statistics for maturity staging; Total number of fish individuals studied (NSample), number of fish individuals with histological samples (Nhist), percentage of fish individuals without histology (Perc_not_Hist). The percentage of cases (fish samples) with multiple modes depending on the approach to weight the experience of the stager which will be considered when defining the fish maturity stage mode. PercMM_traditional shows the percentage of the total samples for which multiple modes are obtained when all the stagers are equally weighted. PercMM_linear_weight shows the percentage of the total samples for which multiple modes are obtained when the weight assigned to the different stagers decreases linearly with the experience, while in the PercMM_negexp the weight applied decreases with a negative exponential shape with the experience. The PercMM_multistage shows the percentage of multiple mode cases when a combination of the different methodologies is used, as explained in the material and methods section')
# Output table
pander(style_table0(summary_multiple_modes_maturity_all), missing="")
}
```
**Sex categorization table**
```{r sex_composition_tab_adv}
# Sex categorization TABLE - Advanced stagers #################################################
# Table caption
set.caption('**Table X:** Sex categorization table: presents the
number of categorizations made per expert for each modal sex category.')
# Output table
pander(style_table0(sex_composition_tab_adv), missing = "-", style = "simple")
```
**Maturity staging table**
```{r num_read_maturity_adv}
# maturity stagings TABLE - Advanced stagers #################################################
# Table caption
set.caption('**Table X:** Maturity staging table: presents the
number of stagings made per expert stager for each modal maturity stage.')
# Output table
pander(style_table0(maturity_composition_tab_adv), missing = "-", style = "simple")
```
**Coefficient of Unalikeability (CU) table by modal sex category**
```{r cv_sex_adv}
# CU TABLE by modal sex category - Advanced stagers #################################################
# Table caption
set.caption('**Table X:** Coefficient of unlikeability (CU) table by modal sex category: presents the
CU per modal sex category and advanced stager, the CU of all advanced
stagers combined per sex category stage and a weighted mean of the CU
per stager.')
# Output table
pander(style_table1(cu_tab_sex_adv), missing = "-")
```
**Coefficient of Unalikeability (CU) table by modal maturity stage**
```{r cv_maturity_adv}
# CU TABLE by modal maturity stage - Advanced stagers #################################################
# Table caption
set.caption('**Table X:** Coefficient of unlikeability (CU) table by modal maturity stage: presents the
CU per modal maturity and advanced stager, the CU of all advanced
stagers combined per modal maturity stage and a weighted mean of the CU
per stager.')
# Output table
pander(style_table1(cu_tab_maturity_adv), missing = "-")
```
**PA table by modal sex category**
```{r percentage_agreement_sex_adv}
# PERCENTAGE AGREEMENT TABLE by modal sex category - Advanced stagers ###############################
# Table caption
set.caption('**Table X:** Percentage agreement (PA) table by modal sex category: presents the PA per
modal sex category and stager, of all advanced stagers
combined and a weighted mean of the PA per stager.')
# Output table
pander(style_table1(pa_tab_sex_adv), missing = "-")
```
**PA table by modal maturity stage**
```{r percentage_agreement_maturity_adv}
# PERCENTAGE AGREEMENT TABLE by modal maturity stage - Advanced stagers ###############################
# Table caption
set.caption('**Table X:** Percentage agreement (PA) table: presents the PA per
modal maturity and stager, of all advanced stagers
combined and a weighted mean of the PA per stager.')
# Output table
pander(style_table1(pa_tab_maturity_adv), missing = "-")
```
**General frequency bias table by modal sex category **
```{r rb_sex_adv,results='asis'}
# Frequency bias table by modal sex category - Advanced stagers ######################################
# Table caption
set.caption('**Table X:** Frequency bias table by modal sex category: presents the frequency of the different sex categories per
modal maturity for all the advanced stager together.')
# Output table
pander(style_table0(general_bias_freq_tab_sex_adv), missing = "-")
```
**General frequency bias table by modal maturity stage**
```{r rb_maturity_adv,results='asis'}
# Frequency bias table by modal maturity stage - Advanced stagers ######################################
# Table caption
set.caption('**Table X:** Frequency bias table by modal maturity stage: presents the frequency of the different maturity stages per
modal maturity stage for all the advanced stager together.')
# Output table
pander(style_table0(general_bias_freq_tab_maturity_adv), missing = "-")
```
**General Frequency Bias plot by modal sex category**
```{r bias_plots_sex_exp, fig.width = 5, fig.height = 4, fig.cap = cap_in}
# BIAS PLOT by modal sex category - Advanced stagers ################################################
# Table caption
cap_in <- '**Figure X:** Sex categorization bias plot by modal sex category for advanced stagers: presents the frequency per
modal sex category and sex category for all the advanced stager together. '
# Output figure
plot_general_freq_sex(ad_long_adv, strata=NULL)
```
**General Frequency Bias plot by modal maturity stage**
```{r bias_plots_maturity_exp, fig.width = 5, fig.height = 4, fig.cap = cap_in}
# BIAS PLOT by modal maturity stage - Advanced stagers ################################################
# Table caption
cap_in <- '**Figure X:** Maturity staging bias plot by modal maturity stage for advanced stagers: presents the frequency per
modal maturity and maturity stage for all the advanced stager together. '
# Output figure
plot_general_freq_matur(ad_long_adv, strata=NULL)
```
```{r set_strata}
# initialise strata loop
istrata <- 0
print_strata <- function() length(config$strata) >= istrata
```
<!-- first strata -->
```{r strata_plus_one}
# second strata
istrata <- istrata + 1
```
```{r strata_title, eval = print_strata()}
stratum <- config$strata[istrata]
# Section title
asis_output(paste("# Results by", stratum))
```
```{r ar_sex_title, eval = print_strata()}
# title
asis_output(paste0("**Sex categorization by ", stratum, "**"))
```
```{r ar_sex_by, eval = print_strata()}
# NUMBER OF SEX CATEGORIZATION PER STOCK - Advanced stagers #########################
# Table caption
set.caption(paste0('**Table X:** Number of sex categorization per ', stratum, ' for advanced stagers.'))
# Output table
pander(style_table1(get(vsname("num_read_tab_modal_sex_by"))), missing = "-")
```
```{r ar_matur_title, eval = print_strata()}
# title
asis_output(paste0("**Maturity staging by ", stratum, "**"))
```
```{r ar_matur_by, eval = print_strata()}
# NUMBER OF MATURITY STAGING PER STOCK - Advanced stagers #########################
# Table caption
set.caption(paste0('**Table X:** Number of maturity stagings per ', stratum, ' for advanced stagers.'))
# Output table
pander(style_table1(get(vsname("num_read_tab_modal_matur_by"))), missing = "-")
```
```{r cu_sex_title, eval = print_strata()}
# title
asis_output(paste0("**Coefficient of Unalikeability by modal sex category ", stratum, "**"))
```
```{r cu_sex_by, eval = print_strata()}
# Table caption
set.caption(paste0('**Table X:** CU by modal sex category per ', stratum, '.'))
# Output table
pander(style_table2(get(vsname("cu_tab_sex_by"))), missing = "-")
```
```{r cu_matur_title, eval = print_strata()}
# title
asis_output(paste0("**Coefficient of Unalikeability by modal maturity stage ", stratum, "**"))
```
```{r cu_matur_by, eval = print_strata()}
# Table caption
set.caption(paste0('**Table X:** CU by modal maturity stage per ', stratum, '.'))
# Output table
pander(style_table2(get(vsname("cu_tab_maturity_by"))), missing = "-")
```
```{r pa_sex_title, eval = print_strata()}
# title
asis_output(paste0("**Percentage Agreement by sex category per ", stratum, "**"))
```
```{r pa_sex_by, eval = print_strata()}
# Section title
#asis_("## PA by sex category - Advanced stagers") # # #############################################
# Table caption
set.caption(paste0('**Table X:** Percentage Agreement by sex category per ', stratum, '.'))
# Output table
pander(style_table2(get(vsname("pa_tab_sex_by"))), missing = "-")
```
```{r pa_matur_title, eval = print_strata()}
# title
asis_output(paste0("**Percentage Agreement by maturation stage per ", stratum, "**"))
```
```{r pa_matur_by, eval = print_strata()}
# Section title
#asis_("## PA by maturation stage - Advanced stagers") # # #############################################
# Table caption
set.caption(paste0('**Table X:** Percentage Agreement by maturation stage per ', stratum, '.'))
# Output table
pander(style_table2(get(vsname("pa_tab_maturity_by"))), missing = "-")
```
<!-- second strata -->
```{r ref.label='strata_plus_one'}
```
```{r ref.label='strata_title', eval = print_strata()}
```
```{r ref.label='ar_sex_title', eval = print_strata()}
```
```{r ref.label='ar_sex_by', eval = print_strata()}
```
```{r ref.label='ar_matur_title', eval = print_strata()}
```
```{r ref.label='ar_matur_by', eval = print_strata()}
```
```{r ref.label='cu_sex_title', eval = print_strata()}
```
```{r ref.label='cu_sex_by', eval = print_strata()}
```
```{r ref.label='cu_matur_title', eval = print_strata()}
```
```{r ref.label='cu_matur_by', eval = print_strata()}
```
```{r ref.label='pa_sex_title', eval = print_strata()}
```
```{r ref.label='pa_sex_by', eval = print_strata()}
```
```{r ref.label='pa_matur_title', eval = print_strata()}
```
```{r ref.label='pa_matur_by', eval = print_strata()}
```
<!-- third strata -->
```{r ref.label='strata_plus_one'}
```
```{r ref.label='strata_title', eval = print_strata()}
```
```{r ref.label='ar_sex_title', eval = print_strata()}
```
```{r ref.label='ar_sex_by', eval = print_strata()}
```
```{r ref.label='ar_matur_title', eval = print_strata()}
```
```{r ref.label='ar_matur_by', eval = print_strata()}
```
```{r ref.label='cu_sex_title', eval = print_strata()}
```
```{r ref.label='cu_sex_by', eval = print_strata()}
```
```{r ref.label='cu_matur_title', eval = print_strata()}
```
```{r ref.label='cu_matur_by', eval = print_strata()}
```
```{r ref.label='pa_sex_title', eval = print_strata()}
```
```{r ref.label='pa_sex_by', eval = print_strata()}
```
```{r ref.label='pa_matur_title', eval = print_strata()}
```
```{r ref.label='pa_matur_by', eval = print_strata()}
```
<!-- fourth strata -->
```{r ref.label='strata_plus_one'}
```
```{r ref.label='strata_title', eval = print_strata()}
```
```{r ref.label='ar_sex_title', eval = print_strata()}
```
```{r ref.label='ar_sex_by', eval = print_strata()}
```
```{r ref.label='ar_matur_title', eval = print_strata()}
```
```{r ref.label='ar_matur_by', eval = print_strata()}
```
```{r ref.label='cu_sex_title', eval = print_strata()}
```
```{r ref.label='cu_sex_by', eval = print_strata()}
```
```{r ref.label='cu_matur_title', eval = print_strata()}
```
```{r ref.label='cu_matur_by', eval = print_strata()}
```
```{r ref.label='pa_sex_title', eval = print_strata()}
```
```{r ref.label='pa_sex_by', eval = print_strata()}
```
```{r ref.label='pa_matur_title', eval = print_strata()}
```
```{r ref.label='pa_matur_by', eval = print_strata()}
```
# Conclusion