-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
431 lines (404 loc) · 21.2 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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
library(shiny)
library(shinythemes)
library(leaflet)
library(leaflet.extras)
library(shinyBS)
library(datasets)
library(shinyWidgets)
library(RCurl)
library(lubridate)
library(purrr)
library(magrittr)
library(httr)
library(geoshaper)
library(psych)
library(reshape2)
library(data.table)
library(maptools) # Tools and functions for sp and other spatial objects e.g. spCbind
library(sf)
library(sp) # Spatial pacakge with class definition
library(rgdal) # GDAL wrapper for R, spatial utilities
library(tidyverse)
library(tidyr)
library(lattice)
library(plotly)
library(dplyr)
library(devtools)
library(scales)
library(Hmisc)
library(fst)
library(totalcensus)
library(dataRetrieval)
library(viridis)
library(DT)
library(rmarkdown)
library(stringr)
library(shinyalert)
library(htmltools)
library(cdlTools)
library(hrbrthemes)
#library(RLumShiny)
# List of all water quality parameters and activity media name available in Water Quality Portal Database; comes from here:
# activitymedia.name <- readRDS("activitymedia_name.rds")
# characteristics.name <- readRDS("characteristics_name.rds")
# activitymedia.name <- readRDS("activitymedia_name.rds")
# activitymedia.name2 <- c("",sort(unique(as.character(activitymedia.name))))
#
# characteristics.name <- readRDS("characteristics_name.rds")
# characteristics.name2 <- c("", sort(unique(as.character(characteristics.name))))
Characteristictype <- c("Physical.2009-2019"="Physical",
"Organics, Pesticide.1990-2019" ="pesticide",
"Inorganics, Major, Non-metals.1990-2019" ="Non_metals",
"Inorganics, Major, Metals.1990-2019" = "Metals")
sampleMedia <- c("Water", "water")
Subdivision.selection <- c("", "Surface Water", "Groundwater")
wq_columns = read.csv("column-names.csv")
source("respin.R", local = TRUE)
#############################################################################################################
shinyUI(navbarPage("WQP Data Exploration Tool",
theme = "bootstrap.css",
inverse = TRUE,
#headerPanel("Water Quality Portal Data Exploration"),
tabsetPanel(
tabPanel("1. Query Data",
sidebarLayout(
sidebarPanel(width=3,
SpinBox(),
selectizeInput('Chartype', 'Characteristic Group',
c("Physical.2009-2019"="Physical",
"Organics, Pesticide.1990-2019" ="Organics, Pesticide",
"Inorganics, Major, Non-metals.1990-2019" ="Inorganics, Major, Non-metals",
"Inorganics, Major, Metals.1990-2019" = "Inorganics, Major, Metals"),
selected= "",
multiple = F),
#selectizeInput('subdiv', 'Water Type', Subdivision.selection, multiple = TRUE),
uiOutput("stsel"),
br(),
actionButton("goButton0","Filter Data!"),
br(),
br(),
uiOutput("charsel"),
br(),
uiOutput("loadsel"),
conditionalPanel(
SpinBox(),
condition = "input.load == 'Local Server'",
uiOutput("yearsel"),
#uiOutput("subdivisionsel"),
#uiOutput("unitsel"),
br()
),
conditionalPanel(
SpinBox(),
condition = "input.load == 'Water Quality Portal'",
dateInput('date1', label = "Date from:", format="mm-dd-yyyy"),
dateInput('date2', label = 'to:', format="mm-dd-yyyy"),
# selectizeInput('medianame2', 'Water Type', activitymedia.name2,
# selected= "Water", multiple = F),
# selectizeInput('charname1', 'A.I. Name', characteristics.name2, selected= "", multiple = F),
#actionButton("goButton1", "Load Sites/Sample Results"),
br(),
actionButton("goButton","Retrieve Data!")
),
hr(),
verbatimTextOutput("print1"),
actionButton("goButton2","Load Data/Display Sites!"),
br(),
br(),
downloadButton("downloadData", "Save Data!"),
br()
), #sidebarpanel
mainPanel(
conditionalPanel(
SpinBox(),
condition = "input.load == 'Water Quality Portal'",
fluidRow(h4("Data retrieval Summary", style = "text-align:center")),
verbatimTextOutput("siteinfo"),
fluidRow(br()),
fluidRow(h4("WQP Web Service Query URL", style = "text-align:center")),
verbatimTextOutput("URL")
),#conditionalPanel
leafletOutput('mymap1'),
br(),
br(),
actionButton("goButton4","Clear map!"),
hr(),
br(),
br(),
br(),
DT::dataTableOutput("site_table")
)#mainPanel
)#sidebarLayout
), #tabPanel1
# tabsetPanel(
#################################################################################################################################
navbarMenu("2. Data Tables", icon = icon("table"),
tabPanel("All Data",
br(),
br(),
DT::dataTableOutput("all_data_table")
),
tabPanel("Missing",
br(),
br(),
DT::dataTableOutput("missing_table")
),
tabPanel("Duplicates",
br(),
br(),
DT::dataTableOutput("dup_table")
)
), #tabsetPanel
#################################################################################################################################
navbarMenu("3. Check Data and Summary", icon = icon("table"),
tabPanel("Undetections",
br(),
wellPanel(fluidRow(column(1),
column(7,
fluidRow(h3("Please select a method for calculation of non-detections:", style = "text-align: center")),
fluidRow(radioButtons("ND_method","",
c("Remove Non-Detections from data"=1,
"Set Non-Detections equal to zero"=2,
"Set Non-Detections equal to the Limit of Detection"=3,
"Set Non-Detections equal to the 1/2 times the Limit of Detection"=4)))))
),
br(),
br(),
downloadButton("downloadData2", "Save Cleaned Data!"),
#actionButton("goButton3","Apply Method!"),
br(),
br(),
hr(),
DT::dataTableOutput("undetections_table"),
br()
),
tabPanel("Summary",
br(),
br(),
uiOutput("group.sel1"),
uiOutput("group.sel2"),
hr(),
DT::dataTableOutput("summary_table"),
br(),
downloadButton("downloadData3", "Save Data Summary!"),
hr(),
actionButton("goButton11","Click for Boxplots!"),
br(),
plotOutput("boxplot", width="50%"),
hr(),
DT::dataTableOutput("summary_table2", width = "50%"))
),
##################################################################################
tabPanel("4. Search Data", icon = icon("flask"),
sidebarLayout(
sidebarPanel(width=3,
SpinBox(),
br(),
h4("1. Please select water characteristic"),
uiOutput("charmap_sel"),
hr(),
h4("2. Please define percentile of data (optional)"),
numericInput(inputId="pr", label="Samples Percentile (default: median):", value= 0.50, 0, 1, 0.01)
),
mainPanel(
br(),
br(),
h3("3. Please select at least two sites on map"),
br(),
leafletOutput('mymap'),
#actionButton("act1", "Refresh map!"),
br(),
h4("Note: Please unselect all of the selected sites before selecting new characteristics or new set of stations."),
hr(),
actionButton("Plot", "Plot Percentiles Frequency!"),
br(),
br(),
plotOutput("plot_map1", width = "50%", height="400px", hover = TRUE),
fixedRow(
br(),
h3("4. Group data by selected features:"),
br(),
column(4,
uiOutput("featureInput1")),
br(),
br(),
br(),
plotlyOutput("plot_map2"),
br(),
br(),
column(4,
uiOutput("featureInput2"))),
br(),
br(),
plotlyOutput("plot_map3"),
br(),
hr(),
h3("5. Please set maximum value of water quality parameter (optional)"),
uiOutput("ui"),
br(),
br()
)#main panel
)#sidebar
),#tab panel
##################################################################################
tabPanel("5. Filter Data", icon = icon("flask"),
sidebarLayout(
sidebarPanel(width=3,
SpinBox(),
uiOutput("provider.sel"),
uiOutput("orgname.sel"),
uiOutput("station.sel"),
uiOutput("subdiv.sel"),
uiOutput("unicode.sel"),
uiOutput("fraction.sel"),
uiOutput("method.sel")
),
mainPanel(
br(),
h4("Please select the sites in 'Search Data' Panel to activate Filtering options."),
hr(),
br(),
br(),
DT::dataTableOutput("final_filtered_data")
)#mainpanel
)),#tab panel
###################################################################################
navbarMenu("6. SSD Tool", icon = icon("bar-chart-o"),
tabPanel("SSD Tool", icon = icon("bar-chart-o"),
sidebarLayout(
sidebarPanel(width=3,
SpinBox(),
h4("1. Please upload input data files:"),
br(),
fileInput("file1", label="Toxicity Data"),
fileInput("file2", label="Exposure Data (must have column 'ResultMeasureValue'"),
hr(),
h4("Example input data files:"),
br(),
downloadButton("downTemplate","Download Toxicity Data Template"),
br(),
br(),
downloadButton("downTemplate2","Download Exposure Data Template")
),
mainPanel(
# navbarMenu("6. SSD Tool", icon = icon("bar-chart-o"),
# tabPanel("SSD Plot",
# SpinBox(),
# fluidRow(
# h4("1. Please upload input data files:"),
# br(),
# fileInput("file1", label="Toxicity Data"),
# fileInput("file2", label="Exposure Data"),
# hr(),
# h4("Example input data files:"),
# br(),
# downloadButton("downTemplate","Download Toxicity Data Template"),
# br(),
# br(),
# downloadButton("downTemplate2","Download Exposure Data Template")
# ),
hr(),
fluidRow(
SpinBox(),
h4("2. Specify Options for SSD"),
br(),
column(3,
fluidRow(
uiOutput("unitselssd"),
bsTooltip("unitselssd", "Units of measure for toxicity data", placement = "top",
trigger = "hover", options = NULL),
uiOutput("plotsel"),
bsTooltip("plotsel", "Only Hazen plotting position is active",
placement = "top", trigger = "hover", options = NULL),
radioButtons("scale", "Data Scale",
list("Arthmetic"=1, "Logarithmic"=2), selected = 1),
uiOutput("samplsizesel")
)),
column(7,
textInput("chem", ("Chemical Name (optional, used in report body."), value = ""),
shinyBS::bsTooltip("chem", "Active ingredient name (optional)", placement = "top",
trigger = "hover", options = NULL),
textInput("exposure", "Exposure Concentration", value ="0.0"),
bsTooltip("exposure", "Is required to calculate Fraction Affected (FA), unit of EC value must be identical to the unit of the toxicity values. (optional)",
placement = "top", trigger = "hover", options = NULL),
numericInput("conf", "Desired Confidence %", value = 95)),
bsTooltip("conf", "Confidence interval for median by bootstrap",
placement = "top", trigger = "hover", options = NULL)
),
fluidRow(
SpinBox(),
hr(),
h4("3. Species Sensitivity Distributions"),
br(),
actionButton("dist", "Calculate"),
bsTooltip("dist", "The program calculates various distributions through toxicity values for the species",
placement = "top", trigger = "hover", options = NULL),
br(),
br(),
DT::dataTableOutput("FitTable"),
br(),
hr(),
h4("4. Outputs"),
br(),
actionButton("act2", "Distribution Parameters"),
bsTooltip("act2", "Table of distributions parameters", placement = "top", trigger = "hover",
options = NULL),
br(),
br(),
DT::dataTableOutput("fitpars.table"),
br(),
actionButton("act3","Goodness of Fit Tests"),
bsTooltip("act3", "Goodness-of-fit tests to decide whether your data comes from the specific population distribution", placement = "top", trigger = "hover",
options = NULL),
br(),
br(),
DT::dataTableOutput("gofPars"),
br(),
actionButton("act4","SSE and MSE"),
bsTooltip("act4", "Sum of Squared Errors and Mean Squared Error to determine the distribution with minimum deviation", placement = "top", trigger = "hover",
options = NULL),
br(),
br(),
DT::dataTableOutput("sse.mse"),
br(),
actionButton("act5","HC5 and HC50"),
bsTooltip("act5", "Hazardous concentration affecting 5% and 50% of the species", placement = "top", trigger = "hover",
options = NULL),
br(),
br(),
DT::dataTableOutput("hcTabl")
),
fluidRow(
hr(),
h4("4. Plot Species Sensitivity Distribution"),
br(),
uiOutput("modelsel"),
column(9,jqui_resizable(plotOutput("plot"))),
column(3, uiOutput("taxasel"))
)
)
)),
tabPanel("Table and Summary",
fluidRow(
h3("Summary of Toxicity Data"),
column(6, jqui_resizable(verbatimTextOutput("summary.tox"))),
br(),
br(),
hr(),
DT::dataTableOutput("SSDtable", width = "80%")
)),
tabPanel("Help",
h4("Input exposure Data"),
"Exposure data file must have column 'ResultMeasureValue' for concentrations.
All other columns in the input data file are redundant.
Example input data file includes 'Prometon' concentrations from WQP website."),
tabPanel("7. Report", icon=icon("pencil",lib="glyphicon"),
SpinBox(),
radioButtons('format', 'Document format', c('PDF', 'HTML', 'Word'),
inline = TRUE),
downloadButton("report", "Generate report")
)
)
)# tabspanel
)#navpage
)