-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStep_01_Load_and_Inspect_Mouse_Data.tex
More file actions
1302 lines (1086 loc) · 66.5 KB
/
Step_01_Load_and_Inspect_Mouse_Data.tex
File metadata and controls
1302 lines (1086 loc) · 66.5 KB
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
% Options for packages loaded elsewhere
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb}
\setcounter{secnumdepth}{5}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math} % this also loads fontspec
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
\usepackage{lmodern}
\ifPDFTeX\else
% xetex/luatex font selection
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
\UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts
}{}
\makeatletter
\@ifundefined{KOMAClassName}{% if non-KOMA class
\IfFileExists{parskip.sty}{%
\usepackage{parskip}
}{% else
\setlength{\parindent}{0pt}
\setlength{\parskip}{6pt plus 2pt minus 1pt}}
}{% if KOMA class
\KOMAoptions{parskip=half}}
\makeatother
% Make \paragraph and \subparagraph free-standing
\makeatletter
\ifx\paragraph\undefined\else
\let\oldparagraph\paragraph
\renewcommand{\paragraph}{
\@ifstar
\xxxParagraphStar
\xxxParagraphNoStar
}
\newcommand{\xxxParagraphStar}[1]{\oldparagraph*{#1}\mbox{}}
\newcommand{\xxxParagraphNoStar}[1]{\oldparagraph{#1}\mbox{}}
\fi
\ifx\subparagraph\undefined\else
\let\oldsubparagraph\subparagraph
\renewcommand{\subparagraph}{
\@ifstar
\xxxSubParagraphStar
\xxxSubParagraphNoStar
}
\newcommand{\xxxSubParagraphStar}[1]{\oldsubparagraph*{#1}\mbox{}}
\newcommand{\xxxSubParagraphNoStar}[1]{\oldsubparagraph{#1}\mbox{}}
\fi
\makeatother
\usepackage{color}
\usepackage{fancyvrb}
\newcommand{\VerbBar}{|}
\newcommand{\VERB}{\Verb[commandchars=\\\{\}]}
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
% Add ',fontsize=\small' for more characters per line
\usepackage{framed}
\definecolor{shadecolor}{RGB}{241,243,245}
\newenvironment{Shaded}{\begin{snugshade}}{\end{snugshade}}
\newcommand{\AlertTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.40,0.45,0.13}{#1}}
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\BuiltInTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.56,0.35,0.01}{#1}}
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{\textbf{#1}}}
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\ExtensionTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.28,0.35,0.67}{#1}}
\newcommand{\ImportTok}[1]{\textcolor[rgb]{0.00,0.46,0.62}{#1}}
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{\textbf{#1}}}
\newcommand{\NormalTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.68,0.00,0.00}{#1}}
\newcommand{\RegionMarkerTok}[1]{\textcolor[rgb]{0.00,0.23,0.31}{#1}}
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{#1}}
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.07,0.07,0.07}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.13,0.47,0.30}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.37,0.37,0.37}{\textit{#1}}}
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
\makeatletter
\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}
\makeatother
% Allow footnotes in longtable head/foot
\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}
\makesavenoteenv{longtable}
\usepackage{graphicx}
\makeatletter
\newsavebox\pandoc@box
\newcommand*\pandocbounded[1]{% scales image to fit in text height/width
\sbox\pandoc@box{#1}%
\Gscale@div\@tempa{\textheight}{\dimexpr\ht\pandoc@box+\dp\pandoc@box\relax}%
\Gscale@div\@tempb{\linewidth}{\wd\pandoc@box}%
\ifdim\@tempb\p@<\@tempa\p@\let\@tempa\@tempb\fi% select the smaller of both
\ifdim\@tempa\p@<\p@\scalebox{\@tempa}{\usebox\pandoc@box}%
\else\usebox{\pandoc@box}%
\fi%
}
% Set default figure placement to htbp
\def\fps@figure{htbp}
\makeatother
\setlength{\emergencystretch}{3em} % prevent overfull lines
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{booktabs}
\usepackage{geometry}
\geometry{margin=1in}
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\AtBeginDocument{%
\ifdefined\contentsname
\renewcommand*\contentsname{Table of contents}
\else
\newcommand\contentsname{Table of contents}
\fi
\ifdefined\listfigurename
\renewcommand*\listfigurename{List of Figures}
\else
\newcommand\listfigurename{List of Figures}
\fi
\ifdefined\listtablename
\renewcommand*\listtablename{List of Tables}
\else
\newcommand\listtablename{List of Tables}
\fi
\ifdefined\figurename
\renewcommand*\figurename{Figure}
\else
\newcommand\figurename{Figure}
\fi
\ifdefined\tablename
\renewcommand*\tablename{Table}
\else
\newcommand\tablename{Table}
\fi
}
\@ifpackageloaded{float}{}{\usepackage{float}}
\floatstyle{ruled}
\@ifundefined{c@chapter}{\newfloat{codelisting}{h}{lop}}{\newfloat{codelisting}{h}{lop}[chapter]}
\floatname{codelisting}{Listing}
\newcommand*\listoflistings{\listof{codelisting}{List of Listings}}
\makeatother
\makeatletter
\makeatother
\makeatletter
\@ifpackageloaded{caption}{}{\usepackage{caption}}
\@ifpackageloaded{subcaption}{}{\usepackage{subcaption}}
\makeatother
\usepackage{bookmark}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\urlstyle{same}
\hypersetup{
pdftitle={Step 01 - Load and Inspect Mouse Data},
pdfauthor={Jason van Leuven},
colorlinks=true,
linkcolor={blue},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\title{Step 01 - Load and Inspect Mouse Data}
\author{Jason van Leuven}
\date{2025-10-25}
\begin{document}
\maketitle
\renewcommand*\contentsname{Table of contents}
{
\hypersetup{linkcolor=}
\setcounter{tocdepth}{3}
\tableofcontents
}
\section{Step 01 - Load and Inspect Mouse
Data}\label{step-01---load-and-inspect-mouse-data}
This first step establishes the analytical foundation of the entire
pipeline. It imports and inspects the mouse wound-healing dataset,
ensuring that all subsequent analyses rest on structurally sound and
biologically coherent data. The dataset represents wound closure and
bacterial clearance trajectories collected from controlled mouse models,
where time, treatment group, and outcome variables must align precisely
before any statistical modelling can proceed.
The key objectives here are integrity, completeness, and
reproducibility. The script begins by checking column structure,
verifying that variable names, data types, and units conform to the
expected schema. It then performs completeness checks on key
identifiers, ensuring that each mouse and wound record is unique,
chronologically ordered, and free from structural anomalies such as
missing time points or duplicate measurements. These checks are informed
by reproducible data principles outlined by Wickham et al.~(2019),
allowing each cleaning step to be traceable and verifiable.
Descriptive summaries and diagnostic plots follow. The code produces
simple histograms, scatterplots, and boxplots to visualise wound-area
progression, bacterial counts, and treatment group distributions. These
outputs help confirm whether the observed biological patterns match
expectations --- for example, whether wound size consistently decreases
across days, and whether CFU counts exhibit the expected log-linear
decline under phage or antibiotic treatment. When anomalies appear, such
as reversed healing trends or sudden CFU spikes, they are flagged for
correction or exclusion in later steps.
Finally, Step 01 exports two well-defined intermediate files:\\
- \texttt{closure\_data.csv}, capturing wound-area trajectories for
closure analysis.\\
- \texttt{clearance\_data.csv}, representing bacterial load decay over
time.
These files serve as the clean, structured inputs for \textbf{Step 02},
where they will undergo more formal validation and preparation for
Weibull-based parameter estimation and later allometric scaling to human
data (Wei et al., 2017; Cukjati et al., 2001). The emphasis here is not
just data hygiene but analytical transparency --- establishing a
pipeline where every transformation from raw measurement to model input
can be reproduced and justified.
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{\# Load V2 Infrastructure}
\CommentTok{\# This replaces hardcoded paths and adds validation \& logging}
\FunctionTok{source}\NormalTok{(}\StringTok{"config/paths.R"}\NormalTok{)}
\FunctionTok{source}\NormalTok{(}\StringTok{"src/R/utils.R"}\NormalTok{)}
\FunctionTok{source}\NormalTok{(}\StringTok{"src/R/data\_validation.R"}\NormalTok{)}
\FunctionTok{source}\NormalTok{(}\StringTok{"src/R/logging.R"}\NormalTok{)}
\CommentTok{\# Get standardized paths}
\NormalTok{paths }\OtherTok{\textless{}{-}} \FunctionTok{get\_project\_paths}\NormalTok{()}
\CommentTok{\# Setup logging}
\FunctionTok{setup\_logging}\NormalTok{(}\AttributeTok{log\_dir =}\NormalTok{ paths}\SpecialCharTok{$}\NormalTok{logs, }\AttributeTok{log\_level =} \StringTok{"INFO"}\NormalTok{)}
\CommentTok{\# Load required packages}
\FunctionTok{suppressPackageStartupMessages}\NormalTok{(\{}
\FunctionTok{library}\NormalTok{(tidyverse)}
\FunctionTok{library}\NormalTok{(janitor)}
\FunctionTok{library}\NormalTok{(readr)}
\FunctionTok{library}\NormalTok{(glue)}
\NormalTok{\})}
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"="} \SpecialCharTok{\%\textgreater{}\%} \FunctionTok{rep}\NormalTok{(}\DecValTok{70}\NormalTok{) }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{paste}\NormalTok{(}\AttributeTok{collapse =} \StringTok{""}\NormalTok{))}
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"STEP 01: Load and Inspect Mouse Data"}\NormalTok{)}
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"="} \SpecialCharTok{\%\textgreater{}\%} \FunctionTok{rep}\NormalTok{(}\DecValTok{70}\NormalTok{) }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{paste}\NormalTok{(}\AttributeTok{collapse =} \StringTok{""}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{\# STEP 01 : Load and Inspect Mouse Data}
\CommentTok{\# Purpose: Import wound closure and bacterial CFU datasets.}
\CommentTok{\# Reference: Wickham et al. (2019) {-} The Tidyverse approach to reproducible data science.}
\CommentTok{\# Define input paths using new infrastructure}
\NormalTok{closure\_path }\OtherTok{\textless{}{-}} \FunctionTok{file.path}\NormalTok{(paths}\SpecialCharTok{$}\NormalTok{data\_raw, }\StringTok{"mouse\_closure\_filled.csv"}\NormalTok{)}
\NormalTok{cfu\_path }\OtherTok{\textless{}{-}} \FunctionTok{file.path}\NormalTok{(paths}\SpecialCharTok{$}\NormalTok{data\_raw, }\StringTok{"mouse\_cfu\_filled.csv"}\NormalTok{)}
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{STEP 01 {-} LOAD MOUSE DATASETS}\SpecialCharTok{\textbackslash{}n}\StringTok{============================}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
STEP 01 - LOAD MOUSE DATASETS
============================
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Loading mouse datasets from data/raw/"}\NormalTok{)}
\CommentTok{\# Load data}
\NormalTok{closure }\OtherTok{\textless{}{-}} \FunctionTok{read\_csv}\NormalTok{(closure\_path, }\AttributeTok{show\_col\_types =} \ConstantTok{FALSE}\NormalTok{) }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{clean\_names}\NormalTok{()}
\NormalTok{cfu }\OtherTok{\textless{}{-}} \FunctionTok{read\_csv}\NormalTok{(cfu\_path, }\AttributeTok{show\_col\_types =} \ConstantTok{FALSE}\NormalTok{) }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{clean\_names}\NormalTok{()}
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Loaded closure dataset: \{nrow(closure)\} rows x \{ncol(closure)\} columns"}\NormalTok{))}
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Loaded CFU dataset: \{nrow(cfu)\} rows x \{ncol(cfu)\} columns"}\NormalTok{))}
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Loaded closure dataset: \{nrow(closure)\} rows x \{ncol(closure)\} columns}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Loaded closure dataset: 140 rows x 11 columns
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Loaded CFU dataset: \{nrow(cfu)\} rows x \{ncol(cfu)\} columns}\SpecialCharTok{\textbackslash{}n\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Loaded CFU dataset: 140 rows x 12 columns
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{glimpse}\NormalTok{(closure)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Rows: 140
Columns: 11
$ cohort <chr> "ABX", "ABX", "ABX", "ABX", "ABX", "ABX", "ABX", "AB~
$ treatment_group <chr> "DAPTO", "DAPTO", "DAPTO_LINEZ", "DAPTO_LINEZ", "LIN~
$ mouse_id <chr> "ABX_DAPTO_M3", "ABX_DAPTO_M4", "ABX_DAPTO_LINEZ_M7"~
$ parameter <chr> "nd_wound_size_mm^2", "nd_wound_size_mm^2", "nd_woun~
$ day <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~
$ wound_area_mm2 <dbl> 40.70, 29.20, 28.10, 25.60, 26.90, 33.80, 31.80, 36.~
$ last_obs_day <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, ~
$ wound_area_interp <dbl> 40.70, 29.20, 28.10, 25.60, 26.90, 33.80, 31.80, 36.~
$ wound_area_filled <dbl> 40.70, 29.20, 28.10, 25.60, 26.90, 33.80, 31.80, 36.~
$ imputed_flag <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FAL~
$ method_used <chr> "observed", "observed", "observed", "observed", "obs~
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{glimpse}\NormalTok{(cfu)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Rows: 140
Columns: 12
$ cohort <chr> "ABX", "ABX", "ABX", "ABX", "ABX", "ABX", "ABX", "ABX"~
$ treatment_group <chr> "DAPTO", "DAPTO", "DAPTO_LINEZ", "DAPTO_LINEZ", "LINEZ~
$ mouse_id <chr> "ABX_DAPTO_M3", "ABX_DAPTO_M4", "ABX_DAPTO_LINEZ_M7", ~
$ parameter <chr> "nd_cfu_per_ml", "nd_cfu_per_ml", "nd_cfu_per_ml", "nd~
$ day <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~
$ cfu_per_ml <dbl> 5.5e+07, 5.5e+07, 5.5e+07, 5.5e+07, 5.5e+07, 5.5e+07, ~
$ last_obs_day <dbl> 11, 11, 11, 11, 2, 11, 11, 11, 11, 11, 11, 11, 11, 11,~
$ log_cfu <dbl> 7.740363, 7.740363, 7.740363, 7.740363, 7.740363, 7.74~
$ log_cfu_interp <dbl> 7.740363, 7.740363, 7.740363, 7.740363, 7.740363, 7.74~
$ cfu_filled <dbl> 5.5e+07, 5.5e+07, 5.5e+07, 5.5e+07, 5.5e+07, 5.5e+07, ~
$ imputed_flag <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE~
$ method_used <chr> "observed", "observed", "observed", "observed", "obser~
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{\# V2 Enhancement: Validate data structure}
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{[checkmark] Running data validation checks...}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[checkmark] Running data validation checks...
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Running data validation checks"}\NormalTok{)}
\FunctionTok{tryCatch}\NormalTok{(\{}
\CommentTok{\# Validate closure data structure}
\FunctionTok{validate\_mouse\_data}\NormalTok{(}
\NormalTok{ closure, }
\AttributeTok{required\_cols =} \FunctionTok{c}\NormalTok{(}\StringTok{"mouse\_id"}\NormalTok{, }\StringTok{"day"}\NormalTok{, }\StringTok{"wound\_area\_filled"}\NormalTok{, }\StringTok{"treatment\_group"}\NormalTok{, }\StringTok{"cohort"}\NormalTok{)}
\NormalTok{ )}
\CommentTok{\# Validate closure data quality}
\NormalTok{ closure\_validation }\OtherTok{\textless{}{-}} \FunctionTok{validate\_closure\_data}\NormalTok{(closure)}
\ControlFlowTok{if}\NormalTok{ (closure\_validation}\SpecialCharTok{$}\NormalTok{all\_pass) \{}
\FunctionTok{cat}\NormalTok{(}\StringTok{"[checkmark] All closure data validation checks passed}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"All closure data validation checks passed"}\NormalTok{)}
\NormalTok{ \} }\ControlFlowTok{else}\NormalTok{ \{}
\FunctionTok{cat}\NormalTok{(}\StringTok{"[!] Some validation checks failed {-} see warnings above}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\FunctionTok{log\_warn}\NormalTok{(}\StringTok{"Some closure data validation checks failed"}\NormalTok{)}
\NormalTok{ \}}
\CommentTok{\# Validate CFU data structure}
\FunctionTok{validate\_mouse\_data}\NormalTok{(}
\NormalTok{ cfu,}
\AttributeTok{required\_cols =} \FunctionTok{c}\NormalTok{(}\StringTok{"mouse\_id"}\NormalTok{, }\StringTok{"day"}\NormalTok{, }\StringTok{"cfu\_filled"}\NormalTok{, }\StringTok{"treatment\_group"}\NormalTok{, }\StringTok{"cohort"}\NormalTok{)}
\NormalTok{ )}
\FunctionTok{cat}\NormalTok{(}\StringTok{"[checkmark] All CFU data structure checks passed}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"All CFU data structure checks passed"}\NormalTok{)}
\NormalTok{\}, }\AttributeTok{error =} \ControlFlowTok{function}\NormalTok{(e) \{}
\FunctionTok{log\_error}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Validation failed: \{e$message\}"}\NormalTok{))}
\FunctionTok{stop}\NormalTok{(e)}
\NormalTok{\})}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[!] Some validation checks failed - see warnings above
\end{verbatim}
\begin{verbatim}
[checkmark] All CFU data structure checks passed
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{Numeric Range Checks}\SpecialCharTok{\textbackslash{}n}\StringTok{{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Numeric Range Checks
----------------------------
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"Closure (wound\_area\_filled):}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{); }\FunctionTok{summary}\NormalTok{(closure}\SpecialCharTok{$}\NormalTok{wound\_area\_filled)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Closure (wound_area_filled):
\end{verbatim}
\begin{verbatim}
Min. 1st Qu. Median Mean 3rd Qu. Max.
6.40 27.95 35.42 33.71 40.30 57.80
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{CFU (cfu\_filled):}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{); }\FunctionTok{summary}\NormalTok{(cfu}\SpecialCharTok{$}\NormalTok{cfu\_filled)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
CFU (cfu_filled):
\end{verbatim}
\begin{verbatim}
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0 5681405 14400000 37646258 55000000 290000000 5
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{[checkmark] Step 01 inspection complete {-} datasets structurally validated.}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[checkmark] Step 01 inspection complete - datasets structurally validated.
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Step 01 inspection complete {-} datasets structurally validated"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{\# STEP 02 : Cohort \& Treatment Summary}
\CommentTok{\# Purpose: Summarise cohort and treatment composition.}
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{STEP 02 {-} COHORT \& TREATMENT SUMMARY}\SpecialCharTok{\textbackslash{}n}\StringTok{============================}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
STEP 02 - COHORT & TREATMENT SUMMARY
============================
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Generating cohort and treatment summaries"}\NormalTok{)}
\NormalTok{closure\_counts }\OtherTok{\textless{}{-}}\NormalTok{ closure }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{count}\NormalTok{(cohort, treatment\_group)}
\NormalTok{cfu\_counts }\OtherTok{\textless{}{-}}\NormalTok{ cfu }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{count}\NormalTok{(cohort, treatment\_group)}
\FunctionTok{print}\NormalTok{(closure\_counts)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
# A tibble: 6 x 3
cohort treatment_group n
<chr> <chr> <int>
1 ABX DAPTO 14
2 ABX DAPTO_LINEZ 14
3 ABX LINEZ 42
4 ABX VANCO 28
5 PHA PHAGE 21
6 PHA PHAGEGEL 21
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{print}\NormalTok{(cfu\_counts)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
# A tibble: 6 x 3
cohort treatment_group n
<chr> <chr> <int>
1 ABX DAPTO 14
2 ABX DAPTO_LINEZ 14
3 ABX LINEZ 42
4 ABX VANCO 28
5 PHA PHAGE 21
6 PHA PHAGEGEL 21
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Closure dataset: \{nrow(closure\_counts)\} cohort{-}treatment combinations"}\NormalTok{))}
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"CFU dataset: \{nrow(cfu\_counts)\} cohort{-}treatment combinations"}\NormalTok{))}
\NormalTok{aligned }\OtherTok{\textless{}{-}} \FunctionTok{identical}\NormalTok{(}\FunctionTok{sort}\NormalTok{(}\FunctionTok{unique}\NormalTok{(closure}\SpecialCharTok{$}\NormalTok{mouse\_id)), }\FunctionTok{sort}\NormalTok{(}\FunctionTok{unique}\NormalTok{(cfu}\SpecialCharTok{$}\NormalTok{mouse\_id)))}
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{Mouse ID alignment across datasets: \{aligned\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Mouse ID alignment across datasets: TRUE
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Mouse ID alignment: \{aligned\}"}\NormalTok{))}
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Closure missing wound\_area\_filled: \{sum(is.na(closure$wound\_area\_filled))\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Closure missing wound_area_filled: 0
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"CFU missing cfu\_filled: \{sum(is.na(cfu$cfu\_filled))\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
CFU missing cfu_filled: 5
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Closure missing values: \{sum(is.na(closure$wound\_area\_filled))\}"}\NormalTok{))}
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"CFU missing values: \{sum(is.na(cfu$cfu\_filled))\}"}\NormalTok{))}
\FunctionTok{cat}\NormalTok{(}\StringTok{"[checkmark] Step 02 summary complete {-} datasets aligned and merge{-}ready.}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[checkmark] Step 02 summary complete - datasets aligned and merge-ready.
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Step 02 summary complete"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{\# STEP 03 : Merge and Export Datasets}
\CommentTok{\# Purpose: Consolidate closure and CFU data for unified analysis.}
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{STEP 03 {-} MERGE \& EXPORT DATASETS}\SpecialCharTok{\textbackslash{}n}\StringTok{============================}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
STEP 03 - MERGE & EXPORT DATASETS
============================
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Merging datasets"}\NormalTok{)}
\NormalTok{merged }\OtherTok{\textless{}{-}}\NormalTok{ closure }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{select}\NormalTok{(cohort, treatment\_group, mouse\_id, day, wound\_area\_filled) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{left\_join}\NormalTok{(cfu }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{select}\NormalTok{(cohort, treatment\_group, mouse\_id, day, cfu\_filled),}
\AttributeTok{by =} \FunctionTok{c}\NormalTok{(}\StringTok{"cohort"}\NormalTok{, }\StringTok{"treatment\_group"}\NormalTok{, }\StringTok{"mouse\_id"}\NormalTok{, }\StringTok{"day"}\NormalTok{))}
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Merged dataset created: \{nrow(merged)\} rows x \{ncol(merged)\} columns}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Merged dataset created: 140 rows x 6 columns
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Missing CFU entries: \{sum(is.na(merged$cfu\_filled))\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Missing CFU entries: 5
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Merged dataset: \{nrow(merged)\} rows x \{ncol(merged)\} columns"}\NormalTok{))}
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Missing CFU entries: \{sum(is.na(merged$cfu\_filled))\}"}\NormalTok{))}
\CommentTok{\# Use new path structure for outputs}
\NormalTok{closure\_out }\OtherTok{\textless{}{-}} \FunctionTok{file.path}\NormalTok{(paths}\SpecialCharTok{$}\NormalTok{outputs, }\StringTok{"closure\_data.csv"}\NormalTok{)}
\NormalTok{clearance\_out }\OtherTok{\textless{}{-}} \FunctionTok{file.path}\NormalTok{(paths}\SpecialCharTok{$}\NormalTok{outputs, }\StringTok{"clearance\_data.csv"}\NormalTok{)}
\NormalTok{merged\_out }\OtherTok{\textless{}{-}} \FunctionTok{file.path}\NormalTok{(paths}\SpecialCharTok{$}\NormalTok{outputs, }\StringTok{"merged\_data.csv"}\NormalTok{)}
\FunctionTok{write\_csv}\NormalTok{(merged }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{select}\NormalTok{(cohort, treatment\_group, mouse\_id, day, wound\_area\_filled), closure\_out)}
\FunctionTok{write\_csv}\NormalTok{(merged }\SpecialCharTok{\%\textgreater{}\%} \FunctionTok{select}\NormalTok{(cohort, treatment\_group, mouse\_id, day, cfu\_filled), clearance\_out)}
\FunctionTok{write\_csv}\NormalTok{(merged, merged\_out)}
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Saved closure data {-}\textgreater{} \{closure\_out\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Saved closure data -> /Users/vanl0030/Documents/weibull_pipeline_v2/outputs/closure_data.csv
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Saved clearance data {-}\textgreater{} \{clearance\_out\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Saved clearance data -> /Users/vanl0030/Documents/weibull_pipeline_v2/outputs/clearance_data.csv
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{glue}\NormalTok{(}\StringTok{"Saved merged data {-}\textgreater{} \{merged\_out\}}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Saved merged data -> /Users/vanl0030/Documents/weibull_pipeline_v2/outputs/merged_data.csv
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Exported: closure\_data.csv, clearance\_data.csv, merged\_data.csv"}\NormalTok{)}
\FunctionTok{cat}\NormalTok{(}\StringTok{"[checkmark] Step 03 complete {-} datasets exported to outputs/}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
[checkmark] Step 03 complete - datasets exported to outputs/
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Step 03 complete"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{center}\rule{0.5\linewidth}{0.5pt}\end{center}
\begin{Shaded}
\begin{Highlighting}[]
\CommentTok{\# STEP 03A : Comprehensive Merge Diagnostics}
\CommentTok{\# Purpose: Multi{-}faceted view of data coverage and overlap}
\CommentTok{\# Reference: Ensures dataset integrity for later KM survival modelling.}
\FunctionTok{suppressPackageStartupMessages}\NormalTok{(\{}
\FunctionTok{library}\NormalTok{(ggvenn)}
\FunctionTok{library}\NormalTok{(gridExtra)}
\FunctionTok{library}\NormalTok{(grid)}
\NormalTok{\})}
\FunctionTok{log\_info}\NormalTok{(}\StringTok{"Generating comprehensive merge diagnostics"}\NormalTok{)}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\CommentTok{\# 1. Overall Closure vs CFU Overlap}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\NormalTok{closure\_keys }\OtherTok{\textless{}{-}}\NormalTok{ closure }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{mutate}\NormalTok{(}\AttributeTok{join\_key =} \FunctionTok{paste}\NormalTok{(cohort, treatment\_group, mouse\_id, day, }\AttributeTok{sep =} \StringTok{"\_"}\NormalTok{)) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{pull}\NormalTok{(join\_key)}
\NormalTok{cfu\_keys }\OtherTok{\textless{}{-}}\NormalTok{ cfu }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{mutate}\NormalTok{(}\AttributeTok{join\_key =} \FunctionTok{paste}\NormalTok{(cohort, treatment\_group, mouse\_id, day, }\AttributeTok{sep =} \StringTok{"\_"}\NormalTok{)) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{pull}\NormalTok{(join\_key)}
\CommentTok{\# Calculate overlap statistics}
\NormalTok{total\_closure }\OtherTok{\textless{}{-}} \FunctionTok{length}\NormalTok{(}\FunctionTok{unique}\NormalTok{(closure\_keys))}
\NormalTok{total\_cfu }\OtherTok{\textless{}{-}} \FunctionTok{length}\NormalTok{(}\FunctionTok{unique}\NormalTok{(cfu\_keys))}
\NormalTok{overlap }\OtherTok{\textless{}{-}} \FunctionTok{length}\NormalTok{(}\FunctionTok{intersect}\NormalTok{(}\FunctionTok{unique}\NormalTok{(closure\_keys), }\FunctionTok{unique}\NormalTok{(cfu\_keys)))}
\NormalTok{closure\_only }\OtherTok{\textless{}{-}} \FunctionTok{length}\NormalTok{(}\FunctionTok{setdiff}\NormalTok{(}\FunctionTok{unique}\NormalTok{(closure\_keys), }\FunctionTok{unique}\NormalTok{(cfu\_keys)))}
\NormalTok{cfu\_only }\OtherTok{\textless{}{-}} \FunctionTok{length}\NormalTok{(}\FunctionTok{setdiff}\NormalTok{(}\FunctionTok{unique}\NormalTok{(cfu\_keys), }\FunctionTok{unique}\NormalTok{(closure\_keys)))}
\FunctionTok{cat}\NormalTok{(}\StringTok{"}\SpecialCharTok{\textbackslash{}n}\StringTok{===========================================================}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
===========================================================
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"MERGE DIAGNOSTICS SUMMARY}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
MERGE DIAGNOSTICS SUMMARY
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"===========================================================}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
===========================================================
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{sprintf}\NormalTok{(}\StringTok{"Total Closure observations: \%5d}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{, total\_closure))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Total Closure observations: 140
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{sprintf}\NormalTok{(}\StringTok{"Total CFU observations: \%5d}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{, total\_cfu))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Total CFU observations: 140
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{sprintf}\NormalTok{(}\StringTok{"Perfect overlap (both): \%5d (\%.1f\%\%)}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{, }
\NormalTok{ overlap, }\DecValTok{100} \SpecialCharTok{*}\NormalTok{ overlap }\SpecialCharTok{/} \FunctionTok{max}\NormalTok{(total\_closure, total\_cfu)))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Perfect overlap (both): 140 (100.0%)
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{sprintf}\NormalTok{(}\StringTok{"Closure only (no CFU): \%5d}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{, closure\_only))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
Closure only (no CFU): 0
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\FunctionTok{sprintf}\NormalTok{(}\StringTok{"CFU only (no Closure): \%5d}\SpecialCharTok{\textbackslash{}n}\StringTok{"}\NormalTok{, cfu\_only))}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
CFU only (no Closure): 0
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{cat}\NormalTok{(}\StringTok{"===========================================================}\SpecialCharTok{\textbackslash{}n\textbackslash{}n}\StringTok{"}\NormalTok{)}
\end{Highlighting}
\end{Shaded}
\begin{verbatim}
===========================================================
\end{verbatim}
\begin{Shaded}
\begin{Highlighting}[]
\FunctionTok{log\_info}\NormalTok{(}\FunctionTok{sprintf}\NormalTok{(}\StringTok{"Data overlap: \%d/\%d observations (\%.1f\%\%)"}\NormalTok{, }
\NormalTok{ overlap, }\FunctionTok{max}\NormalTok{(total\_closure, total\_cfu), }
\DecValTok{100} \SpecialCharTok{*}\NormalTok{ overlap }\SpecialCharTok{/} \FunctionTok{max}\NormalTok{(total\_closure, total\_cfu)))}
\CommentTok{\# Overall Venn diagram with better sizing}
\NormalTok{p1 }\OtherTok{\textless{}{-}} \FunctionTok{ggvenn}\NormalTok{(}
\FunctionTok{list}\NormalTok{(}
\StringTok{"Wound Closure}\SpecialCharTok{\textbackslash{}n}\StringTok{Data"} \OtherTok{=} \FunctionTok{unique}\NormalTok{(closure\_keys), }
\StringTok{"Bacterial CFU}\SpecialCharTok{\textbackslash{}n}\StringTok{Data"} \OtherTok{=} \FunctionTok{unique}\NormalTok{(cfu\_keys)}
\NormalTok{ ), }
\AttributeTok{fill\_color =} \FunctionTok{c}\NormalTok{(}\StringTok{"\#0073C2FF"}\NormalTok{, }\StringTok{"\#EFC000FF"}\NormalTok{),}
\AttributeTok{stroke\_size =} \FloatTok{1.5}\NormalTok{,}
\AttributeTok{set\_name\_size =} \DecValTok{6}\NormalTok{,}
\AttributeTok{text\_size =} \FloatTok{5.5}
\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{labs}\NormalTok{(}\AttributeTok{title =} \StringTok{"A. Overall Data Coverage"}\NormalTok{,}
\AttributeTok{subtitle =} \FunctionTok{sprintf}\NormalTok{(}\StringTok{"Overlap: \%d observations (\%.1f\%\%)"}\NormalTok{, }
\NormalTok{ overlap, }\DecValTok{100} \SpecialCharTok{*}\NormalTok{ overlap }\SpecialCharTok{/} \FunctionTok{max}\NormalTok{(total\_closure, total\_cfu))) }\SpecialCharTok{+}
\FunctionTok{theme}\NormalTok{(}\AttributeTok{plot.title =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{16}\NormalTok{, }\AttributeTok{face =} \StringTok{"bold"}\NormalTok{),}
\AttributeTok{plot.subtitle =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{13}\NormalTok{))}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\CommentTok{\# 2. Coverage by Treatment Group}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\NormalTok{treatment\_coverage }\OtherTok{\textless{}{-}}\NormalTok{ merged }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{group\_by}\NormalTok{(treatment\_group) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{summarise}\NormalTok{(}
\AttributeTok{n\_mice =} \FunctionTok{n\_distinct}\NormalTok{(mouse\_id),}
\AttributeTok{n\_obs =} \FunctionTok{n}\NormalTok{(),}
\AttributeTok{closure\_complete =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(wound\_area\_filled)),}
\AttributeTok{cfu\_complete =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(cfu\_filled)),}
\AttributeTok{both\_complete =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(wound\_area\_filled) }\SpecialCharTok{\&} \SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(cfu\_filled)),}
\AttributeTok{.groups =} \StringTok{"drop"}
\NormalTok{ ) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{mutate}\NormalTok{(}
\AttributeTok{closure\_pct =} \DecValTok{100} \SpecialCharTok{*}\NormalTok{ closure\_complete }\SpecialCharTok{/}\NormalTok{ n\_obs,}
\AttributeTok{cfu\_pct =} \DecValTok{100} \SpecialCharTok{*}\NormalTok{ cfu\_complete }\SpecialCharTok{/}\NormalTok{ n\_obs,}
\AttributeTok{both\_pct =} \DecValTok{100} \SpecialCharTok{*}\NormalTok{ both\_complete }\SpecialCharTok{/}\NormalTok{ n\_obs}
\NormalTok{ )}
\NormalTok{p2 }\OtherTok{\textless{}{-}} \FunctionTok{ggplot}\NormalTok{(treatment\_coverage, }\FunctionTok{aes}\NormalTok{(}\AttributeTok{x =}\NormalTok{ treatment\_group)) }\SpecialCharTok{+}
\FunctionTok{geom\_col}\NormalTok{(}\FunctionTok{aes}\NormalTok{(}\AttributeTok{y =}\NormalTok{ both\_pct), }\AttributeTok{fill =} \StringTok{"\#2ECC71"}\NormalTok{, }\AttributeTok{alpha =} \FloatTok{0.8}\NormalTok{, }\AttributeTok{width =} \FloatTok{0.7}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{geom\_col}\NormalTok{(}\FunctionTok{aes}\NormalTok{(}\AttributeTok{y =}\NormalTok{ closure\_pct), }\AttributeTok{fill =} \StringTok{"\#0073C2FF"}\NormalTok{, }\AttributeTok{alpha =} \FloatTok{0.5}\NormalTok{, }\AttributeTok{width =} \FloatTok{0.5}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{geom\_col}\NormalTok{(}\FunctionTok{aes}\NormalTok{(}\AttributeTok{y =}\NormalTok{ cfu\_pct), }\AttributeTok{fill =} \StringTok{"\#EFC000FF"}\NormalTok{, }\AttributeTok{alpha =} \FloatTok{0.5}\NormalTok{, }\AttributeTok{width =} \FloatTok{0.3}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{geom\_text}\NormalTok{(}\FunctionTok{aes}\NormalTok{(}\AttributeTok{y =}\NormalTok{ both\_pct }\SpecialCharTok{+} \DecValTok{5}\NormalTok{, }\AttributeTok{label =} \FunctionTok{sprintf}\NormalTok{(}\StringTok{"\%.0f\%\%"}\NormalTok{, both\_pct)), }
\AttributeTok{size =} \DecValTok{5}\NormalTok{, }\AttributeTok{fontface =} \StringTok{"bold"}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{scale\_y\_continuous}\NormalTok{(}\AttributeTok{limits =} \FunctionTok{c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{105}\NormalTok{), }\AttributeTok{expand =} \FunctionTok{c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{0}\NormalTok{)) }\SpecialCharTok{+}
\FunctionTok{labs}\NormalTok{(}
\AttributeTok{title =} \StringTok{"B. Data Completeness by Treatment Group"}\NormalTok{,}
\AttributeTok{subtitle =} \StringTok{"Green = Both measurements | Blue = Closure | Yellow = CFU"}\NormalTok{,}
\AttributeTok{x =} \StringTok{"Treatment Group"}\NormalTok{,}
\AttributeTok{y =} \StringTok{"\% Complete"}
\NormalTok{ ) }\SpecialCharTok{+}
\FunctionTok{theme\_minimal}\NormalTok{(}\AttributeTok{base\_size =} \DecValTok{14}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{theme}\NormalTok{(}
\AttributeTok{panel.grid.major.x =} \FunctionTok{element\_blank}\NormalTok{(),}
\AttributeTok{plot.title =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{face =} \StringTok{"bold"}\NormalTok{, }\AttributeTok{size =} \DecValTok{16}\NormalTok{),}
\AttributeTok{plot.subtitle =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{),}
\AttributeTok{axis.text.x =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{angle =} \DecValTok{0}\NormalTok{, }\AttributeTok{hjust =} \FloatTok{0.5}\NormalTok{, }\AttributeTok{size =} \DecValTok{12}\NormalTok{)}
\NormalTok{ )}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\CommentTok{\# 3. Coverage by Cohort}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\NormalTok{cohort\_coverage }\OtherTok{\textless{}{-}}\NormalTok{ merged }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{group\_by}\NormalTok{(cohort, treatment\_group) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{summarise}\NormalTok{(}
\AttributeTok{n\_mice =} \FunctionTok{n\_distinct}\NormalTok{(mouse\_id),}
\AttributeTok{both\_complete =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(wound\_area\_filled) }\SpecialCharTok{\&} \SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(cfu\_filled)),}
\AttributeTok{n\_obs =} \FunctionTok{n}\NormalTok{(),}
\AttributeTok{.groups =} \StringTok{"drop"}
\NormalTok{ ) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{mutate}\NormalTok{(}\AttributeTok{complete\_pct =} \DecValTok{100} \SpecialCharTok{*}\NormalTok{ both\_complete }\SpecialCharTok{/}\NormalTok{ n\_obs)}
\NormalTok{p3 }\OtherTok{\textless{}{-}} \FunctionTok{ggplot}\NormalTok{(cohort\_coverage, }\FunctionTok{aes}\NormalTok{(}\AttributeTok{x =}\NormalTok{ cohort, }\AttributeTok{y =}\NormalTok{ complete\_pct, }\AttributeTok{fill =}\NormalTok{ treatment\_group)) }\SpecialCharTok{+}
\FunctionTok{geom\_col}\NormalTok{(}\AttributeTok{position =} \StringTok{"dodge"}\NormalTok{, }\AttributeTok{width =} \FloatTok{0.7}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{geom\_text}\NormalTok{(}\FunctionTok{aes}\NormalTok{(}\AttributeTok{label =} \FunctionTok{sprintf}\NormalTok{(}\StringTok{"n=\%d}\SpecialCharTok{\textbackslash{}n}\StringTok{\%.0f\%\%"}\NormalTok{, n\_mice, complete\_pct)),}
\AttributeTok{position =} \FunctionTok{position\_dodge}\NormalTok{(}\AttributeTok{width =} \FloatTok{0.7}\NormalTok{),}
\AttributeTok{vjust =} \SpecialCharTok{{-}}\FloatTok{0.3}\NormalTok{, }\AttributeTok{size =} \DecValTok{4}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{scale\_y\_continuous}\NormalTok{(}\AttributeTok{limits =} \FunctionTok{c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{115}\NormalTok{), }\AttributeTok{expand =} \FunctionTok{c}\NormalTok{(}\DecValTok{0}\NormalTok{, }\DecValTok{0}\NormalTok{)) }\SpecialCharTok{+}
\FunctionTok{scale\_fill\_brewer}\NormalTok{(}\AttributeTok{palette =} \StringTok{"Set2"}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{labs}\NormalTok{(}
\AttributeTok{title =} \StringTok{"C. Data Completeness by Cohort \& Treatment"}\NormalTok{,}
\AttributeTok{subtitle =} \StringTok{"Showing mice per group and \% with both measurements"}\NormalTok{,}
\AttributeTok{x =} \StringTok{"Cohort"}\NormalTok{,}
\AttributeTok{y =} \StringTok{"\% Complete (Both Measurements)"}\NormalTok{,}
\AttributeTok{fill =} \StringTok{"Treatment"}
\NormalTok{ ) }\SpecialCharTok{+}
\FunctionTok{theme\_minimal}\NormalTok{(}\AttributeTok{base\_size =} \DecValTok{14}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{theme}\NormalTok{(}
\AttributeTok{legend.position =} \StringTok{"bottom"}\NormalTok{,}
\AttributeTok{legend.text =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{11}\NormalTok{),}
\AttributeTok{legend.title =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{, }\AttributeTok{face =} \StringTok{"bold"}\NormalTok{),}
\AttributeTok{panel.grid.major.x =} \FunctionTok{element\_blank}\NormalTok{(),}
\AttributeTok{plot.title =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{face =} \StringTok{"bold"}\NormalTok{, }\AttributeTok{size =} \DecValTok{16}\NormalTok{),}
\AttributeTok{plot.subtitle =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{),}
\AttributeTok{axis.text =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{)}
\NormalTok{ )}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\CommentTok{\# 4. Temporal Coverage (by Day)}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\NormalTok{temporal\_coverage }\OtherTok{\textless{}{-}}\NormalTok{ merged }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{group\_by}\NormalTok{(day) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{summarise}\NormalTok{(}
\AttributeTok{n\_observations =} \FunctionTok{n}\NormalTok{(),}
\AttributeTok{closure\_available =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(wound\_area\_filled)),}
\AttributeTok{cfu\_available =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(cfu\_filled)),}
\AttributeTok{both\_available =} \FunctionTok{sum}\NormalTok{(}\SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(wound\_area\_filled) }\SpecialCharTok{\&} \SpecialCharTok{!}\FunctionTok{is.na}\NormalTok{(cfu\_filled)),}
\AttributeTok{.groups =} \StringTok{"drop"}
\NormalTok{ ) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{pivot\_longer}\NormalTok{(}\AttributeTok{cols =} \FunctionTok{c}\NormalTok{(closure\_available, cfu\_available, both\_available),}
\AttributeTok{names\_to =} \StringTok{"measurement\_type"}\NormalTok{,}
\AttributeTok{values\_to =} \StringTok{"count"}\NormalTok{) }\SpecialCharTok{\%\textgreater{}\%}
\FunctionTok{mutate}\NormalTok{(}
\AttributeTok{measurement\_type =} \FunctionTok{factor}\NormalTok{(}
\NormalTok{ measurement\_type,}
\AttributeTok{levels =} \FunctionTok{c}\NormalTok{(}\StringTok{"both\_available"}\NormalTok{, }\StringTok{"closure\_available"}\NormalTok{, }\StringTok{"cfu\_available"}\NormalTok{),}
\AttributeTok{labels =} \FunctionTok{c}\NormalTok{(}\StringTok{"Both Complete"}\NormalTok{, }\StringTok{"Closure Data"}\NormalTok{, }\StringTok{"CFU Data"}\NormalTok{)}
\NormalTok{ )}
\NormalTok{ )}
\NormalTok{p4 }\OtherTok{\textless{}{-}} \FunctionTok{ggplot}\NormalTok{(temporal\_coverage, }\FunctionTok{aes}\NormalTok{(}\AttributeTok{x =}\NormalTok{ day, }\AttributeTok{y =}\NormalTok{ count, }\AttributeTok{color =}\NormalTok{ measurement\_type)) }\SpecialCharTok{+}
\FunctionTok{geom\_line}\NormalTok{(}\AttributeTok{linewidth =} \FloatTok{1.5}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{geom\_point}\NormalTok{(}\AttributeTok{size =} \FloatTok{3.5}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{scale\_color\_manual}\NormalTok{(}\AttributeTok{values =} \FunctionTok{c}\NormalTok{(}\StringTok{"Both Complete"} \OtherTok{=} \StringTok{"\#2ECC71"}\NormalTok{, }
\StringTok{"Closure Data"} \OtherTok{=} \StringTok{"\#0073C2FF"}\NormalTok{,}
\StringTok{"CFU Data"} \OtherTok{=} \StringTok{"\#EFC000FF"}\NormalTok{)) }\SpecialCharTok{+}
\FunctionTok{labs}\NormalTok{(}
\AttributeTok{title =} \StringTok{"D. Temporal Coverage Across Study Period"}\NormalTok{,}
\AttributeTok{subtitle =} \StringTok{"Number of observations available at each time point"}\NormalTok{,}
\AttributeTok{x =} \StringTok{"Study Day"}\NormalTok{,}
\AttributeTok{y =} \StringTok{"Number of Observations"}\NormalTok{,}
\AttributeTok{color =} \StringTok{"Data Type"}
\NormalTok{ ) }\SpecialCharTok{+}
\FunctionTok{theme\_minimal}\NormalTok{(}\AttributeTok{base\_size =} \DecValTok{14}\NormalTok{) }\SpecialCharTok{+}
\FunctionTok{theme}\NormalTok{(}
\AttributeTok{legend.position =} \StringTok{"bottom"}\NormalTok{,}
\AttributeTok{legend.text =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{11}\NormalTok{),}
\AttributeTok{legend.title =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{, }\AttributeTok{face =} \StringTok{"bold"}\NormalTok{),}
\AttributeTok{plot.title =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{face =} \StringTok{"bold"}\NormalTok{, }\AttributeTok{size =} \DecValTok{16}\NormalTok{),}
\AttributeTok{plot.subtitle =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{),}
\AttributeTok{axis.text =} \FunctionTok{element\_text}\NormalTok{(}\AttributeTok{size =} \DecValTok{12}\NormalTok{)}
\NormalTok{ )}
\CommentTok{\# {-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}{-}}
\CommentTok{\# Combine all plots with better spacing}