forked from andandandand/OACC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.R
311 lines (230 loc) · 15 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
library(shiny)
shinyUI(
fluidPage(
#titlePanel("The Online Algorithmic Complexity Calculator"),
sidebarLayout(
column(6,
tabsetPanel(
tabPanel("For any string",
value = 1,
h3("Block Decomposition Method for Strings"),
div(wellPanel(
textInput(inputId = "bdmInputString",
label = "Enter a string",
value ="010101010101010101010101010101010101",
width ="800px"),
sliderInput(inputId = "blockSize",
label = "Block size",
min = 2, max = 12, value = 12, step = 1),
#max becomes the current value of blockSize -1
#dynamically
sliderInput(inputId = "blockOverlap",
label = "Block overlap",
min = 0, max = 11, value = 0, step = 1),
radioButtons(inputId = "bdmAlphabet",
label = "Alphabet size",
inline = TRUE,
choices = list("2" = 2,
"4" = 4,
"5" = 5,
"6" = 6,
"9" = 9,
"256 (utf-8)" = 256),
selected = 2),
br(),
actionButton("goButtonBDM1D", "Evaluate")
), style="font-size:115%")
),
tabPanel("For binary arrays/adjacency matrices",
value = 2,
h3(
"Block Decomposition Method for Unweighted Adjacency Matrices"),
div(wellPanel(
fileInput(inputId = 'file1',
label = "Choose a CSV file",
accept = c('text/comma-separated-values',
'text/plain',
'text/csv', '.csv')
),
radioButtons(inputId = 'bdm2DBlockSize',
label = 'Block size',
choices = c('4 x 4' = 4,
'3 x 3' = 3),
selected = 4),
sliderInput(inputId = 'bdm2DOverlap',
label = "Block overlap (rows and columns)",
min = 0,
max = 3,
step = 1,
value = 0),
actionButton("goButtonBDM2D", "Evaluate")
) #end wellPanel BDM 2D
, style="font-size: 115%")
), #end tabPanel BDM 2D
tabPanel("For short strings",
value = 3,
h3("Algorithmic Complexity for Short Strings"),
div(wellPanel(
textInput(inputId = "ctmInputStrings",
label = "Strings to evaluate",
value ="AAAAAAAAAAAA ATATATATATAT ATTGCCGGCCTA",
width = "800px")
,
p("Use space to separate strings."),
p("The length of each string must be shorter than 13 characters."),
radioButtons(inputId = "ctmAlphabet",
label = "Alphabet size",
inline = TRUE,
choices = list("2" = 2,
"4" = 4,
"5" = 5,
"6" = 6,
"9" = 9),
selected = 4),
selectInput(#inputId="shortStringsEvalFunction", #"argument is not interpretable as logical" error
inputId="funct",
label = "Function used to evaluate the strings",
choices = list("CTM Kolmogorov complexity estimated by algorithmic probability " = "acss",
"Shannon entropy" = "entropy",
"Second order entropy" = "entropy2",
"Compression length by gzip"="compression-gzip",
"Compression length by bzip2" = "compression-bzip2",
"Compression length by xz" = "compression-xz",
"Likelihood of production by Turing machines (deterministic process)" = "likelihood_d",
"Likelihood of production by Turing machines (random process)" = "likelihood_ratio",
"Conditional probability of random appearance" = "prob_random"
),
selected = "acss"),
actionButton("goButtonCTM", "Evaluate")
)), # end wellPanel "For short strings",
style="font-size:115%"), #end tabPanel "For short strings"
tabPanel("Network perturbation",
value = 4,
h3("Algorithmic Perturbation Analysis of Unweighted Networks"),
div(wellPanel(
fileInput(inputId = "file2",
label = "Choose a CSV file",
accept = c('text/comma-separated-values',
'text/plain',
'text/csv',
'.csv')
),
selectInput(inputId = "vertexToDelete",
label = "Node to delete",
choices = ""), # choices filled in by server
actionButton(inputId = "goButtonDeleteVertex",
label = "Delete node"),
span(textOutput(outputId = "cantDeleteVertex"),
style = "color:red"),
hr(),
selectInput(inputId = "edgeToDelete",
label = "Edge to delete",
choices = ""), # choices filled in by server
actionButton(inputId = "goButtonDeleteEdge",
label = "Delete link"),
span(textOutput(outputId = "cantDeleteLink"),
style="color:red"),
hr(),
radioButtons(inputId = "printTable",
label = h4("Perturbation Table"),
choices = list("Nodes" = "vertices",
"Links" = "edges"),
selected = "vertices"),
hr(),
downloadButton('report', # name of downloadHandler in server
'Download report')
)),
style = "font-size:115%"), # end tabPanel "Network Perturbation"
id = "conditionedPanels"
)
),
mainPanel(
withMathJax(),
conditionalPanel(condition="input.conditionedPanels==1",
br(),
h3("Result of Evaluation"),
br(),
div(p(textOutput("evaluatedString")),
style="font-size:120%",
align="center"),
br(),
div(tableOutput("resultBDMTable"),
style="font-size : 120%;
font-family: Arial, Helvetica, sans-serif;",
align="center"),
hr(),
div(p("$$\\textit{BDM} =
\\sum_{i=1}^{n} \\textit{K}(\\textit{block}_{i})
+\\textit{log}_{2}(|\\textit{block}_{i}|)$$"),
style="font-size: 120%",
align="center"),
hr(),
div(p("Strings that don't appear in the
\\(D(\\#\\textit{of states}, \\#\\textit{ of symbols})\\)
distribution have their
\\(\\textit{K}\\) value estimated as"),
style="font-size:110%"),
div(p("$$ \\textit{Max}(K(\\#\\textit{ of states}, \\#\\textit{ of symbols}))
+ 1 $$"),
style="font-size:110%")
), ##end BDM 1D tab
conditionalPanel(condition="input.conditionedPanels==2",
br(),
h3("Adjacency Matrix"),
div(tableOutput("loadedGraph"), align="center", style="font-size: 110%"),
br(),
h3("Result of Evaluation"),
div(tableOutput("resultBDM2DTable"), style="font-size: 120%", align="center"),
hr(),
div(p("$$BDM =
\\sum_{i=1}^{n} K(block_{i})+log_{2}(|block_{i}|)$$"),
style ="font-size: 120%")
), ##end BDM 2D tab
conditionalPanel(condition ="input.conditionedPanels==3",
br(),
h3("Result of Evaluation"),
br(),
div(tableOutput("resultCTM"),
style = "font-size: 120%",
align = "center"),
hr(),
conditionalPanel(condition = "input.funct == 'acss'",
div(p("$$K(\\#\\textit{ of states}, \\#\\textit{ of symbols}) =
-log_{2}(D(\\#\\textit{of states}, \\textit{# of symbols})$$"),
style = "font-size: 120%"),
hr(),
div(p("\\(\\textit{}~\\)\\(K(\\#\\textit{ of states}, \\#\\textit{ of symbols})\\)
indicates the estimated Kolmogorov complexity of
the string by the Coding Theorem Method."),
style="font-size:110%"),
hr(),
div(p("\\(D(\\#\\textit{of states}, \\#\\textit{ of symbols})\\) indicates the
estimated algorithmic probability,
which is the output frequency of the string
by Turing machines with the same alphabet."),
style="font-size:110%"),
hr(),
div(p("Strings that don't appear in the
\\(D(\\#\\textit{of states}, \\#\\textit{ of symbols})\\)
distribution have their
\\(\\textit{K}\\) value estimated as"),
style="font-size:110%"),
div(p("$$ \\textit{Max}(K(\\#\\textit{ of states}, \\#\\textit{ of symbols}))
+ 1 $$"),
style="font-size:110%"),
hr(),
div(p("More information on the other complexity
functions is available in the ",
a(href="https://cran.r-project.org/web/packages/acss/acss.pdf",
"documentation of the ACSS package @ CRAN.")),
style="font-size:110%", align="center")
)
), ## #end conditionalPanel CTM chosen
conditionalPanel(condition ="input.conditionedPanels==4",
br(),
plotOutput("graphPlot"),
tableOutput("perturbationTable")
)
) ## end mainPanel
)
))