-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.R
311 lines (265 loc) · 16.8 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
require(shiny)
require(shinythemes)
# Define input widget for lognormal distribution
logN.input <- function(title, suffix, E.value, cv.value){
wellPanel(
style = "padding: 5px;",
h5(title),
sliderInput(paste0("E_", suffix), "Mean catch:", min = 0, max = 2, step = 0.05, value = E.value, ticks = FALSE),
sliderInput(paste0("cv_", suffix), "Coef. variation (%):", min = 0, max = 100, step = 5, value = cv.value, ticks = FALSE)
)
}
# Define input widget for beta distribution
beta.input <- function(title, suffix, p.value, cv.value){
wellPanel(
style = "padding: 5px;",
h5(title),
sliderInput(paste0("p_", suffix), "Expected probability:", min = 0, max = 1, step = 0.05, value = p.value, ticks = FALSE),
sliderInput(paste0("cv_", suffix), "Coef. variation (%):", min = 0, max = 100, step = 5, value = cv.value, ticks = FALSE)
)
}
# Define input widget for management options
mng_input <- function(id, title){
# wellPanel(
#style = "padding: 5px;",
checkboxGroupInput(id, label = h4(title),
choices = list("Ban Shark lines" = "NoShkln", "Ban wire trace" = "NoWire",
"Ban shallow hooks" = "NoShallow", "Restrict to Circle-hooks only" = "AllCircle"),
selected = NULL, inline = FALSE)
# )
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
shinyUI(
navbarPage("Impact of longlining in sharks: simulation of mitigation measures",
theme = shinytheme("flatly"),
# 1st Tab ------------------------------------------------------------------
tabPanel("Step 1: Choose species & input distributions",
tags$style(type="text/css",
"label {font-size: 13px;}",
".recalculating {opacity: 1.0;}"
),
tags$head(
tags$link(rel = "stylesheet", type = "text/css", href = "slidebarColours.css")
),
sidebarLayout(
sidebarPanel(width = 3,
selectInput("spp", label = h3("Choose species"),
choices = list("Oceanic whitetip shark", "Silky shark"),
selected = "Oceanic whitetip shark"),
em("NOTE: Hyperparameter's default values as specified in ",
a("Shelton et al. (2015)", href = "https://dl.dropboxusercontent.com/u/250971/EB-WP-02-%5BMC_sharks%5D.pdf"))
),
mainPanel(
br(),
h3("Specify the input distributions"),
br(),
p("<Some text here (explaining the two components of the simulation model?)>"),
br(),
tabsetPanel(
tabPanel(h4("Catch Component"),
h4("Catch Rate per 100 hooks in:"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, logN.input("Shark lines", "shkln", E.value = 0.620, cv.value = 5)),
column(6, logN.input("Shallow Hooks", "shll", E.value = 0.008, cv.value = 4))
),
fluidRow(
column(6, logN.input("Deep Hooks", "deep", E.value = 0.016, cv.value = 3))
)),
br(),
column(7, plotOutput("cbtyPlot"))
)
#fluidRow(column(3, verbatimTextOutput("value3"))),
#fluidRow(column(3, verbatimTextOutput("value4"))),
),
tabPanel(h4("Fate Component"),
br(),
p(em("NOTE: The upper limit of the CV for probability inputs are defined by the Beta distn constraint:
CV < sqrt((1-p)/p)")),
br(),
h4("Probability of lip hook (vs. gut hook) given:"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, beta.input("J-Hook", "LHP.J", p.value = 0.3, cv.value = 43)),
column(6, beta.input("T-Hook", "LHP.T", p.value = 0.33, cv.value = 40))
),
fluidRow(
column(6, beta.input("C-Hook", "LHP.C", p.value = 0.9, cv.value = 10))
)),
br(),
column(7, plotOutput("LHP"))
),
hr(),
h4("Probability of bite-off given:"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, beta.input("Mono Leader & lip-hooked", "BOP.ML", p.value = 0.33, cv.value = 10)),
column(6, beta.input("Mono Leader & gut-hooked", "BOP.MG", p.value = 0.72, cv.value = 20))
),
fluidRow(
column(6, beta.input("Wire Leader & lip-hooked", "BOP.WL", p.value = 0.01, cv.value = 10)),
column(6, beta.input("Wire Leader & gut-hooked", "BOP.WG", p.value = 0.01, cv.value = 10))
)),
br(),
column(7, plotOutput("BOP"))
),
hr(),
h4("Probability of mortality given bite-off and:"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, beta.input("Lip-hooked", "BOM.L", p.value = 0.03, cv.value = 95)),
column(6, beta.input("Gut-hooked", "BOM.G", p.value = 0.06, cv.value = 80))
)),
br(),
column(7, plotOutput("BOM"))
),
hr(),
h4("Probability of mortality at retrieval given:"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, beta.input("Lip-hooked", "RM.L", p.value = 0.19, cv.value = 5)),
column(6, beta.input("Gut-hooked", "RM.G", p.value = 0.19, cv.value = 5))
)),
br(),
column(7, plotOutput("RM"))
),
hr(),
h4("Probability of release in-water (vs. brought-on then released):"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, beta.input("", "WRP", p.value = 0.5, cv.value = 30))
)),
br(),
column(7, plotOutput("WRP"))
),
hr(),
h4("Probability of mortality upon release given:"),
br(),
fluidRow(
column(5,
fluidRow(
column(6, beta.input("In-water release & lip-hooked", "URM.WL", p.value = 0.15, cv.value = 25)),
column(6, beta.input("In-water release & gut-hooked", "URM.WG", p.value = 0.19, cv.value = 20))
),
fluidRow(
column(6, beta.input("Landed release & lip-hooked", "URM.LL", p.value = 0.34, cv.value = 15)),
column(6, beta.input("Landed release & gut-hooked", "URM.LG", p.value = 0.44, cv.value = 12))
)),
br(),
column(7, plotOutput("URM"))
)
))))),
# 2nd Tab ------------------------------------------------------------------
tabPanel("Step 2: Choose management scenarios & Run MC simulation",
sidebarLayout(
sidebarPanel(width = 3,
h3("Management scenarios"),
br(),
p("Within each management scenario frame:"),
tags$ul(
tags$li("Select one or a combination of options"),
tags$li("If none of the boxes is selected, the management scenario is not considered")
),
br(),
mng_input("MngScn1", "Management Scenario 1"),
hr(),
mng_input("MngScn2", "Management Scenario 2"),
hr(),
mng_input("MngScn3", "Management Scenario 3"),
hr(),
mng_input("MngScn4", "Management Scenario 4")
),
mainPanel(
fluidRow(
column(3, numericInput("nsims", label = h4("Number of simulations"), value = 1000)),
column(3, selectInput("bskSize", label = h4("Basket Size"),
choices = list("20", "25", "30", "35", "40"),
selected = "30"))
),
br(),
fluidRow(
column(5, actionButton("simButton", h4("Run Simulation")))
),
# fluidRow(
# column(6, verbatimTextOutput("value1"))
# ),
br(),
br(),
br(),
tabsetPanel(
tabPanel(h4("Catch and mortality"),
br(),
h5("Monte Carlo distributions of catch and mortality under each scenario"),
fluidRow(column(8, plotOutput("MCplots_catchMort", height = "550px"), offset = 2)),
br(),
br(),
hr(),
h5("Monte Carlo percentiles"),
br(),
fluidRow(column(8, p("Total Catch"), tableOutput("tab_summCatch"))),
fluidRow(column(8, p("Mortality"), tableOutput("tab_summMort")))
),
tabPanel(h4("Mortality rate"),
br(),
h5("Monte Carlo distributions of mortality rate (i.e. deaths/catch) under each scenario"),
fluidRow(column(6, plotOutput("MCplots_MortRate", height = "550px"), offset = 3)),
br(),
br(),
hr(),
h5("Monte Carlo percentiles"),
br(),
fluidRow(column(8, tableOutput("tab_summMortRate"), offset = 3))
),
tabPanel(h4("Mortality components"),
br(),
h5("Median of Monte Carlo distributions of mortality components under each scenario"),
fluidRow(column(10, plotOutput("MCplots_MedianMortElem", height = "500px"), offset = 1))
))
)))
# # 3nd Tab ------------------------------------------------------------------
#
# tabPanel("Step 3: Run simulation & Outputs",
# tabsetPanel(
# tabPanel("Contrast Plots",
# h4("Monte Carlo distributions of catch and mortality under each scenario"),
# fluidRow(column(6, plotOutput("MCplots_catchMort", height = "650px"), offset = 2)),
# br(),
#
# hr(),
# br(),
# h4("Monte Carlo distributions of mortality rate (i.e. deaths/catch) under each scenario"),
# fluidRow(
# column(5, plotOutput("MCplots_MortRate", height = "650px"), offset = 2)
# # column(4,
# # br(), br(), br(), br(),
# # tableOutput("table"))
# ),
#
# hr(),
# br(),
# h4("Median of Monte Carlo distributions of mortality components under each scenario"),
# fluidRow(column(8, plotOutput("MCplots_MedianMortElem", height = "650px"), offset = 2))
#
# ),
#
#
# tabPanel("Contrast summary tables",
#
# h4("Overall mortality rate (i.e. deaths/catch)"),
# tableOutput("table")
# )
# ))
))