-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtab-main.R
410 lines (380 loc) · 27.9 KB
/
tab-main.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
tabmain <- tabPanel(
"Main screen",
fluidRow(
column (5, # offset = 0, style='padding:15px;',
h2("Data input"),
fluidRow(
column(12, radioButtons("datasource", "", inline = TRUE,
choices = c("Text files", "Excel files", "Stored capthist object", "secr dataset"),
selected = "Text files"))
),
conditionalPanel( condition = "input.datasource == 'Text files' | input.datasource == 'Excel files'",
fluidRow(
column(6,
wellPanel(class = "mypanel",
conditionalPanel( condition = "input.datasource == 'Text files'",
div(style="height: 80px;", # non-breaking space ASCII 160
fileInput("trapfilename", # Detector layout file
paste0("1.", strrep(intToUtf8(160),2), "Detector layout"),
multiple = TRUE,
accept = c("text/plain")))),
conditionalPanel( condition = "input.datasource == 'Excel files'",
div(style="height: 80px;", # non-breaking space ASCII 160
fileInput("trapxlsname", paste0("1.", strrep(intToUtf8(160),2), "Detector layout"),
multiple = TRUE,
accept = c(".xls", ".xlsx"))),
fluidRow(
column(12, selectInput("trapsheet", "Sheet",
choices = c("Sheet1"),
multiple = FALSE)) ## WARNING: MULTIPLE SHEETS NOT IMPLEMENTED; REQUIRES CHANGE TO read.traps
)
),
fluidRow(
column(6,
selectInput("detector", "Detector type",
choices = c("single", "multi","proximity","count",
"polygon", "polygonX", "transect", "transectX"),
selected = "multi")
),
conditionalPanel( condition = "input.datasource == 'Text files'",
column(6,
br(),
actionLink("showtrapfilelink", HTML("<small>show file</small>"))
)
)
),
fluidRow(
column(12, style="color:grey;",
div(#style="height: 25px;",
textInput("trapcovnames", "Covariate names",
value = "", placeholder = "e.g., traptype, habitat"))
)
),
fluidRow(
column(12, style="color:grey;",
div(# style="height: 25px;",
textInput("trapotherargs", "Other arguments",value = "", placeholder = "e.g., skip = 1"))
)
)
) # end wellPanel
), # end column(6, )
column(6,
wellPanel(class = "mypanel",
conditionalPanel( condition = "input.datasource == 'Text files'",
div(style="height: 80px;",
fileInput("captfilename", paste0("2.", strrep(intToUtf8(160),2), "Captures"),
accept = c(".txt")))
),
conditionalPanel( condition = "input.datasource == 'Excel files'",
div(style="height: 80px;",
fileInput("captxlsname", paste0("2.", strrep(intToUtf8(160),2), "Captures"),
accept = c(".xls", ".xlsx"))),
fluidRow(
column(12, selectInput("captsheet", "Sheet", choices = c("Sheet1")))
)
),
fluidRow(
column(6, selectInput("fmt", label = "Format",
choices = c("trapID", "XY"))),
column(6,
br(),
conditionalPanel( condition = "input.datasource == 'Text files'",
actionLink("showcaptfilelink", HTML("<small>show file</small>"))
),
actionLink("filtercaptlink", HTML("<small>filter</small>"))
)
),
fluidRow(
column(12, style="color:grey;",
textInput("covnames", "Covariate names",
value = "", placeholder = "e.g., sex")
)
),
fluidRow(
column(12, style="color:grey;",
textInput("captotherargs", "Other arguments",
value = "", placeholder = "e.g., skip = 1")
)
),
fluidRow(
conditionalPanel(condition = "output.filterCapt",
column(12, style="color:grey;",
textInput("filtercapttext", "Filter",
value = "", placeholder = "e.g., session = 1")
)
)
)
) # end wellPanel
) # end column(6,)
) # end fluidRow
), # end conditionalPanel Text, xls
conditionalPanel( condition = "input.datasource == 'Stored capthist object'",
wellPanel(class = "mypanel",
fluidRow(
# known issue: 'accept' does not restrict types in RStudio,
# only in browsers
# https://github.com/rstudio/shiny/issues/951
column(9, fileInput("importfilename",
"Import capthist from RDS file",
accept = c(".RDS", ".Rds",".rds"))),
column(3, br(), actionLink("clearimportlink", "Clear"))
)
)
), # end conditionalPanel stored capthist
conditionalPanel( condition = "input.datasource == 'secr dataset'",
wellPanel(class = "mypanel",
fluidRow(
column(5,
div(style = "margin-top:-15px"),
selectInput("secrdatabox", "",
choices = c(
"captdata",
"blackbearCH",
"deermouse.ESG",
"deermouse.WSG",
"hornedlizardCH",
"housemouse",
"infraCH",
"lineoCH",
"ovenCHp",
"OVpossumCH",
"possumCH",
"stoatCH"),
selected = "captdata",
multiple = FALSE,
selectize = FALSE,
size = 12)),
column(7,
uiOutput("secrdatadescriptionui"),
fluidRow(
column(8),
column(4, actionButton('secrhelptopicbtn', 'More'))))
)
)
), # end conditionalPanel secr dataset
h2("Model"),
wellPanel(class = "mypanel",
fluidRow(
column(3, selectInput("detectfnbox", "Detection function",
choices = c("HN", "HR", "EX","HHN", "HHR", "HEX", "HVP"),
selected = "HN"),
div(style = "margin-top:-15px"), # negative spacer
uiOutput("detectfnui")
),
column(3, radioButtons("likelihoodbtn", "Likelihood", choices = c("Full", "Conditional"))),
column(3, radioButtons("distributionbtn", label = "Distribution of n",
choices = c("Poisson", "Binomial"))),
column(3, style="color:grey;",
selectInput("hcovbox", label = "Mixture hcov",
choices = c("none"), selected = "none", width = 160)
)
),
fluidRow(
div(style = "margin-top:5px"), # spacer
column(6, textInput("model", "Model", value = "D~1, g0~1, sigma~1")),
column(6, HTML("<small><strong>Habitat mask</strong></small>"," "),
HTML(" "),
actionLink("masklink", HTML("<small> edit</small>")),
HTML(" "),
actionLink("suggestbufferlink2", HTML("<small>suggest</small>"),
title = "Based on RPSV(ch, CC = TRUE); RB <= 0.1%"),
br(),
div(style = "margin-top:5px"), # spacer
verbatimTextOutput("maskdetailPrint")
)
),
fluidRow(
column(12, style="color:grey;",
div(style = "margin-top:-15px"), # negative spacer
textInput("modelotherargs", "Other arguments", value = "",
placeholder = "e.g., details = list(fastproximity = FALSE), binomN = 1"))
)
), # end wellPanel Model
h2("Actions"),
fluidRow(
column(3, actionButton("fitbtn", "Fit model", width = 130,
title = "Fit spatially explicit capture-recapture model to estimate density and update Results")),
column(3, actionButton("secrhelpbtn", "secr help", width = 130,
title = "Open secr manual in a browser window",
onclick = "window.open('https://www.otago.ac.nz/density/pdfs/secr-manual.pdf',
'_blank')")),
column(3, uiOutput("secrdesignurl")), ## switch to secrdesign, with parameters
column(3, actionLink("optionslink", "Go to Options"))
),
br(),
fluidRow(
column(3, actionButton("resetbtn", "Reset all", width = 130,
title = "Reset all inputs to initial values")),
# column(3, bookmarkButton(width = 130)), # NOT WORKING 1.3
# column(3, actionButton("dummybookmarkbutton", "Bookmark", width = 130, title = "Bookmarking is disabled in secrapp 2.0")),
column(3, actionButton("refitbtn", "Re-fit model", width = 130, title = "Re-fit with method from Options")),
column(3),
column(3, helpText(HTML("F11 full screen")))
)
), # end left side column (5, )
column (6,
h2("Results"),
fluidRow(
column(6,
radioButtons("resultsbtn", label = "",
inline = TRUE, choices = defaultresultsbtn)
),
column(4,
textInput("otherfunction", label="", placeholder = "e.g., RPSV(ch, CC=TRUE)")
),
conditionalPanel("output.modelFitted",
column(2, br(), downloadLink("savebtn", HTML("<small>Save fitted model</small>"))))
),
fluidRow(
column(12,
tags$head(tags$style("#resultsPrint{overflow-y:scroll; height: 350px;}")),
verbatimTextOutput("resultsPrint"))
),
actionButton("hideresultsbtn", HTML("<small>hide</small>"), class = "btn-link"),
fluidRow(
column(12,
br(),
tabsetPanel(type = "pills",
id = "plottabs",
tabPanel("Code",
br(),
fluidRow(
column(12, verbatimTextOutput("codePrint"))
)
),
tabPanel("Array",
fluidRow(
column(9, style = 'padding:0px;',
plotOutput("arrayPlot",
click = clickOpts(id = "arrayClick", clip = FALSE),
hover = hoverOpts(id ="arrayHover", delayType = "throttle"))),
column(3, br(),
conditionalPanel("output.multisession=='true'",
numericInput("sess", "Session", min = 1, max = 2000,
step = 1, value = 1)),
br(),
conditionalPanel("output.capthistLoaded",
checkboxInput("tracks", "All tracks", FALSE), br(),
numericInput("animal", "Select animal", min = 0, max = 2000,
step = 1, value = 1),
conditionalPanel("input.animal>0", verbatimTextOutput("animalIDPrint")),
conditionalPanel("output.modelFitted", checkboxInput("fxi", "fxi contour", FALSE))
),
conditionalPanel("output.usage",
fluidRow(
column(2, offset = 1, checkboxInput("usageplot", "Usage", FALSE))
)
),
conditionalPanel("input.gridlines != 'None'",
uiOutput("uigridlines") ),
br(),
uiOutput('xycoord')
)
)
# ,
# conditionalPanel("output.capthistLoaded",
# fluidRow(
# column(2, offset = 1, checkboxInput("tracks", "All tracks", FALSE)),
# column(2, numericInput("animal", "Select animal", min = 0, max = 2000,
# step = 1, value = 1)),
# column(4, conditionalPanel("input.animal>0",
# verbatimTextOutput("animalIDPrint")
# )),
# column(3, conditionalPanel("output.modelFitted", checkboxInput("fxi", "fxi contour", FALSE)))
# )),
# conditionalPanel("output.usage",
# fluidRow(
# column(2, offset = 1, checkboxInput("usageplot", "Usage", FALSE))
# )
# )
),
tabPanel("Moves",
fluidRow(
column(8, plotOutput("movesHist", height = 360)),
column(4, br(), br(),
numericInput("nbar", "Nominal breaks",
min = 0,
max = 100,
value = 10,
step = 1,
width = 120),
uiOutput("sessionnumberui"),
verbatimTextOutput("movesPrint"),
conditionalPanel("output.nontrap == 'true'",
uiOutput("moveswarningui") )
)
)),
tabPanel("Detectfn", plotOutput("detnPlot", height = 320)),
tabPanel("Buffer", plotOutput("esaPlot", height = 320)),
tabPanel("Pxy",
br(),
fluidRow(
column(9, style='padding:0px;', plotOutput("pxyPlot", click = "pxyclick")),
column(3, br())
),
fluidRow(
column(9, helpText(HTML("p.(x) is the probability an animal at point x will be detected at least once")))
),
fluidRow(
column(3, checkboxInput("maskedge", "show mask edge", value = FALSE))
)
),
tabPanel("Dxy",
br(),
fluidRow(
column(9, style='padding:0px;', plotOutput("DPlot", click = "Dclick")),
column(3, br())
),
fluidRow(
column(9,helpText(HTML("D(x) is the modelled density at point x")))
),
fluidRow(
column(2, checkboxInput("Dmaskedge", "mask edge", value = FALSE)),
column(2, checkboxInput("Dshowdetectors", "detectors", value = FALSE)),
column(2, checkboxInput("Dshowdetections", "detections", value = FALSE)),
column(2, checkboxInput("Dshowpopn", "random popn", value = FALSE),
uiOutput('uipopN')),
column(4, checkboxInput("showHRbox", "95% HR", value = FALSE))
)
),
tabPanel("Power",
fluidRow(
column(11, plotOutput("powerPlot", height = 320, click = "CIclick"))
),
br(),
fluidRow(
column(3, offset = 1,
br(), checkboxInput("powertype", "95% CI",
value = FALSE,
width = 130)),
## uiOutput('CIpct'),
column(4,
br(), checkboxInput("adjustRSEbox", "Adjust final RSE",
value = TRUE,
width = 130)),
# helpText(HTML("Scales with population"))),
column(4, conditionalPanel("input.powertype==true",
numericInput("xpos", "% change", min = -100, max = 250,
step = 1, value = 0, width = 70)
)
)
),
fluidRow(
column(12,
sliderInput("RSEslider", "",
min = 1.0,
max = 40,
value = 1,
step = 0.1,
pre = "RSE ",
post = "%",
width = "90%"))
)
)
),
actionButton("hidegraphicsbtn", HTML("<small>hide</small>"), class = "btn-link")
)
)
)
)
)