-
Notifications
You must be signed in to change notification settings - Fork 2
/
ui.R
161 lines (159 loc) · 7.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
#################################################-
## USER INTERFACE
#################################################-
## Preliminaries ----
#################################################-
library(shiny)
library(shinyMatrix)
library(rgl)
library(scales)
#################################################-
## Define UI ----
#################################################-
shinyUI(
fluidPage(
# Application title
titlePanel(
h1("How is diversity maintained in multispecies communities?", h2("A structural approach to coexistence"))
),
# HTML tags
tags$head(
tags$style(HTML("hr {border-top: 1px solid #000000;}"))
),
# User inputs
sidebarLayout(
sidebarPanel(
p("Coexistence theory has largely focused on 2-species communities, but this neglects the role of indirect interactions that are found only in larger systems. Saavedra et al. (doi:10.1002/ecm.1263) offers an approach to quantifying diversity in these systems using the mathematics of structural stability borrowed from engineering. Use the controls below to explore how competitor fitness & interactions govern diversity."),
hr(),
h4("Number of Species:"),
radioButtons("spp", label = NULL,
choices = c('3', '4'),
selected = '3'),
hr(),
h4("Species intrinsic growth rates:"),
conditionalPanel(
condition = "input.spp == '3'",
numericInput("r1", "r1", 1, min = 0, max = 1,
step = 0.1),
numericInput("r2", "r2", 0.6, min = 0, max = 1,
step = 0.1),
numericInput("r3", "r3", 0.7, min = 0, max = 1,
step = 0.1),
h4("Interaction coefficients:"),
shinyMatrix::matrixInput(inputId = "alphamat",
value = matrix(c(1, 0.4, 0.3,
0.5, 1, 0.6,
0.05, 0.5, 1),
nrow = 3,
dimnames = list(c("α(1,_)", "α(2,_)", "α(3,_)"), c("α(_,1)", "α(_,2)", "α(_,3)")),
byrow = TRUE),
class = "numeric",
rows = list(names = TRUE,
editableNames = FALSE),
cols = list(names = TRUE,
editableNames = FALSE)),
hr(),
conditionalPanel(condition = "input.spp == '3'",
h4("Scenarios:"),
actionButton("neutral3",
"Quasi-neutrality"),
actionButton("intransient3",
"Rock-paper-scissors"),
actionButton("weakintra3",
"Weak inter-specific interactions")
),
hr(),
h4("Display options:"),
checkboxInput("draw_network", "Species interaction network", value = TRUE),
checkboxInput("draw_table", "Coexistence metric table", value = TRUE),
radioButtons("cone_opt", "Plot cone",
choices = c("none", "static", "interactive"),
selected = "none")
),
conditionalPanel(
condition = "input.spp == '4'",
numericInput("rr1", "r1", 1, min = 0, max = 1, step = 0.1),
numericInput("rr2", "r2", 1, min = 0, max = 1, step = 0.1),
numericInput("rr3", "r3", 0.5, min = 0, max = 1, step = 0.1),
numericInput("rr4", "r4", 0.5, min = 0, max = 1, step = 0.1),
h4("Interaction coefficients:"),
shinyMatrix::matrixInput(inputId = "alphamat4",
value = matrix(c(1, 0.4, 0.3, 0.1,
0.5, 1, 0.6, 0.1,
0.05, 0.5, 1, 0.5,
0.1, 0.2, 0.2, 1),
nrow = 4,
dimnames = list(c("α(1,_)", "α(2,_)", "α(3,_)", "α(4,_)"),
c("α(_,1)", "α(_,2)", "α(_,3)", "α(_,4)")),
byrow = TRUE),
class = "numeric",
rows = list(names = TRUE,
editableNames = FALSE),
cols = list(names = TRUE,
editableNames = FALSE)),
hr(),
conditionalPanel(condition = "input.spp == '4'",
h4("Scenarios:"),
actionButton("neutral4",
"Quasi-neutrality"),
actionButton("weakintra4",
"Weak inter-specific interactions")
),
hr(),
h4("Display options:"),
checkboxInput("draw_network4sp", "Species interaction network", value = TRUE),
checkboxInput("draw_table4sp", "Coexistence metric table", value = TRUE)
)
),
# Outputs
mainPanel(
# 3 species
fluidRow(
conditionalPanel("input.spp == '3' & input.draw_network",
column(width = 7,
plotOutput("network_3sp")
)
),
conditionalPanel("input.spp == '3' & input.draw_table",
column(width = 5,
h5("Coexistence metrics"),
tableOutput("stats")
)
)),
conditionalPanel("input.spp == '3'",
fluidRow(
plotOutput("proj")
)
),
conditionalPanel("input.spp == '3' & input.cone_opt == 'static'",
fluidRow(
plotOutput("cone")
)
),
conditionalPanel("input.spp == '3' & input.cone_opt == 'interactive'",
fluidRow(
rglwidgetOutput("cone3d")
)
),
# 4 species
fluidRow(
conditionalPanel("input.spp == '4' & input.draw_network4sp",
column(width = 7,
plotOutput("network_4sp")
)
),
conditionalPanel("input.spp == '4' & input.draw_table4sp",
column(width = 5,
h5("Coexistence metrics"),
tableOutput("stats4sp")
)
)),
conditionalPanel("input.spp == '4'",
fluidRow(
rglwidgetOutput("proj4sp")
)
)
)
)
)
)