-
Notifications
You must be signed in to change notification settings - Fork 0
/
prop_detected_figures.R
124 lines (109 loc) · 5.6 KB
/
prop_detected_figures.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
source("packages.R")
source("utils.R")
source("plot_functions.R")
source("find_latest_results.R")
results_name <- "results_df"
most_recent_file <- file.info(list.files("results/", full.names = T)) %>%
as.data.frame() %>%
rownames_to_column()%>%
filter(str_detect(rowname,"_redo_inf.fst")) %>%
slice_max(mtime) %>%
pull(rowname)
assign(results_name,read.fst(most_recent_file) %>%
filter(stringency!="Pre-board only")
# mutate(
# assay = factor(assay, levels = c("Innova (KCL)", "PCR")),
# assay = fct_explicit_na(assay, "No testing"),
# pre_board_assay=replace_na(pre_board_assay,"No pre-flight testing"),
# pre_board_assay=fct_relevel(pre_board_assay,"No pre-flight testing",
# "Innova (KCL)",
# "PCR")
# ) %>%
# mutate(assay = fct_recode(assay,`LFT`="Innova (KCL)"),
# pre_board_assay=fct_recode(pre_board_assay,
# `LFT pre-flight`="Innova (KCL)",
# `PCR pre-flight`="PCR")) %>%
# mutate(adherence = ifelse(adherence_quar == 1 &
# adherence_test == 1 &
# adherence_symp == 1,
# "full", "literature"))
)
processed <- calculate_detected_infectious_status(x = results_df,
detected_levels = detected_levels,
infectious_levels = infectious_levels)
# appendix version of plot
# takes forever to run
# make_results_plot(
# processed,
# faceting = assay + adherence_quar + adherence_symp + adherence_test ~ pre_board_assay,
# prefix = "who", base = "appendix",
# width=9, height=18, device = "png", units = "inch")
# focus on main
baseline_scenarios <- crossing(data.frame(adherence_symp = c(0.71, 1),#0.67,
adherence_quar = c(0.28, 1),#0.5,
adherence_test = c(0.86, 1)),
assay = c("No testing", "PCR", "LFT"),
pre_board_assay = c("No pre-flight testing",
"PCR pre-flight",
"LFT pre-flight")) %>%
mutate(assay = factor(assay,
#ordered = T,
levels = c("No testing", "LFT", "PCR")),
pre_board_assay = factor(pre_board_assay,
#ordered = T,
levels = c("No pre-flight testing",
"LFT pre-flight",
"PCR pre-flight")))
processed_df <- mutate(processed,
assay = factor(assay, levels = levels(assay), ordered = F),
pre_board_assay = factor(pre_board_assay,
ordered = F,
levels = c("No pre-flight testing",
"LFT pre-flight",
"PCR pre-flight"))) %>%
inner_join(baseline_scenarios) %>%
ungroup() %>%
filter(detected %!in% c("Ceased being infectious before flight",
"Develops symptoms before flight")) %>%
droplevels()
make_results_plot(x = processed_df,
faceting = pre_board_assay + adherence_quar + adherence_symp +
adherence_test ~ assay,
prefix = "who",
base = "daily_quar_baseline_and_ideal",
width = 9,
height = 12,
device = "png",
units = "inch")
make_results_plot(x = processed_df %>%
filter(adherence_symp == 0.71,
adherence_quar == 0.28,
adherence_test == 0.86),
faceting = pre_board_assay ~ assay,
prefix = "who",
base = "daily_quar_baseline",
width = 9,
height = 7,
device = "png",
units = "inch")
# focus on main but with both LFA sensitivities
# is this no longer needed?
# make_results_plot(x = processed %>% inner_join(dplyr::select(baseline_scenario, -sens_LFA)),
# faceting = sens_LFA ~ stringency + pre_board_test,
# prefix = "who", base = "daily_quar_both_sens",
# width=10, height=5, device = "png", units = "inch")
make_results_plot(x = processed_df %>%
filter(adherence_symp == 1,
adherence_quar == 1,
adherence_test == 1),
faceting = pre_board_assay + type ~ assay,
prefix = "who",
base = "daily_quar_both_type",
width = 9,
height = 9,
device = "png",
units = "inch")
# make_results_plot(x = processed %>% inner_join(dplyr::select(baseline_scenario, -sens_LFA)),
# faceting = sens_LFA + type ~ stringency + pre_board_test,
# prefix = "who", base = "daily_quar_both_sens_type",
# width=10, height=6, device = "png", units = "inch")