-
Notifications
You must be signed in to change notification settings - Fork 1
/
cdc-model-reboot.Rmd
177 lines (171 loc) · 6.24 KB
/
cdc-model-reboot.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
---
output:
html_document:
self_contained: yes
smart: yes
css: styles-reboot.css
runtime: shiny
---
```{r, echo=FALSE}
source("cdc_model_functions.R")
source("cdc_plotting_functions.R")
source("shiny-helpers.R")
source("pauseable.R")
with(defaults, {
transmission_rate <- makeVectorControl(
control_prefixes, "transmission_rate",
control_descriptions, control_transmission_rates,
min = 0, step=0.01,
tests = list(validators$positive("tranmission rates"))
)
stay_durations <- makeVectorControl(
control_prefixes, "stay_duration",
control_descriptions, control_durations,
min = 0, step=1,
tests = list(validators$positive("durations"), validators$integers("durations"))
)
hospitalization_rate <- makeVectorControl(
control_prefixes, "hospitalization_rate",
control_descriptions, control_hospitalization_rates,
type = probabilityInput,
tests = list(validators$positive("hospitalization rates"))
)
infection_pdf <- inputIntervalPDF('infection', 6)
# infection_pdf <- list(control=NULL, reactor = function() {
# defaults$I_day_PDF
# })
# incubation_pdf <- list(control=NULL, reactor = function() {
# defaults$E_day_PDF
# })
# output$incubation_download <- downloadHandler(
# filename='incubation_pdf.csv', contentType = 'text/csv', content = function(file) {
# pdf <- defaults$E_day_PDF
# res <- data.frame(pdf=pdf)
# write.table(res, file, row.names=F, col.names=F)
# })
#
# incubation_pdf_file_warning <- reactive({
# if(!is.null(input$incubation_upload)) {
# inputFile <- input$incubation_upload$datapath
# src <- drop(as.matrix(read.table(inputFile, header = F)))
# if (is.numeric(src)) {
# if (sum(src) == 1) {
# ## pause pdf updating?
# ## updateRadioButtons(session, incubation_pdf_type, selected="manual")
# ## set incubation to manual
# ## updateNumericInput(session, incubation_pdf_max, value=length(src))
# ## set incubation max to length
# ## for i in 1 to length, set inc_day_i to data[i]
# ## unpause pdf updating
# ''
# } else {
# 'pdf does not sum to 1.'
# }
# } else {
# 'did not provide numeric data.'
# }
# } else {
# ''
# }
# })
# simulation <- reactive({
# sim_duration <- input$simulation_duration ## TODO validate
# N0 <- defaults$N0
# simulate(list(
# infective_treatments = defaults$infective_treatments,
# treatment_durations = stay_durations$reactor(),
# simulation_duration = sim_duration,
# treatment_distribution = defaults$treatment_distribution, #yield_intervention(intervention_scenario()),
# introductions = defaults$introductions, # yield_introduction(introduction_scenario()),
# treatment_transmissions = transmission_rate$reactor(),
# hosp_proportions = hospitalization_rate$reactor(),
# E_day_PDF = incubation_PDF$reactor(),
# I_day_PDF = infection_PDF$reactor(),
# N0 = N0
# ))
# })
#
shinyUI(navbarPage("EbolaResponse v2",
nestedTabPanel("Results",
tabPanel("Symptomatic Individuals",
renderPlot(dummyPlot(100)),
tags$caption("Plot Caption")
),
tabPanel("Occupied Beds",
renderPlot(dummyPlot(100))
),
tabPanel("Cumulative Incidence",
renderPlot(dummyPlot(100))
),
tabPanel("Cumulative Mortality",
renderPlot(dummyPlot(100))
)
# ,
# inputTabPanel("Display Options",
# radioButtons("option_1", "Option 1", choices = c('a','b'), inline = T),
# radioButtons("option_2", "Option 2", choices = c('a','b'), inline = T)
# )
),
nestedTabPanel("Change Model Settings",
inputTabPanel("General",
customizeInput(
numericInput, "population","Population", value=10, min=0.1, step=0.1,
mouseover="The initial susceptible population.", units="millions"
),
customizeInput(
dateInput, "start_date", "Start date", min="2014-01-01", max="2014-12-31", value="2014-02-03",
mouseover="The reference start date for initial incubation.", units="YYYY-MM-DD"
),
customizeInput(
numericInput, "simulation_duration", "Simulation Duration", value=300, min=1, step=1,
mouseover="The number of days considered in the simulation.", units="days"
)
),
inputTabPanel("Transmission",
h3("New Ebola Cases produced per capita-day from Infectious Individuals, by Treatment Setting:", title = "TODO"),
transmission_rate$control,
customizeInput(
numericInput, "beta_multiplier", "Transmission Coefficient Multiplier", value=1, min=0.01, step=0.01,
mouseover = "This multiplier applies to all beta values. The default value, 1, means that the transmission parameters are used directly. A value of 2 means that all transmission rates are doubled, a value of 0.5 means that all rates are halved."
)
),
inputTabPanel("Incubation",
#inputPDF("incubation"),
inputCSV('incubation_upload', "Upload a file to fill in manual distribution."),
div(renderText(incubation_pdf_file_warning()), class="warning"),
view = renderPlot(plotIntervalDistribution(incubation_pdf$reactor())),
download = "incubation_download"
),
inputTabPanelSolid("Disease",
#inputPDF("infection"),
infection_pdf$control,
customizeInput(
probabilityInput, "case_fatality_rate", "Case Fatality Rate", value=0.7,
mouseover = "The probability of dying from Ebola.",
units = '%'
),
customizeInput(
probabilityInput, "asymptomatic_rate", "Asymptomatic Infection Rate", value=0.0,
mouseover = "The probability of asymptomatic, immunizing exposure.",
units = '%'
)
#, view = renderPlot(plotIntervalDistribution(infection_pdf$reactor()))
),
inputTabPanel("Treatment",
h3("Effective Bed-Days, by Treatment Setting:", title = "TODO"),
stay_durations$control,
renderPrint(stay_durations$reactor()),
h3("Proportion Requiring Hospitalization, by Treatment Setting:", title = "TODO"),
hospitalization_rate$control
)
),
nestedTabPanel("Model Description & Assumptions",
tabPanel("Overall", includeMarkdown("overall.md")),
tabPanel("Transmission", includeMarkdown("transmission.md")),
tabPanel("Incubation", includeMarkdown("incubation.md")),
tabPanel("Disease", includeMarkdown("disease.md")),
tabPanel("Treatment Logistics", includeMarkdown("treatment.md"))
)
))
})
```