-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathui.R
410 lines (357 loc) · 23.4 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
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
#------------------------- #
# UI Components
#------------------------- #
developer <- function(lastName, firstName, degree = "", affiliationIndex = 1, href = "") {
tag("address",
list(a(style = "font-weight: bold;",
href = href,
target = "_blank",
lastName,
",",
firstName,
degree,
tag("sup", affiliationIndex))))
}
ui <- fluidPage( # UI ----
tags$head(
tags$style(HTML("
.label-text {
font-size: 16px; /* Adjust label font size as needed */
}
.option-text {
font-size: 12px; /* Adjust option font size as needed */
}
"))
),
theme = bs_theme(version = 4,
primary = "#18536F"),
tags$head(
tags$link(rel = "stylesheet",
type="text/css",
href="spatialEpisimBanner.css"),
tags$link(rel = "stylesheet",
type="text/css",
href="https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.control.min.css"),
tags$script(src = "https://cdn.jsdelivr.net/npm/iso8601-js-period@0.2.1/iso8601.min.js"),
tags$script(src = "https://cdn.jsdelivr.net/npm/leaflet-timedimension@1.1.1/dist/leaflet.timedimension.min.js"),
tags$script(src = "addTimeDimension.js")
),
div(
style = "background-color: #18536F; padding: 10px; width: 100%; box-sizing: border-box; display: flex; align-items: center;
height: 100px;",
div(
h1(
strong("The Krishnamurthy Lab Spatio-Temporal Epidemic Modelling app"),
style = "margin: 0px 0px; color: white; font-size: 35px"
)
)),
add_busy_spinner(spin = "cube-grid",
color = "#18536F",
margins = c("50%","50%")),
navbarPage(title = "",
tabPanel(title = "Model",
sidebarLayout(
sidebarPanel( ## sidebar panel ----
shinyjs::useShinyjs(),
shinyjs::inlineCSS(appCSS),
div(
id = "dashboard",
uiOutput("countryDropdown"),
uiOutput("cropStateCheckbox"),
conditionalPanel("input.selectedCountry != ''",
helper(checkboxInput(inputId = "cropLev1",
label = strong("Limit simulation to state(s)/province(s) (crop to selection)"),
value = TRUE),
content = "cropSelectedCountry"),
conditionalPanel(condition = "input.cropLev1", uiOutput("Level1Ui")),
radioButtons(inputId = "appMode",
label = strong("Application mode"),
choices = list("Visualizer",
"Simulator"),
selected = "Simulator",
inline = TRUE)),
# -------------------------------------------- #
# Visualizer Inputs #
# -------------------------------------------- #
conditionalPanel(
condition = "input.appMode == 'Visualizer'",
conditionalPanel(condition = "input.selectedCountry == 'Democratic Republic of Congo'",
fileInput(inputId = "latLonData",
label = strong("Upload Lat-Lon Data:"),
placeholder = "Upload Lat-Lon data (.csv or .xls or .xlsx)",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv",
".xls",
".xlsx")),
fileInput(inputId = "incidenceData",
label = strong("Upload Incidence/Death Data:"),
placeholder = "Upload Incidence/Death data (.csv or .xls or .xlsx)",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv",
".xls",
".xlsx"))),
uiOutput("resetButton")
),
# -------------------------------------------- #
# Simulation Inputs #
# -------------------------------------------- #
conditionalPanel(
condition = "input.appMode == 'Simulator'",
helper(uiOutput("aggInput"),
content = "rasterAggregationFactor"),
uiOutput("modelRadio"),
uiOutput("stochasticRadio"),
conditionalPanel(
condition = "input.selectedCountry != ''",
withMathJax(),
wellPanel(h5("Model Parameters", style="font-weight: bold; font-size:11.5pt"),
conditionalPanel(id = "SVEIRD",
withMathJax(),
condition = "input.modelSelect == 'SVEIRD'",
uiOutput("alphaInput")),
uiOutput("betaInput"),
uiOutput("gammaInput"),
uiOutput("sigmaInput"),
uiOutput("deltaInput"),
helper(uiOutput("lambdaInput"), content = "lambda")),
wellPanel(helper(uiOutput("seedUpload"),
size = "l",
type = "inline",
title = "Seed data template (for the Democratic Republic of Congo)",
content = HTML(r"--{<div class = "datatables html-widget html-widget-output shiny-report-size html-fill-item" id = "seedDataDT" style = "width:auto;height:auto;"></div>}--")),
uiOutput("seedDataButton"),
uiOutput("seedRadiusInput")),
uiOutput("startDateInput"),
uiOutput("timestepInput")),
# actionButton("go","Run Simulation",
# style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
# actionButton("resetAll","Reset Values",
# style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
br(),
br(),
uiOutput("dataAssimCheckbox"),
# --------------------------------------------- #
# Bayesian Assimilation Inputs #
# --------------------------------------------- #
conditionalPanel(
condition = "input.dataAssim == '1'",
helper(checkboxGroupButtons(
inputId = "selectedCompartments",
label = "Select observable compartment(s)",
choices = c("V", "E", "I", "R", "D"),
selected = c("I"),
checkIcon = list(
yes = tags$i(class = "fa fa-check-square",
style = "color: steelblue"),
no = tags$i(class = "fa fa-square-o",
style = "color: steelblue")),
disabled = TRUE
),
content = "selectedCompartmentsUnimplemented"),
br(),
uiOutput("dataAssimZones"),
uiOutput("dataAssimFileI"),
uiOutput("dataAssimFileD"),
h5("Model error covariance matrix (Q) formulation", style="font-weight: bold; font-size:11.5pt"),
uiOutput("varCovarFunc"),
uiOutput("selectRho"),
uiOutput("selectSigma"),
uiOutput("selectNbhd"),
h5(HTML("Model error covariance matrix (Ψ) formulation"), style="font-weight: bold; font-size:11.5pt"),
uiOutput("selectPsiDiag"),
# actionButton("goDA","Run Simulation with DA",
# style ="color: #fff; background-color: #337ab7; border-color: #2e6da4")
),
# br(),
# actionButton("resetAllDA","Reset Values",
# style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton(inputId = "go",
label = "Run Simulation",
class = "act-btn"),
actionButton(inputId = "resetAll",
label = "Reset Values",
class = "act-btn"),
)), # div "dashboard"
), # sidebarPanel
mainPanel( ## main panel ----
conditionalPanel(
condition = "input.appMode == 'Visualizer'",
div(id = "maptabPanels",
tabsetPanel(id = 'vizTabSet',
tabPanel(id = "main",
title ="Leaflet Plot",
br(),
leafletOutput("leafletMap",
width = 1024,
height = 768),
br(),
br()
#downloadButton('downloadPlot', 'Save Image')
),
tabPanel(title = "Leaflet Cropped Plot",
value = "Leaflet Cropped Plot",
br(),
leafletOutput("croppedLeafletMap",
width = 1024,
height = 768),
br(),
br()
),
tabPanel(title = "terra Plot",
br(),
imageOutput("terraOutputImage"),
br(),
br()
),
tabPanel(title = "Transmission Path",
br(),
div(style = "width: 100%; height: 80vh; position: relative;",
leafletOutput("transmission", width = "100%", height = "100%")
),
br(),
br()
),
tabPanel(title = "Lollipop Chart",
br(),
plotlyOutput("lollipop",
height = 1000),
br(),
br()
),
tabPanel(title = "Time-Series Graph",
br(),
uiOutput("timeSeriesOptions"),
br(),
plotlyOutput("timeSeries",
height = 800),
br(),
br())
# tabPanel(title ="Population Count by State/Province",
# DT::dataTableOutput("aggTable")
# )
) # tabSet
), # maptabPanels
),
conditionalPanel(
condition = "input.appMode == 'Simulator'",
div(id = "tabsetContainer",
tabsetPanel(id = "tabSet", selected = "Input Summary",
tabPanel(title = "Input Summary",
verbatimTextOutput("summary"),
br(),
DTOutput("summaryTable"),
br(),
br(),
imageOutput("outputImage",
height = "768px",
width = "768px"),
#imageOutput("croppedOutputImage"),
#imageOutput("seededOutputImage"),
#downloadButton(outputId = "downloadSummary", label = "Save Input Summary as a PDF File")
),
tabPanel(title = "Model", id = "modelTab",
h3("Schematic Diagram"),
br(),
imageOutput("flowchartImg",
height = "400px"),
br(),
br(),
h3("Mathematical Model"),
br(),
imageOutput("modelImg",
height = "400px")
),
# tabPanel(title = "Schematic Diagram", id = "flowchartTab",
#
# ),
tabPanel(title = "Initial Seed Data",
DTOutput("tableSeed"),
br(),
leafletOutput("seedPlot",
width = 1024,
height = 768)
),
tabPanel(title = "MP4 Animation",
br(),
br(),
uiOutput("outputVideo")#,
#downloadButton(outputId = "downloadMP4", label = "Save MP4 Animation")
),
tabPanel(title = "Output Summary",
DTOutput("outputSummary") ,
downloadButton(outputId = "downloadOutputSummary", label = "Download as Excel")
),
tabPanel(title = "Plot", id = "plotTab",
plotlyOutput("infectedExposedPlot", width = 800, height = 600),
plotlyOutput("cumulativeDeaths", width = 800, height = 600),
plotlyOutput("dailyIncidence", width = 800, height = 600),
plotlyOutput("cumulativeIncidence", width = 800, height = 600),
plotlyOutput("fullPlot", width = 800, height = 600),
# imageOutput("fracSusPlot"),
#downloadButton(outputId = "downloadPlot", label = "Save Image")
)
) # tabsetPanel
)
)
), # mainPanel
) # sidebarLayout
), # Model tabPanel
ModelAuthorshipTab <- nav_panel(
title = "Authors",
h2("Principal investigator", style = "font-weight:bold"),
## TODO: Reformat Ashok's information so the digital links aren't ugly.
tag("address",
list(
p(a("Ashok Krishnamurthy, Ph.D.", href = "https://bit.ly/2YKrXjX", target = "_blank", style = "font-weight: bold;"), br(),
"Mount Royal University", br(),
"Department of Mathematics & Computing,", br(),
"Calgary, AB, Canada", br(),
a("akrishnamurthy@mtroyal.ca", href = "mailto:akrishnamurthy@mtroyal.ca"), br(),
a("SpatialEpisim GitHub", href = "https://github.com/ashokkrish/spatialEpisim", target = "_blank")),
style = r"(a[href^='mailto']::before {content: '📧 ';} a[href^='tel']::before {content: '📞 ';})")),
#TODO: Need the link for research assistants who have not had
h2("Research Assistants", style = "font-weight:bold"),
developer("Carson", "Bryce", "B.Sc", href = "https://github.com/bryce-carson/"),
developer("Le", "Khanh", href = "https://github.com/kle6951/"),
developer("Wondwossen", "Tobias", href = "https://github.com/Toby-exe"),
h2("Affiliations", style = "font-weight:bold"),
p(tag("sup", 1), "Mount Royal University", br(),
"4825 Mount Royal Gate SW", br(),
"Calgary, Alberta, Canada", br(),
"T3E 6K6"),
h2("Acknowledgment", style = "font-weight:bold"),
list(p("Dr. Loren Cobb, Dr. Bedrich Sousedik, Michael Myer, Tom Bayliss White, Crystal Wai, Gursimran Dhaliwal, Timothy Pulfer, Ryan Darby, Jason Szeto, and Jake Doody.", br(),
)),
h2("Disclaimer", style ="font-weight:bold"),
p("This tool uses a mathematical model to simulate a variety of CoViD-19, Ebola, and
Measles outbreaks based on user-defined parameters. The output of the model
depends on model assumptions, parameter choices, and human mobility patterns. It
is not a medical predictor, and should be used for informational and research
purposes only. Please carefully consider the parameters you choose. Interpret
and use the simulated results responsibly. Authors are not liable for any direct
or indirect consequences of this usage."),
h2("Credits", style ="font-weight:bold"),
p("We would like to express our gratitude to the authors of the following R packages used in our project:"),
worldPopPanel <- bsCollapsePanel(
title = "WorldPop",
content = tags$div(style = "padding: 10px;",
HTML(
paste0(
"WorldPop (www.worldpop.org - School of Geography and Environmental Science, University of Southampton; ",
"Department of Geography and Geosciences, University of Louisville; Departement de Geographie, Universite de Namur) ",
"and Center for International Earth Science Information Network (CIESIN), Columbia University (2018). ",
"Global High Resolution Population Denominators Project - Funded by The Bill and Melinda Gates Foundation (OPP1134076). ",
"<a href='https://dx.doi.org/10.5258/SOTON/WP00671' target='_blank'>Link to the website</a>"
)
)
),
style = "primary"
),
uiOutput("packageList"),
), #Author Tab Panel
) # navbarPage
)