-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicromets_v2.Rmd
1130 lines (1015 loc) · 45.4 KB
/
Micromets_v2.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
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
---
title: "Micrometastatic Axillary Nodal Disease Project"
author: "Anni Liu"
date: "`r format(Sys.Date(), '%B %d, %Y')`"
knit: knitautomator::knit_filename
output:
word_document:
fig_caption: no
fig_height: 4
fig_width: 4
highlight: null
toc: yes
reference_docx: manuscript_style_V0.docx
html_document: default
params:
date.analysis: !r format(Sys.Date(), "%Y%B%D")
plot.fig: TRUE
results.folder: FALSE
editor_options:
chunk_output_type: console
---
```{r shortcut, include=FALSE}
#################################################################
## RStudio keyboard shortcut ##
#################################################################
# Cursor at the beginning of a command line: Ctrl+A
# Cursor at the end of a command line: Ctrl+E
# Clear all the code from your console: Ctrl+L
# Create a pipe operator %>%: Ctrl+Shift+M (Windows) or Cmd+Shift+M (Mac)
# Knit a document (knitr): Ctrl+Shift+K (Windows) or Cmd+Shift+K (Mac)
# Comment or uncomment current selection: Ctrl+Shift+C (Windows) or Cmd+Shift+C (Mac)
```
```{r analysis_plan, include=FALSE}
##------New update------
# Use the Axillary micromets v4.xlsx dataset. The sample size is 102.
# Add new variables: Locoregional_recurrence_2, LRRDeath, T2LRRDeath
# Re-run all analysis sections
# Plot a survival curve showing the time to locoregional recurrence (in months)
```
```{r attach_libraries_functions, include=FALSE}
easypackages::libraries("BTKR", "multcomp", "readxl", "tidyverse",
"bannerCommenter", "survival", "parallel",
"formatR", "future.apply", "ragg", "ggsurvfit")
source("../BTKR_function/fsmry.dmgrph.rowprop.R")
"%_%" <- function(m, n) paste0(m, "_", n)
"%0%" <- function(m, n) paste0(m, n)
uni.coxph <- function(surv.time, surv.event) {
out <- mclapply(1:length(vars.ana),
function(i) {
vars.missing <- ifelse(is.na(dat.work[, vars.ana[i]]),
"missing", "non.missing") %>%
factor(levels = c("non.missing", "missing"))
res.i <- coxph(formula("Surv(" %0% surv.time %0% "," %0% surv.event %0% ") ~ " %0% vars.ana[i]),
data = dat.work)
if(any(vars.missing == "missing")) {
res.i.miss <- coxph(formula("Surv(" %0% surv.time %0% "," %0% surv.event %0% ") ~ vars.missing"),
data = dat.work)
return(list(res.i, res.i.miss))
} else {
return(list(res.i))
}
},
mc.cores = 4L)
names(out) <- vars.ana
return(out)
}
##------Set customized theme for all plots------
theme_set(theme_classic())
theme_update(
legend.position = c(0.75, 0.35),
strip.background = element_blank(),
axis.text = element_text(size = 12),
axis.title = element_text(size = 14),
legend.text = element_text(size = 12))
theme.list <- theme_get()
##------Modify P-value formatting function------
format_number <- function (x, digits = 0) {
numform::round2(x, digits = digits) %>%
format(nsmall = digits, scientific = FALSE, trim = TRUE)
}
format_p2 <- function (x, digits = 1) {
if (digits == 1) {
p_fmt <- dplyr::case_when(
x > 1 + 1e-15 ~ NA_character_,
x < 0 - 1e-15 ~ NA_character_,
x > 0.9 ~ paste0(">", format_number(x = 0.9, digits = 1)),
round(x, 1) >= 0.2 ~ format_number(x, digits = 3),
round(x, 2) >= 0.1 ~ format_number(x, digits = 3),
x >= 0.001 ~ format_number(x, digits = 3), x < 0.001 ~ paste0("<", format_number(x = 0.001, digits = 3)))
}
else if (digits == 2) {
p_fmt <- dplyr::case_when(
x > 1 + 1e-15 ~ NA_character_,
x < 0 - 1e-15 ~ NA_character_,
x > 0.99 ~ paste0(">", format_number(x = 0.99, digits = 2)),
round2(x, 2) >= 0.1 ~ format_number(x, digits = 2),
x >= 0.001 ~ format_number(x, digits = 3),
x < 0.001 ~ paste0("<", format_number(x = 0.001, digits = 3)))
}
else if (digits == 3) {
p_fmt <- dplyr::case_when(
x > 1 + 1e-15 ~ NA_character_,
x < 0 - 1e-15 ~ NA_character_,
x > 0.999 ~ paste0(">", format_number(x = 0.999, digits = 3)),
x >= 0.001 ~ format_number(x, digits = 3),
x < 0.001 ~ paste0("<", format_number(x = 0.001, digits = 3)))
}
else {
stop("The `digits=` argument must be 1, 2, or 3.")
}
p_fmt
}
```
```{r check_data, include=FALSE}
dat0 = dat.work = dget("../data/derived/2023Oct16_dat_micromets.Rdata")
```
```{r global_options, include=FALSE}
#################################################################
## Automator ##
#################################################################
if (params$plot.fig) {
dir.fig <- "../report/figs" %_% params$date.analysis %0% "/"
# Need "/", otherwise, the images are saved directly under the report folder
if (!dir.exists(dir.fig)) {
# If the figure directory does not exist, we create a new directory under the folder report using the name figs + current date passed from the params$date.analysis in YAML
dir.create(dir.fig)
}
knitr::opts_chunk$set( # Setting parameters when figures are plotted
fig.width = 4, fig.height = 4,
fig.path = dir.fig, dev = "png", dpi = 300,
echo = FALSE, warning = FALSE, message = FALSE,
cache = FALSE,
comment = ""
)
} else { # Setting parameters when figures are not plotted
knitr::opts_chunk$set(
echo = FALSE, warning = FALSE, message = FALSE,
cache = FALSE,
comment = ""
)
}
if (params$results.folder) { # Suitable when the results need to be stored outside the microsoft word report
dir.result <- "../report/results" %_% params$date.analysis
if (!dir.exists(dir.result)) {
# If the directory does not exist, we create a new directory under the folder report using the name results + current date passed from the params$date.analysis in YAML
dir.create(dir.result)
}
}
```
# Data preparation
```{r, clean_data_start, eval=FALSE}
##------Clean data------
# table(dat0$Age_Dx_Grp_2, useNA = "ifany")
dat0 <- readxl::read_xlsx(
"../data/raw/Axillary micromets\ v4.xlsx", # \ escape
sheet = "Coded v4",
range = c("A1:BC103"),
col_names = T,
na = c("Unknown", "unknown", "N/A", "n/a")
)
dat0 <- dat0 |>
mutate(
Age_dx_grp_1 = case_when(Age_Dx_10yr_Groups == 2 ~ "20-29",
Age_Dx_10yr_Groups == 3 ~ "30-39",
Age_Dx_10yr_Groups == 4 ~ "40-49",
Age_Dx_10yr_Groups == 5 ~ "50-59",
Age_Dx_10yr_Groups == 6 ~ "60-69",
Age_Dx_10yr_Groups == 7 ~ "70-79",
Age_Dx_10yr_Groups == 8 ~ "80-89",
Age_Dx_10yr_Groups == 9 ~ "90+") %>%
factor(levels = c("20-29", "30-39", "40-49", "50-59", "60-69", "70-79", "80-89", "90+")
)) %>%
mutate(
Age_dx_grp_2 = ifelse(Age_Dx < 40, "<40", "≥40") %>%
factor(levels = c("<40", "≥40")
)) %>%
mutate(
Age_dx_grp_3 = ifelse(Age_Dx < 45, "<45", "≥45") %>%
factor(levels = c("<45", "≥45")
)) %>%
mutate(
Age_dx_grp_4 = ifelse(Age_Dx < 50, "<50", "≥50") %>%
factor(levels = c("<50", "≥50")
)) %>%
mutate(
Race_2 = case_when(Race == 0 ~ "Asian",
Race == 1 ~ "Non-hispanic black",
Race == 2 ~ "Non-hispanic white",
Race == 3 ~ "Hispanic",
Race == 4 ~ "Other",
Race == 5 ~ as.character(NA)) %>%
factor(levels = c("Asian", "Non-hispanic black", "Non-hispanic white", "Hispanic", "Other")
)) %>%
mutate(
Sex_2 = ifelse(Sex == 0, "Female", "Male") %>%
factor(levels = c("Female", "Male")
)) %>%
mutate(
Menopausal_2 = case_when(Menopausal == 0 ~ "Pre",
Menopausal == 1 ~ "Post",
Menopausal == 2 ~ as.character(NA)) %>%
factor(levels = c("Pre", "Post")
)) %>%
mutate(
Screened_2 = case_when(Screened == 0 ~ "No",
Screened == 1 ~ "Yes",
Screened == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Multiple_index_2 = ifelse(Multiple_index == 0, "No", "Yes") %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Bilateral_cancer_2 = ifelse(Bilateral_Cancer == 0, "No", "Yes") %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Index_status_2 = ifelse(Idx_status == 0, "New primary cancer", "Local recurrence") %>%
factor(levels = c("New primary cancer", "Local recurrence")
)) %>%
mutate(
Prior_breast_cancer_2 = ifelse(Prior_breast_Ca == 0, "No", "Yes") %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Tumor_type_2 = case_when(Tumor_type == 0 ~ "DCIS",
Tumor_type == 1 ~ "IDC",
Tumor_type == 2 ~ "ILC",
Tumor_type == 3 ~ "IDC/ILC",
Tumor_type == 4 ~ "Mammary",
Tumor_type == 5 ~ "Other") %>%
factor(levels = c("DCIS", "IDC", "ILC", "IDC/ILC", "Mammary", "Other")
)) %>%
mutate(
Nodal_mets_dx_2 = ifelse(`Nodal_mets _at_Dx` == 0, "No", "Yes") %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Histo_grade_2 = case_when(Histo_grade == 1 ~ "Grade1",
Histo_grade == 2 ~ "Grade2",
Histo_grade == 3 ~ "Grade3",
Histo_grade == 4 ~ as.character(NA)) %>%
factor(levels = c("Grade1", "Grade2", "Grade3")
)) %>%
mutate(
ER_2 = case_when(ER == 0 ~ "Negative",
ER == 1 ~ "Positive",
ER == 2 ~ as.character(NA)) %>%
factor(levels = c("Negative", "Positive")
)) %>%
mutate(
PR_2 = case_when(PR == 0 ~ "Negative",
PR == 1 ~ "Positive",
PR == 2 ~ as.character(NA)) %>%
factor(levels = c("Negative", "Positive")
)) %>%
mutate(
HER2_2 = case_when(HER2 == 0 ~ "Negative",
HER2 == 1 ~ "Positive",
HER2 == 2 ~ as.character(NA)) %>%
factor(levels = c("Negative", "Positive")
)) %>%
mutate(
TNBC = case_when(
# Check the distributions of estrogen receptor, progesterone receptor, and protein HER2
# with(dat0, table(ER_2, PR_2, HER2_2, useNA = "ifany"))
is.na(ER_2) & is.na(PR_2) & HER2_2 %in% c("Negative", NA) ~ as.character(NA),
ER_2 == "Negative" & PR_2 == "Negative" & HER2_2 == "Negative" ~ "Triple negative",
TRUE ~ "Non-triple negative") %>%
factor(levels = c("Triple negative", "Non-triple negative")
)) %>%
mutate(
Ki67_2 = case_when(Ki_67 == 0 ~ "Ki67≤10%",
Ki_67 == 1 ~ "Ki67>10%",
Ki_67 == 2 ~ as.character(NA)) %>%
factor(levels = c("Ki67≤10%", "Ki67>10%")
)) %>%
mutate(
LVI_2 = case_when(LVI == 0 ~ "No",
LVI == 1 ~ "Yes",
LVI == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
ALND_2 = case_when(Completion_ALND == 0 ~ "No",
Completion_ALND == 1 ~ "Yes",
Completion_ALND == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
N_clinical_2 = gsub("c1|c2A", "c1/c2", `N Class - Clinical`) %>%
factor(levels = c("c0", "c1/c2", "cX"),
labels = c("cN0", "cN1/cN2", "cNX") # Large sample size -> reference group
)) %>%
mutate(
T_clinical_2 = gsub("1|c0|c1|c1A|c1b|c1B|c1c|c1C|c1mi|c2|cTis|pIS|Tis", "T0/Tis/T1/T2",
gsub("c3|c4D", "T3/T4",
gsub("cx|cX", "TX", `T Class - Clinical`))) %>%
factor(levels = c("T0/Tis/T1/T2", "T3/T4", "TX")) # Large sample size -> reference group
) %>%
mutate(
Neoadjuvant_chemo_2 = case_when(Neoadjuvent_Chemo == 0 ~ "No",
Neoadjuvent_Chemo == 1 ~ "Yes",
Neoadjuvent_Chemo == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Neoadjuvant_endocrine_2 = case_when(Neoadjuvent_endocrine == 0 ~ "No",
Neoadjuvent_endocrine == 1 ~ "Yes",
Neoadjuvent_endocrine == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Neoadjuvant_treatment = case_when(Neoadjuvant_chemo_2 == "Yes" ~ "ChemoYes",
Neoadjuvant_endocrine_2 == "Yes" ~ "EndocrineYes",
Neoadjuvant_chemo_2 == "Yes" & Neoadjuvant_endocrine_2 == "Yes" ~ "Both",
Neoadjuvant_chemo_2 == "No" & Neoadjuvant_endocrine_2 == "No" ~ "Neither") %>%
factor(levels = c("ChemoYes", "EndocrineYes", "Both", "Neither")
)) %>%
mutate(
Neoadjuvant_antiHER2_2 = case_when(`Neoadjuvent_anti-HER2` == 0 ~ "No",
`Neoadjuvent_anti-HER2` == 1 ~ "Yes",
`Neoadjuvent_anti-HER2` == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Neoadjuvant_XRT_2 = case_when(Neoadjuvent_XRT == 0 ~ "No",
Neoadjuvent_XRT == 1 ~ "Yes",
Neoadjuvent_XRT == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Adjuvant_chemo_2 = case_when(Adjuvent_Chemo == 0 ~ "No",
Adjuvent_Chemo == 1 ~ "Yes",
Adjuvent_Chemo == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Adjuvant_endocrine_2 = case_when(Adjuvent_Endocrine == 0 ~ "No",
Adjuvent_Endocrine == 1 ~ "Yes",
Adjuvent_Endocrine == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Adjuvant_treatment = case_when(Adjuvant_chemo_2 == "Yes" ~ "ChemoYes",
Adjuvant_endocrine_2 == "Yes" ~ "EndocrineYes",
Adjuvant_chemo_2 == "Yes" & Adjuvant_endocrine_2 == "Yes" ~ "Both",
Adjuvant_chemo_2 == "No" & Adjuvant_endocrine_2 == "No" ~ "Neither") %>%
factor(levels = c("ChemoYes", "EndocrineYes", "Both", "Neither")
)) %>%
mutate(
Adjuvant_antiHER2_2 = case_when(`Adjuvent_anti-HER2` == 0 ~ "No",
`Adjuvent_anti-HER2` == 1 ~ "Yes",
`Adjuvent_anti-HER2` == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Adjuvant_XRT_2 = case_when(Adjuvent_XRT == 0 ~ "No",
Adjuvent_XRT == 1 ~ "Yes",
Adjuvent_XRT == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Local_recurrence_2 = case_when(`Local recurrence` == 0 ~ "No",
`Local recurrence` == 1 ~ "Yes",
`Local recurrence` == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Axillary_recurrence_2 = case_when(`Axillary Recurrence` == 0 ~ "No",
`Axillary Recurrence` == 1 ~ "Yes",
`Axillary Recurrence` == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
##------Add and recode the locoregional recurrence------
mutate(
Locoregional_recurrence_2 = case_when(`Locoregional recurrence` == 0 ~ "No",
`Locoregional recurrence` == 1 ~ "Yes",
`Locoregional recurrence` == 2 ~ as.character(NA)) |>
factor(levels = c("No", "Yes")
)) |>
mutate(
Distant_recurrence_2 = case_when(DR == 0 ~ "No",
DR == 1 ~ "Yes",
DR == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
New_breast_cancer_2 = case_when(NewBC == 0 ~ "No",
NewBC == 1 ~ "Yes",
NewBC == 2 ~ as.character(NA)) %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
Addition_pos_node_2 = ifelse(`how many additional positive nodes removed` %in% c(NA, 0), "No", "Yes") %>%
factor(levels = c("No", "Yes")
)) %>%
mutate(
ALND_adjuvantXRT = case_when(ALND_2 == "No" & Adjuvant_XRT_2 == "No" ~ "No ALND, no adjuvant XRT",
ALND_2 == "No" & Adjuvant_XRT_2 == "Yes" ~ "No ALND, yes adjuvant XRT",
ALND_2 == "Yes" & Adjuvant_XRT_2 == "No" ~ "Yes ALND, no adjuvant XRT",
ALND_2 == "Yes" & Adjuvant_XRT_2 == "Yes" ~ "Yes ALND, yes adjuvant XRT") %>%
factor(levels = c("No ALND, no adjuvant XRT",
"No ALND, yes adjuvant XRT",
"Yes ALND, no adjuvant XRT",
"Yes ALND, yes adjuvant XRT")
)) %>%
mutate(
ALND_age40 = case_when(ALND_2 == "No" & Age_dx_grp_2 == "<40" ~ "No ALND, age<40",
ALND_2 == "No" & Age_dx_grp_2 == "≥40" ~ "No ALND, age≥40",
ALND_2 == "Yes" & Age_dx_grp_2 == "<40" ~ "Yes ALND, age<40",
ALND_2 == "Yes" & Age_dx_grp_2 == "≥40" ~ "Yes ALND, age≥40") %>%
factor(levels = c("No ALND, age<40",
"No ALND, age≥40",
"Yes ALND, age<40",
"Yes ALND, age≥40")
)) %>%
mutate(
ALND_age45 = case_when(ALND_2 == "No" & Age_dx_grp_3 == "<45" ~ "No ALND, age<45",
ALND_2 == "No" & Age_dx_grp_3 == "≥45" ~ "No ALND, age≥45",
ALND_2 == "Yes" & Age_dx_grp_3 == "<45" ~ "Yes ALND, age<45",
ALND_2 == "Yes" & Age_dx_grp_3 == "≥45" ~ "Yes ALND, age≥45") %>%
factor(levels = c("No ALND, age<45",
"No ALND, age≥45",
"Yes ALND, age<45",
"Yes ALND, age≥45")
)) %>%
mutate(
ALND_age50 = case_when(ALND_2 == "No" & Age_dx_grp_4 == "<50" ~ "No ALND, age<50",
ALND_2 == "No" & Age_dx_grp_4 == "≥50" ~ "No ALND, age≥50",
ALND_2 == "Yes" & Age_dx_grp_4 == "<50" ~ "Yes ALND, age<50",
ALND_2 == "Yes" & Age_dx_grp_4 == "≥50" ~ "Yes ALND, age≥50") %>%
factor(levels = c("No ALND, age<50",
"No ALND, age≥50",
"Yes ALND, age<50",
"Yes ALND, age≥50")
)) %>%
mutate(
ALND_adjuvantXRT_age40 = case_when(
ALND_adjuvantXRT == "No ALND, no adjuvant XRT" & Age_dx_grp_2 == "<40" ~ "No ALND, no adjuvant XRT, age<40",
ALND_adjuvantXRT == "No ALND, no adjuvant XRT" & Age_dx_grp_2 == "≥40" ~ "No ALND, no adjuvant XRT, age≥40",
ALND_adjuvantXRT == "No ALND, yes adjuvant XRT" & Age_dx_grp_2 == "<40" ~ "No ALND, yes adjuvant XRT, age<40",
ALND_adjuvantXRT == "No ALND, yes adjuvant XRT" & Age_dx_grp_2 == "≥40" ~ "No ALND, yes adjuvant XRT, age≥40",
ALND_adjuvantXRT == "Yes ALND, no adjuvant XRT" & Age_dx_grp_2 == "<40" ~ "Yes ALND, no adjuvant XRT, age<40",
ALND_adjuvantXRT == "Yes ALND, no adjuvant XRT" & Age_dx_grp_2 == "≥40" ~ "Yes ALND, no adjuvant XRT, age≥40",
ALND_adjuvantXRT == "Yes ALND, yes adjuvant XRT" & Age_dx_grp_2 == "<40" ~ "Yes ALND, Yes adjuvant XRT, age<40",
ALND_adjuvantXRT == "Yes ALND, yes adjuvant XRT" & Age_dx_grp_2 == "≥40" ~ "Yes ALND, Yes adjuvant XRT, age≥40") %>%
factor(levels = c("No ALND, no adjuvant XRT, age<40",
"No ALND, no adjuvant XRT, age≥40",
"No ALND, yes adjuvant XRT, age<40",
"No ALND, yes adjuvant XRT, age≥40",
"Yes ALND, no adjuvant XRT, age<40",
"Yes ALND, no adjuvant XRT, age≥40",
"Yes ALND, Yes adjuvant XRT, age<40",
"Yes ALND, Yes adjuvant XRT, age≥40")
)) %>%
mutate(
ALND_adjuvantXRT_age45 = case_when(
ALND_adjuvantXRT == "No ALND, no adjuvant XRT" & Age_dx_grp_3 == "<45" ~ "No ALND, no adjuvant XRT, age<45",
ALND_adjuvantXRT == "No ALND, no adjuvant XRT" & Age_dx_grp_3 == "≥45" ~ "No ALND, no adjuvant XRT, age≥45",
ALND_adjuvantXRT == "No ALND, yes adjuvant XRT" & Age_dx_grp_3 == "<45" ~ "No ALND, yes adjuvant XRT, age<45",
ALND_adjuvantXRT == "No ALND, yes adjuvant XRT" & Age_dx_grp_3 == "≥45" ~ "No ALND, yes adjuvant XRT, age≥45",
ALND_adjuvantXRT == "Yes ALND, no adjuvant XRT" & Age_dx_grp_3 == "<45" ~ "Yes ALND, no adjuvant XRT, age<45",
ALND_adjuvantXRT == "Yes ALND, no adjuvant XRT" & Age_dx_grp_3 == "≥45" ~ "Yes ALND, no adjuvant XRT, age≥45",
ALND_adjuvantXRT == "Yes ALND, yes adjuvant XRT" & Age_dx_grp_3 == "<45" ~ "Yes ALND, Yes adjuvant XRT, age<45",
ALND_adjuvantXRT == "Yes ALND, yes adjuvant XRT" & Age_dx_grp_3 == "≥45" ~ "Yes ALND, Yes adjuvant XRT, age≥45") %>%
factor(levels = c("No ALND, no adjuvant XRT, age<45",
"No ALND, no adjuvant XRT, age≥45",
"No ALND, yes adjuvant XRT, age<45",
"No ALND, yes adjuvant XRT, age≥45",
"Yes ALND, no adjuvant XRT, age<45",
"Yes ALND, no adjuvant XRT, age≥45",
"Yes ALND, Yes adjuvant XRT, age<45",
"Yes ALND, Yes adjuvant XRT, age≥45")
)) %>%
mutate(
ALND_adjuvantXRT_age50 = case_when(
ALND_adjuvantXRT == "No ALND, no adjuvant XRT" & Age_dx_grp_4 == "<50" ~ "No ALND, no adjuvant XRT, age<50",
ALND_adjuvantXRT == "No ALND, no adjuvant XRT" & Age_dx_grp_4 == "≥50" ~ "No ALND, no adjuvant XRT, age≥50",
ALND_adjuvantXRT == "No ALND, yes adjuvant XRT" & Age_dx_grp_4 == "<50" ~ "No ALND, yes adjuvant XRT, age<50",
ALND_adjuvantXRT == "No ALND, yes adjuvant XRT" & Age_dx_grp_4 == "≥50" ~ "No ALND, yes adjuvant XRT, age≥50",
ALND_adjuvantXRT == "Yes ALND, no adjuvant XRT" & Age_dx_grp_4 == "<50" ~ "Yes ALND, no adjuvant XRT, age<50",
ALND_adjuvantXRT == "Yes ALND, no adjuvant XRT" & Age_dx_grp_4 == "≥50" ~ "Yes ALND, no adjuvant XRT, age≥50",
ALND_adjuvantXRT == "Yes ALND, yes adjuvant XRT" & Age_dx_grp_4 == "<50" ~ "Yes ALND, Yes adjuvant XRT, age<50",
ALND_adjuvantXRT == "Yes ALND, yes adjuvant XRT" & Age_dx_grp_4 == "≥50" ~ "Yes ALND, Yes adjuvant XRT, age≥50") %>%
factor(levels = c("No ALND, no adjuvant XRT, age<50",
"No ALND, no adjuvant XRT, age≥50",
"No ALND, yes adjuvant XRT, age<50",
"No ALND, yes adjuvant XRT, age≥50",
"Yes ALND, no adjuvant XRT, age<50",
"Yes ALND, no adjuvant XRT, age≥50",
"Yes ALND, Yes adjuvant XRT, age<50",
"Yes ALND, Yes adjuvant XRT, age≥50")
)) %>%
mutate(Death_2 = ifelse(Death_from_BC == 0, "No", "Yes") %>%
factor(levels = c("No", "Yes")
)) %>%
data.frame()
##------Recode ARDeath/LRDeath/LRRDeath/DRDeath------
table(dat0$Axillary_recurrence_2, dat0$Death_2, useNA = "ifany")
dat0$ARDeath <- NA
dat0$ARDeath[dat0$Axillary_recurrence_2 == "Yes" | dat0$Death_2 == "Yes"] <- 1
dat0$ARDeath[dat0$Axillary_recurrence_2 == "No" & dat0$Death_2 == "No"] <- 0
table(dat0$ARDeath, useNA = "ifany")
table(dat0$Local_recurrence_2, dat0$Death_2, useNA = "ifany")
dat0$LRDeath <- NA
dat0$LRDeath[dat0$Local_recurrence_2 == "Yes" | dat0$Death_2 == "Yes"] <- 1
dat0$LRDeath[dat0$Local_recurrence_2 == "No" & dat0$Death_2 == "No"] <- 0
table(dat0$LRDeath, useNA = "ifany")
table(dat0$Locoregional_recurrence_2, dat0$Death_2, useNA = "ifany")
dat0$LRRDeath <- NA
dat0$LRRDeath[dat0$Locoregional_recurrence_2 == "Yes" | dat0$Death_2 == "Yes"] <- 1
dat0$LRRDeath[dat0$Locoregional_recurrence_2 == "No" & dat0$Death_2 == "No"] <- 0
table(dat0$LRRDeath, useNA = "ifany")
table(dat0$Distant_recurrence_2, dat0$Death_2, useNA = "ifany")
dat0$DRDeath <- NA
dat0$DRDeath[dat0$Distant_recurrence_2 == "Yes" | dat0$Death_2 == "Yes"] <- 1
dat0$DRDeath[dat0$Distant_recurrence_2 == "No" & dat0$Death_2 == "No"] <- 0
table(dat0$DRDeath, useNA = "ifany")
##------Recode T2ARDeath/T2LRDeath/T2LRRDeath/T2DRDeath------
dat0 <- dat0 %>%
mutate(
T2ARDeath = case_when(
(Axillary_recurrence_2 == "Yes" & Death_2 == "No") ~ `Time_to_AXR`,
(Axillary_recurrence_2 == "Yes" & Death_2 == "Yes") ~ `Time_to_AXR`,
(Death_2 == "Yes" & Axillary_recurrence_2 == "No") ~ `Time_to_death`,
ARDeath == 0 ~ `Follow_up_time..days.`))
# Check the number of patients not at risk
summary(dat0$T2ARDeath)
dat0 <- dat0 %>%
mutate(
T2LRDeath = case_when(
(Local_recurrence_2 == "Yes" & Death_2 == "No") ~ `Time_to_LR`,
(Local_recurrence_2 == "Yes" & Death_2 == "Yes") ~ `Time_to_LR`,
(Death_2 == "Yes" & Local_recurrence_2 == "No") ~ `Time_to_death`,
LRDeath == 0 ~ `Follow_up_time..days.`))
summary(dat0$T2LRDeath)
dat0 <- dat0 %>%
mutate(
T2LRRDeath = case_when(
(Locoregional_recurrence_2 == "Yes" & Death_2 == "No") ~ `Time_to_LRR..months.`,
(Locoregional_recurrence_2 == "Yes" & Death_2 == "Yes") ~ `Time_to_LRR..months.`,
(Death_2 == "Yes" & Locoregional_recurrence_2 == "No") ~ `Time_to_death`,
LRRDeath == 0 ~ `Follow_up_time..days.`))
summary(dat0$T2LRRDeath)
dat0 <- dat0 %>%
mutate(
T2DRDeath = case_when(
(Distant_recurrence_2 == "Yes" & Death_2 == "No") ~ `Time_to_DR`,
(Distant_recurrence_2 == "Yes" & Death_2 == "Yes") ~ `Time_to_DR`,
(Death_2 == "Yes" & Distant_recurrence_2 == "No") ~ `Time_to_death`,
DRDeath == 0 ~ `Follow_up_time..days.`))
summary(dat0$T2DRDeath)
##------Fix column names and orders------
names(dat0) <-
sapply(strsplit(names(dat0), split = "\\."), function(x)
paste(x[x != ""], collapse = "."))
dat0 <- dat0 %>%
select(
"Record.ID", everything()
)
##------Save data------
date.analysis <- format(Sys.Date(), "%Y%b%d")
dput(dat0, paste0("../data/derived/", date.analysis, "_dat_micromets.Rdata"))
write.csv(dat0, paste0("../data/derived/", date.analysis, "_dat_micromets.csv"), row.names = F)
```
```{r load_cleaned_data}
dat.work <- dget("../data/derived/2023Oct16_dat_micromets.Rdata")
```
```{r results="hide"}
##------Set study variables------
vars.all <- c(
### Demographical variables
# "Age_Dx",
"Age_dx_grp_1", "Age_dx_grp_2", "Age_dx_grp_3", "Age_dx_grp_4",
"Race_2", "Sex_2", "Menopausal_2", "Follow_up_time.days",
### Disease history variables
"T_clinical_2", "N_clinical_2",
"ER_2", "PR_2", "HER2_2", "TNBC",
"Tumor_Size.mm",
"Tumor_type_2",
"Nodal_mets_dx_2",
"Histo_grade_2",
"Ki67_2",
"LVI_2",
"Multiple_index_2",
"Bilateral_cancer_2",
"Index_status_2",
"Prior_breast_cancer_2",
### Screening/diagnosis/treatment variables
"Screened_2",
"ALND_2",
"ALND_age40", "ALND_age45", "ALND_age50",
"Addition_pos_node_2",
"Adjuvant_XRT_2", "Adjuvant_treatment",
"Adjuvant_chemo_2", "Adjuvant_endocrine_2", "Adjuvant_antiHER2_2",
"Neoadjuvant_XRT_2", "Neoadjuvant_treatment",
"Neoadjuvant_chemo_2", "Neoadjuvant_endocrine_2", "Neoadjuvant_antiHER2_2",
"ALND_adjuvantXRT",
"ALND_adjuvantXRT_age40", "ALND_adjuvantXRT_age45", "ALND_adjuvantXRT_age50",
### Disease outcome variables
"Axillary_recurrence_2", "Local_recurrence_2", "Locoregional_recurrence_2",
"Distant_recurrence_2", "New_breast_cancer_2"
)
# Create an indicator [0, 1] for all categorical variables
vars.cat <- rep(1, length(vars.all))
vars.cat[vars.all %in% c("Age_Dx", "Follow_up_time.days", "Tumor_Size.mm")] <- 0
```
The association between a categorical variable and a grouping variable (i.e., completion of axillary lymph node dissection (ALND)) was examined using the Fisher’s exact test. Difference in the value of a continuous variable among patients of different groups was examined using the Wilcoxon rank sum test (p-value is aligned with the median (IQR) summmaries in the following table). For variable with missing values, the difference in the proportion of missingness across different groups was also examined.
In our univariate survival analysis, the axillary/local/**locoregional**/distant recurrence-free survival time is defined as a composite endpoint which combines the time to axillary/local/locoregional/distant recurrence, time to death, and time to last follow-up into a univariate time to the first event or censoring. To illustrate how this combination of time works, we enumerate different scenarios for calculating the axillary recurrence-free survival time. The same logic applies to the other 3 types of recurrence.
For axillary recurrence-free survival time:
* Given that 1 patient has the axillary recurrence but does not die, the time to axillary recurrence is treated as the survival time.
* Given that 5 patients die without the axillary recurrence, the time to death is treated as their survival time.
* Given that 1 patient first has the axillary recurrence and then dies, the time to axillary recurrence is treated as the survival time.
* Given that 115 patients neither have the axillary recurrence or die, the time to last follow-up is treated as their survival time.
* Given that 6 patients die but miss the information on the axillary recurrence, their survival time is treated as not available.
# Patient characteristics tables
## Patients characteristics by axillary lymph node dissection (column proportion)
```{r, results="hide"}
# Create a summary table by ALND_2
vars.cat.rm <- which(vars.all %in% c(
"ALND_2",
"ALND_adjuvantXRT",
"ALND_age40",
"ALND_age45",
"ALND_age50",
"ALND_adjuvantXRT_age40",
"ALND_adjuvantXRT_age45",
"ALND_adjuvantXRT_age50"))
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all[-vars.cat.rm],
vars.cat = vars.cat[-vars.cat.rm],
by = "ALND_2")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection (row proportion)
```{r, results="hide"}
vars.cat.rm <- which(vars.all %in% c(
"ALND_2",
"ALND_adjuvantXRT",
"ALND_age40",
"ALND_age45",
"ALND_age50",
"ALND_adjuvantXRT_age40",
"ALND_adjuvantXRT_age45",
"ALND_adjuvantXRT_age50",
"Neoadjuvant_treatment")) # Error in fisher.test(y.by.grp, simulate.p.value = TRUE) : need 2 or more non-zero row marginals
out <- fsmry.dmgrph.rowprop(dat = dat.work,
vars = vars.all[-vars.cat.rm],
vars.cat = vars.cat[-vars.cat.rm],
by = "ALND_2")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by post-mastectomy radiation therapy (column proportion)
```{r, results="hide"}
# Create a summary table by Adjuvant_XRT_2
vars.cat.rm <- which(vars.all %in% c(
"Adjuvant_XRT_2",
"ALND_adjuvantXRT",
"ALND_age40",
"ALND_age45",
"ALND_age50",
"ALND_adjuvantXRT_age40",
"ALND_adjuvantXRT_age45",
"ALND_adjuvantXRT_age50"))
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all[-vars.cat.rm],
vars.cat = vars.cat[-vars.cat.rm],
by = "Adjuvant_XRT_2")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by post-mastectomy radiation therapy (row proportion)
```{r, results="hide"}
vars.cat.rm <- which(vars.all %in% c(
"ALND_2",
"ALND_adjuvantXRT",
"ALND_age40",
"ALND_age45",
"ALND_age50",
"ALND_adjuvantXRT_age40",
"ALND_adjuvantXRT_age45",
"ALND_adjuvantXRT_age50",
"Neoadjuvant_treatment")) # Error in fisher.test(y.by.grp, simulate.p.value = TRUE) : need 2 or more non-zero row marginals
out <- fsmry.dmgrph.rowprop(dat = dat.work,
vars = vars.all[-vars.cat.rm],
vars.cat = vars.cat[-vars.cat.rm],
by = "Adjuvant_XRT_2")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection and post-mastectomy radiation therapy
```{r, results="hide"}
# Create a summary table by ALND_adjuvantXRT
vars.all2 <- c(
# "Age_Dx",
"Age_dx_grp_1", "Age_dx_grp_2", "Age_dx_grp_3", "Age_dx_grp_4",
"Race_2", "Sex_2", "Menopausal_2",
# "Follow_up_time.days",
"T_clinical_2", "N_clinical_2",
"ER_2", "PR_2", "HER2_2", "TNBC",
# "Tumor_Size.mm",
"Tumor_type_2",
"Nodal_mets_dx_2",
"Histo_grade_2",
"Ki67_2",
"LVI_2",
"Multiple_index_2",
"Bilateral_cancer_2",
"Index_status_2",
"Prior_breast_cancer_2",
"Screened_2",
"ALND_2",
"ALND_age40", "ALND_age45", "ALND_age50",
"Addition_pos_node_2",
"Adjuvant_XRT_2", "Adjuvant_treatment",
"Adjuvant_chemo_2", "Adjuvant_endocrine_2", "Adjuvant_antiHER2_2",
"Neoadjuvant_XRT_2", "Neoadjuvant_treatment",
"Neoadjuvant_chemo_2", "Neoadjuvant_endocrine_2", "Neoadjuvant_antiHER2_2",
"ALND_adjuvantXRT",
"ALND_adjuvantXRT_age40", "ALND_adjuvantXRT_age45", "ALND_adjuvantXRT_age50",
"Axillary_recurrence_2", "Local_recurrence_2", "Locoregional_recurrence_2",
"Distant_recurrence_2", "New_breast_cancer_2"
)
vars.cat.rm <- which(vars.all2 %in% c(
"Adjuvant_XRT_2",
"ALND_adjuvantXRT",
"ALND_age40",
"ALND_age45",
"ALND_age50",
"ALND_adjuvantXRT_age40",
"ALND_adjuvantXRT_age45",
"ALND_adjuvantXRT_age50"))
#################################################################
## Problem ##
#################################################################
# Error in wilcox.test.default(y1, y2, exact = F) :
# not enough (non-missing) 'x' observations
# In addition: Warning messages:
# 1: In `==.default`(grp, grp.names1) :
# longer object length is not a multiple of shorter object length
# 2: In is.na(e1) | is.na(e2) :
# longer object length is not a multiple of shorter object length
# Create an indicator [0, 1] for all categorical variables
vars.cat <- rep(1, length(vars.all2))
vars.cat[vars.all2 %in% c("Age_Dx", "Follow_up_time.days", "Tumor_Size.mm")] <- 0
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm],
vars.cat = vars.cat[-vars.cat.rm],
by = "ALND_adjuvantXRT")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection and age (<40 versus ≥40)
```{r, results="hide"}
# Create a summary table by ALND_age40
vars.cat.rm.2 <- c(
vars.cat.rm,
which(vars.all2 %in% c("Age_dx_grp_1", "Age_dx_grp_2", "Age_dx_grp_3", "Age_dx_grp_4")))
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm.2],
vars.cat = vars.cat[-vars.cat.rm.2],
by = "ALND_age40")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection, post-mastectomy radiation therapy, and age (<40 versus ≥40)
```{r, results="hide"}
# Create a summary table by ALND_adjuvantXRT_age40
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm.2],
vars.cat = vars.cat[-vars.cat.rm.2],
by = "ALND_adjuvantXRT_age40")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection and age (<45 versus ≥45)
```{r, results="hide"}
# Create a summary table by ALND_age45
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm.2],
vars.cat = vars.cat[-vars.cat.rm.2],
by = "ALND_age45")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection, post-mastectomy radiation therapy, and age (<45 versus ≥45)
```{r, results="hide"}
# Create a summary table by ALND_adjuvantXRT_age45
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm.2],
vars.cat = vars.cat[-vars.cat.rm.2],
by = "ALND_adjuvantXRT_age45")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection and age (<50 versus ≥50)
```{r, results="hide"}
# Create a summary table by ALND_age50"
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm.2],
vars.cat = vars.cat[-vars.cat.rm.2],
by = "ALND_age50")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
## Patients characteristics by axillary lymph node dissection, post-mastectomy radiation therapy, and age (<50 versus ≥50)
```{r, results="hide"}
# Create a summary table by ALND_adjuvantXRT_age50
out <- fsmry.dmgrph(dat = dat.work,
vars = vars.all2[-vars.cat.rm.2],
vars.cat = vars.cat[-vars.cat.rm.2],
by = "ALND_adjuvantXRT_age50")
```
```{r, results="asis"}
knitr::kable(out[[1]], row.names = F)
```
# Univariate analysis for recurrence free survival
Note that patients without time to axillary/local/locoregional/distant recurrence data were not included in the analysis. The association between each variable and axillary/local/locoregional/distant recurrence free survival was assessed using the log rank test. The Cox-proportional hazards model was used to estimate the HR and corresponding 95% CI for each unit increase of a continuous variable, or with respect to the reference category for a categorical variable. For each variable, if there were missing values, the association between missingness and axillary/local/locoregional/distant recurrence free survival was also examined.
## Associations between variables and axillary recurrence
```{r, results="hide"}
##################################################################
## Reset the Age_dx_grp_1 reference level ##
##################################################################
# In cox regression modeling, to prevent the 95% CI of HR estimate approximating infinity, the reference category of a covariate may have the **adequate sample size** and/or **adequate outcomes**.
# How to define the **adequacy**?
# An events per variable of 10 is widely advocated as the rule of thumb for multivariable Cox regression analyses.
# Reference: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5045274/
table(dat.work$Age_dx_grp_1, dat.work$Axillary_recurrence_2)
dat.work$Age_dx_grp_1 <- relevel(dat.work$Age_dx_grp_1, ref = "70-79")
# dat.work$Age_dx_grp_1 <- relevel(dat.work$Age_dx_grp_1, ref = "40-49")
# dat.work$Age_dx_grp_1 <- relevel(dat.work$Age_dx_grp_1, ref = "50-59")
# dat.work$Age_dx_grp_1 <- factor(dat.work$Age_dx_grp_1,
# levels = c("20-29", "30-39", "40-49", "50-59", "60-69", "70-79", "80-89", "90+")) # Recover the original level
#################################################################
## !!!Reset the Race_2 reference level ##
#################################################################
table(dat.work$Race_2, dat.work$Axillary_recurrence_2)
dat.work$Race_2 <- factor(dat.work$Race_2, levels = c("Non-hispanic white", "Non-hispanic black", "Asian", "Hispanic", "Other"))
# dat.work$Race_2 <- relevel(dat.work$Race_2, ref = "Non-hispanic black")
# dat.work$Race_2 <- factor(dat.work$Race_2, levels = c("Asian", "Non-hispanic black", "Non-hispanic white", "Hispanic", "Other")) # Original factor level
# !!! We lose significant findings for Non-hispanic black
```
```{r, uni.coxph, results="hide"}
vars.ana <- c(
"Age_Dx", "Age_dx_grp_1", "Age_dx_grp_2", "Age_dx_grp_3", "Age_dx_grp_4",
"Race_2", "Sex_2", "Menopausal_2",
"T_clinical_2", "N_clinical_2",
"ER_2", "PR_2", "HER2_2", "TNBC",
"Multiple_index_2",
"Bilateral_cancer_2",
"Index_status_2",
"Prior_breast_cancer_2",
"Tumor_type_2",
"Nodal_mets_dx_2",
"Histo_grade_2",
"Ki67_2",
"LVI_2",
"Tumor_Size.mm",
"Screened_2",
"ALND_2",
"Addition_pos_node_2",
"Adjuvant_XRT_2", "Adjuvant_chemo_2", "Adjuvant_endocrine_2", "Adjuvant_treatment", "Adjuvant_antiHER2_2",
"Neoadjuvant_XRT_2", "Neoadjuvant_chemo_2", "Neoadjuvant_endocrine_2", "Neoadjuvant_treatment", "Neoadjuvant_antiHER2_2"
)
out <- uni.coxph(surv.time = "T2ARDeath", surv.event = "ARDeath")
table(unlist(lapply(out, length)))
out.stat <- lapply(out, function(x) lapply(x, fcphuni.stat))
out.tbl <- lapply(out.stat, fcphuni.tbl)
out.tbl <- do.call(rbind, out.tbl)
row.names(out.tbl) <- NULL
```
```{r}
knitr::kable(out.tbl)
```
## Associations between variables and local recurrence
```{r, results="hide"}
##################################################################
## Recover the original reference level ##
##################################################################
dat.work$Age_dx_grp_1 <- factor(dat.work$Age_dx_grp_1,
levels = c("20-29", "30-39", "40-49", "50-59", "60-69", "70-79", "80-89", "90+"))
```
```{r, results="hide"}
out <- uni.coxph(surv.time = "T2LRDeath", surv.event = "LRDeath")
table(unlist(lapply(out, length)))
out.stat <- lapply(out, function(x) lapply(x, fcphuni.stat))