-
Notifications
You must be signed in to change notification settings - Fork 3
/
ui.R
290 lines (223 loc) · 10.6 KB
/
ui.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
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
ui <- navbarPage("Digital contact tracing for SARS-COV-2",
tags$head(includeHTML(("google-analytics.html"))), # google analytics token
theme = shinytheme("spacelab"), # change the theme here; use "themeSelector()" below for an easy way to pick
#shinythemes::themeSelector(), # use this to dynamically select a theme
tabsetPanel(
tabPanel(
"Infectiousness",
HTML('<meta name="viewport" content="width=1024">'), # forces "desktop view" on mobile
# Sidebar with a slider inputs etc
sidebarLayout(
sidebarPanel(
id = "sidePanel",
style = "overflow-y: auto; max-height: 90vh; position:relative;", # make it scrollable
useShinyjs(), # for the reset button
withMathJax(), # for LaTeXing
h5("Incubation period (days):"),
sliderInput("incperMedian",
h6("Median:"),
min = 1,
max = 12, # https://github.com/HopkinsIDD/ncov_incubation#parameter-estimates
step = 0.01,
value = exp(1.64)),
sliderInput("incperSdlog",
h6("sdlog parameter:"),
min = 0.01,
max = 0.99,
step = 0.01,
value = 0.36),
# mini plot to show the chosen incubation period distribution
h6("Chosen incubation period lognormal distribution"),
withSpinner(plotOutput("IncperDistribPlot", height="130px"), type=7),
hr(),
h5("Generation time (days):"),
sliderInput("serIntShape",
h6("Shape:"),
min = 1,
max = 7,
step = 0.01,
value = 2.83),
sliderInput("serIntScale",
h6("Scale:"),
min = 1,
max = 7,
step = 0.01,
value = 5.67),
# mini plot to show the chosen generation time distribution
h6("Chosen generation time Weibull distribution"),
withSpinner(plotOutput("SerintDistribPlot", height="130px"), type=7),
hr(),
sliderInput("doublingTime",
h5("Epidemic doubling time (days):"),
min = 1,
max = 10,
step = 0.01,
value = 5),
hr(),
sliderInput("xa",
h5("Relative infectiousness of asymptomatic compared with symptomatic individuals:"),
min = 0,
max = 2,
step = 0.01,
value = 0.1),
hr(),
sliderInput("P.a",
h5("Fraction of infected individuals who are asymptomatic:"),
min = 0,
max = 0.99, # 1 gives an error
step = 0.01,
value = 0.4),
sliderInput("frac.Re",
h5("Fraction of transmissions that are environmentally mediated:"),
min = 0,
max = 0.99, # 1 gives an error
step = 0.01,
value = 0.1),
hr(),
h5("Environmental contribution:"),
radioButtons("env.type",
label = "",
choices = list("Environmental infectiousness is constant" = "constant",
"Environmental infectiousness decays exponentially" = "exp.decay"),
selected = "constant"),
# dependent on the selection of env inf type above, give an appropriate slider to determine the rate
uiOutput("environment_sliders"),
hr()
),
# Show a plot of the generated distribution
mainPanel(
id = "mainPanel",
style = "overflow-y: auto; max-height: 90vh; position:relative;", # make it scrollable
# make a "reset" button
fluidRow(column=3,
align="right",
actionButton("reset_input", "Reset values")
),
h3("Average rate of infecting others as a function of the time since infection"),
# I would love to control the height of the plot dynamically so that it's, say, 50% of the window height,
# but the documentation for "plotOutput" says it might behave weirdly, and it does!
# Tried using shinyjqui resizeable but it's a bit buggy. Other suggestions welcome!
withSpinner(plotOutput("mainPlot", height="400px"), type=7),
withSpinner(plotOutput("decompositionPlot", height="200px"), type=7),
withMathJax(uiOutput("parameterSummary")), # withMathJax enables LaTeX to be rendered
hr()
) # end "main" panel (the bit with the graphs and the explanations)
) # end "sidebarLayout"
),# end "Infectiousness" tab
tabPanel(
"Interventions",
HTML('<meta name="viewport" content="width=1024">'), # forces "desktop view" on mobile
# Sidebar with a slider inputs etc
sidebarLayout(
sidebarPanel(
id = "sidePanel2",
style = "overflow-y: auto; max-height: 90vh; position:relative;", # make it scrollable
useShinyjs(), # for the reset button
withMathJax(), # for LaTeXing
h5("Delay:"),
sliderInput("delay",
h6("Hours from symptoms to isolation and quarantining of contacts:"),
min = 0,
max = 72,
step = 1,
value = 0),
hr(),
h5("Incubation period (days):"),
sliderInput("incperMedianContour",
h6("Median:"),
min = 1,
max = 12, # https://github.com/HopkinsIDD/ncov_incubation#parameter-estimates
step = 0.01,
value = exp(1.64)),
sliderInput("incperSdlogContour",
h6("sdlog parameter:"),
min = 0.01,
max = 0.99,
step = 0.01,
value = 0.36),
# mini plot to show the chosen incubation period distribution
h6("Chosen incubation period lognormal distribution"),
withSpinner(plotOutput("IncperDistribPlotContour", height="130px"), type=7),
hr(),
h5("Generation time (days):"),
sliderInput("serIntShapeContour",
h6("Shape:"),
min = 1,
max = 7,
step = 0.01,
value = 2.83),
sliderInput("serIntScaleContour",
h6("Scale:"),
min = 1,
max = 7,
step = 0.01,
value = 5.67),
# mini plot to show the chosen generation time distribution
h6("Chosen generation time Weibull distribution"),
withSpinner(plotOutput("SerintDistribPlotContour", height="130px"), type=7),
hr(),
sliderInput("doublingTimeContour",
h5("Epidemic doubling time before interventions (days):"),
min = 1,
max = 10,
step = 0.01,
value = 5),
hr(),
sliderInput("xaContour",
h5("Relative infectiousness of asymptomatic compared with symptomatic individuals:"),
min = 0,
max = 2,
step = 0.01,
value = 0.1),
hr(),
sliderInput("P.aContour",
h5("Fraction of infected individuals who are asymptomatic:"),
min = 0,
max = 0.99, # 1 gives an error
step = 0.01,
value = 0.4),
sliderInput("frac.ReContour",
h5("Fraction of transmissions that are environmentally mediated:"),
min = 0,
max = 0.99, # 1 gives an error
step = 0.01,
value = 0.1),
hr(),
h5("Environmental contribution:"),
radioButtons("env.typeContour",
label = "",
choices = list("Environmental infectiousness is constant" = "constant",
"Environmental infectiousness decays exponentially" = "exp.decay"),
selected = "constant"),
# dependent on the selection of env inf type above, give an appropriate slider to determine the rate
uiOutput("environment_slidersContour"),
hr()
),
# Show a plot of the generated distribution
mainPanel(
id = "mainPanel2",
style = "overflow-y: auto; max-height: 90vh; position:relative;", # make it scrollable
# make a "reset" button
fluidRow(column=3,
align="right",
actionButton("reset_inputContour", "Reset values")
),
h3("Daily epidemic growth rate r, with interventions of varying efficiencies"),
withMathJax(uiOutput("contourDescribeDelay")),
withSpinner(plotOutput("contourPlot", height="600px", width="775px"), type=7),
withMathJax(uiOutput("contourDescribeR0")),
h5("Please note that our published results use a higher resolution and a tighter tolerance for convergence;
for ease of use we perform a faster approximation here."),
hr()
) # end "main" panel (the bit with the graphs and the explanations)
) # end "sidebarLayout"
), # end "Interventions" tab
tabPanel("Details",
withMathJax(includeMarkdown("markdown/details.md"))
), # end "Details" tab
tabPanel("About",
withMathJax(includeMarkdown("markdown/about.md")),
verbatimTextOutput("systeminfo") # server info
) # end "Details" tab
) # end tabsetPanel
) # end ui