ui.R 15.8 KB
Newer Older
dmattek's avatar
dmattek committed
1

dmattek's avatar
dmattek committed
2

dmattek's avatar
dmattek committed
3
4
5
6
7
8
9
# This is the user-interface definition of a Shiny web application.
# You can find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com
#

library(shiny)
dmattek's avatar
dmattek committed
10
library(shinyjs) #http://deanattali.com/shinyjs/
dmattek's avatar
dmattek committed
11
12
13
library(plotly)

shinyUI(fluidPage(
dmattek's avatar
dmattek committed
14
15
  useShinyjs(),
  # Include shinyjs
dmattek's avatar
dmattek committed
16
17
18
19
  
  # Application title
  title = "Timecourse Inspector",
  
dmattek's avatar
dmattek committed
20
21
22
23
24
  sidebarLayout(
    sidebarPanel(
      #Selector for file upload
      fileInput(
        'inFileLoadNuc',
dmattek's avatar
dmattek committed
25
        'Select data file (e.g. tCoursesSelected.csv) and press "Load Data"',
dmattek's avatar
dmattek committed
26
27
28
29
30
        accept = c('text/csv', 'text/comma-separated-values,text/plain')
      ),
      actionButton("inButLoadNuc", "Load Data"),
      actionButton("butReset", "Reset file input"),
      actionButton('inDataGen1', 'Generate artificial dataset'),
dmattek's avatar
dmattek committed
31

dmattek's avatar
dmattek committed
32
      tags$hr(),
dmattek's avatar
Added:    
dmattek committed
33
      checkboxInput('chBtrackUni', 'Track Label unique across entire dataset', FALSE),
dmattek's avatar
dmattek committed
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
      uiOutput('varSelSite'),
      uiOutput('varSelTrackLabel'),
      uiOutput('varSelGroup'),
      uiOutput('varSelTime'),
      uiOutput('varSelMeas1'),
      radioButtons(
        'inSelMath',
        'Math operation 1st and 2nd meas.:',
        c(
          'None' = '',
          'Divide' = " / ",
          'Sum' = " + ",
          'Multiply' = " * ",
          'Subtract' = ' - ',
          '1 / X' = '1 / '
        )
      ),
dmattek's avatar
dmattek committed
51
52
      uiOutput('varSelMeas2'),
      
dmattek's avatar
dmattek committed
53
54
55
      tags$hr(),
      checkboxInput('chBtimeTrim', 'Trim x-axis', FALSE),
      uiOutput('uiSlTimeTrim'),
dmattek's avatar
dmattek committed
56
57
58
59
60
      tags$hr(),
      checkboxInput('chBnorm', 'Normalization', FALSE),
      uiOutput('uiChBnorm'),
      uiOutput('uiSlNorm'),
      uiOutput('uiChBnormRobust'),
dmattek's avatar
dmattek committed
61
62
63
      uiOutput('uiChBnormGroup'),
      tags$hr(),
      checkboxInput('chBoutliers', 'Remove outliers', FALSE),
dmattek's avatar
dmattek committed
64
65
66
      uiOutput('uiSlOutliers'),
      uiOutput("uiTxtOutliers"),
      downloadButton('downloadDataClean', 'Download mod\'d data')
67
    ),
dmattek's avatar
dmattek committed
68
69
70
71
    
    mainPanel(tabsetPanel(
      tabPanel(
        "Time courses",
dmattek's avatar
Added:    
dmattek committed
72
73
74
75
76
77
78
        h4(
          "Plot time series"
        ),
  
        br(),
        checkboxInput('chBhighlightTraj', 'Highlight trajectories?', FALSE),
        uiOutput('varSelHighlight'),
dmattek's avatar
dmattek committed
79
80
81
82
83
84
85
86
87
88
89
        br(),
        fluidRow(
          column(
            4,
            numericInput(
              'inPlotTrajFacetNcol',
              '#Columns:',
              value = 4,
              min = 1,
              width = '100px',
              step = 1
dmattek's avatar
Added:    
dmattek committed
90
91
92
            ),
            checkboxInput('chBplotTrajInt', 'Interactive Plot?'),
            actionButton('butPlotTraj', 'Plot!')
dmattek's avatar
dmattek committed
93
94
95
          ),
          column(
            4,
dmattek's avatar
Added:    
dmattek committed
96
            sliderInput('sliPlotTrajSkip', 'Plot every n-th point:', min = 1, max = 10, value = 5, step = 1)
dmattek's avatar
dmattek committed
97
98
99
100
101
102
103
104
105
106
107
          ),
          column(
            4,
            numericInput(
              'inPlotTrajWidth',
              'Width [%]:',
              value = 100,
              min = 10,
              max = 100,
              width = '100px',
              step = 10
dmattek's avatar
Added:    
dmattek committed
108
109
110
111
112
113
114
115
            ),
            numericInput(
              'inPlotTrajHeight',
              'Height [px]:',
              value = 800,
              min = 100,
              width = '100px',
              step = 50
dmattek's avatar
dmattek committed
116
117
118
            )
          )
        ),
dmattek's avatar
dmattek committed
119
        uiOutput('uiPlotTraj'),
dmattek's avatar
dmattek committed
120
        downPlotUI('downPlotTraj', "Download PDF")
dmattek's avatar
dmattek committed
121
      ),
dmattek's avatar
dmattek committed
122
      
dmattek's avatar
Added:    
dmattek committed
123
124
125
      tabPanel(
        "Box-plots",
        tabBoxPlotUI('tabBoxPlot')
dmattek's avatar
dmattek committed
126
127
128
      ),
      

dmattek's avatar
dmattek committed
129
130
131
132
133
134
      # scatter plot
      tabPanel(
        'Scatter',
        tabScatterPlotUI('tabScatter')
      ),
      
dmattek's avatar
dmattek committed
135
136
137
138
      tabPanel(
        'Hierarchical',
        br(),
        fluidRow(
dmattek's avatar
dmattek committed
139
          column(4,
dmattek's avatar
dmattek committed
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
            selectInput(
              "selectPlotHierLinkage",
              label = ("Select linkage method:"),
              choices = list(
                "Ward" = 1,
                "Ward D2" = 2,
                "Single" = 3,
                "Complete" = 4,
                "Average" = 5,
                "McQuitty" = 6,
                "Centroid" = 7
              ),
              selected = 2
            ),
            selectInput(
              "selectPlotHierDiss",
              label = ("Select type of dissimilarity measure:"),
              choices = list("Euclidean" = 1,
                             "Maximum" = 2,
                             "Manhattan" = 3,
                             "Canberra" = 4,
                             "Binary" = 5,
                             "Minkowski" = 6),
              selected = 1
            )
          ),
dmattek's avatar
dmattek committed
166
          column(4,
dmattek's avatar
dmattek committed
167
168
169
170
171
172
173
174
175
176
177
                 sliderInput(
                   'inPlotHierNclust',
                   '#dendrogram branches to colour',
                   min = 1,
                   max = 20,
                   value = 1,
                   step = 1,
                   ticks = TRUE,
                   round = TRUE
                 ),
                 checkboxInput('chBPlotHierClSel', 'Manually select clusters to display'),
dmattek's avatar
dmattek committed
178
179
180
                 uiOutput('uiPlotHierClSel'),
                 #downCellClUI('downDataHier', "Download Data")
                 downloadButton('downCellCl', 'Download CSV with cell IDs and cluster no.')
dmattek's avatar
dmattek committed
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
          )
        ),
        br(),
        #checkboxInput('inPlotHierSparInteractive', 'Interactive Plot?',  value = FALSE),
        
        tabsetPanel(
          tabPanel('Heat-map',
                   fluidRow(
                     column(3,
                            checkboxInput('selectPlotHierDend', 'Plot dendrogram and re-order samples', TRUE),
                            selectInput(
                              "selectPlotHierPalette",
                              label = "Select colour palette:",
                              choices = l.col.pal,
                              selected = 'Spectral'
                            ),
                            checkboxInput('inPlotHierRevPalette', 'Reverse colour palette', TRUE),
                            checkboxInput('selectPlotHierKey', 'Plot colour key', TRUE)
                     ),
                     column(3,
                            sliderInput(
                              'inPlotHierNAcolor',
                              'Shade of grey for NA values (0 - black, 1 - white)',
                              min = 0,
                              max = 1,
                              value = 0.8,
                              step = .1,
                              ticks = TRUE
                            ),
                            numericInput('inPlotHierHeatMapHeight', 
                                         'Display plot height [px]', 
                                         value = 600, 
                                         min = 100,
                                         step = 100)
                     ),
                     column(6,
                            h4('Classic hierarchical clustering')
                     )
                   ),
                   
                   fluidRow(
                     column(
                       3,
                       numericInput(
                         'inPlotHierMarginX',
                         'Margin below x-axis',
                         5,
                         min = 1,
                         width = 100
                       )
                     ),
                     column(
                       3,
                       numericInput(
                         'inPlotHierMarginY',
                         'Margin right of y-axis',
                         20,
                         min = 1,
                         width = 100
                       )
                     ),
                     column(
                       3,
                       numericInput(
                         'inPlotHierFontX',
                         'Font size row labels',
                         1,
                         min = 0,
                         width = 100,
                         step = 0.1
                       )
                     ),
                     column(
                       3,
                       numericInput(
                         'inPlotHierFontY',
                         'Font size column labels',
                         1,
                         min = 0,
                         width = 100,
                         step = 0.1
                       )
                     )
                   ),
                   br(),
                   
dmattek's avatar
dmattek committed
267
                   downPlotUI('downPlotHier', "Download PDF"),
dmattek's avatar
dmattek committed
268
269
270
271
272
273
                   actionButton('butPlotHierHeatMap', 'Plot!'),
                   plotOutput('outPlotHier')
          ),
          # tabPanel('Heat-map int.',
          #          helpText("Choose your settings 2")),
          tabPanel('Time-courses',
dmattek's avatar
dmattek committed
274
                   downPlotUI('downPlotHierTraj', "Download PDF"),
dmattek's avatar
dmattek committed
275
276
277
                   actionButton('butPlotHierTraj', 'Plot!'),
                   plotOutput('outPlotHierTraj')),
          tabPanel('Cluster dist.',
dmattek's avatar
dmattek committed
278
                   downPlotUI('downPlotHierClDist', "Download PDF"),
dmattek's avatar
dmattek committed
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
                   actionButton('butPlotHierClDist', 'Plot!'),
                   plotOutput('outPlotHierClDist'))
        )
      ),
      
      
      tabPanel(
        'Hier. Sparse',
        br(),
        fluidRow(
          column(
            6,
            selectInput(
              "selectPlotHierSparLinkage",
              label = ("Select linkage method:"),
              choices = list(
                "Average" = 1,
                "Complete" = 2,
                "Single" = 3,
                "Centroid" = 4
              ),
              selected = 1
            ),
            selectInput(
              "selectPlotHierSparDiss",
              label = ("Select type of dissimilarity measure:"),
              choices = list("Squared Distance" = 1,
                             "Absolute Value" = 2),
              selected = 1
            ),
            sliderInput(
              'inPlotHierSparNclust',
              '#dendrogram branches to colour',
              min = 1,
              max = 30,
              value = 1,
              step = 1,
              ticks = TRUE,
              round = TRUE
            )
          ),
          
          column(
            6,
            checkboxInput('inHierSparAdv',
                          'Advanced options',
                          FALSE),
            uiOutput(
              'uiPlotHierSparNperms'
            ),
            uiOutput(
              'uiPlotHierSparNiter'
            ),
            checkboxInput('chBPlotHierSparClSel', 'Manually select clusters to display'),
dmattek's avatar
dmattek committed
333
334
            uiOutput('uiPlotHierSparClSel'),
            downloadButton('downCellClSpar', 'Download CSV with cell IDs and cluster no.')
dmattek's avatar
dmattek committed
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
432
433
434
435
436
437
438
439
          )
        ),
        
        
        br(),
        #checkboxInput('inPlotHierSparInteractive', 'Interactive Plot?',  value = FALSE),
        
        tabsetPanel(
          tabPanel('Heat-map',
                   fluidRow(
                     column(3,
                            radioButtons(
                              "selectPlotHierSparDend",
                              label = 'Dendrogram',
                              choices = list(
                                'Plot dendrogram; order samples accordingly' = 1,
                                'Don\'t plot dendrogram; retain original ordering' = 2
                              ),
                              selected = 1
                            ),
                            selectInput(
                              "selectPlotHierSparPalette",
                              label = "Select colour palette:",
                              choices = l.col.pal,
                              selected = 'Spectral'
                            ),
                            checkboxInput('inPlotHierSparRevPalette', 'Reverse colour palette', TRUE),
                            checkboxInput('selectPlotHierSparKey', 'Plot colour key', TRUE)
                     ),
                     column(3,
                            sliderInput(
                              'inPlotHierSparNAcolor',
                              'Shade of grey for NA values (0 - black, 1 - white)',
                              min = 0,
                              max = 1,
                              value = 0.8,
                              step = .1,
                              ticks = TRUE
                            )
                     ),
                     column(6,
                            br(),
                            h4(
                              "Sparse hierarchical clustering using ",
                              a("sparcl", href = "https://cran.r-project.org/web/packages/sparcl/")
                            ),
                            p(
                              'Column labels in the heat-map are additionally labeld according to their \"importance\":'
                            ),
                            tags$ol(
                              tags$li("Black - not taken into account"),
                              tags$li("Blue with \"*\" - low importance (weight factor in (0, 0.1]"),
                              tags$li("Green with \"**\" - medium importance (weight factor in (0.1, 0.5]"),
                              tags$li("Red with \"***\" - high importance (weight factor in (0.5, 1.0]")
                            )
                     )
                   ),
                   
                   fluidRow(
                     column(
                       3,
                       numericInput(
                         'inPlotHierSparMarginX',
                         'Margin below x-axis',
                         5,
                         min = 1,
                         width = 100
                       )
                     ),
                     column(
                       3,
                       numericInput(
                         'inPlotHierSparMarginY',
                         'Margin right of y-axis',
                         20,
                         min = 1,
                         width = 100
                       )
                     ),
                     column(
                       3,
                       numericInput(
                         'inPlotHierSparFontX',
                         'Font size row labels',
                         1,
                         min = 0,
                         width = 100,
                         step = 0.1
                       )
                     ),
                     column(
                       3,
                       numericInput(
                         'inPlotHierSparFontY',
                         'Font size column labels',
                         1,
                         min = 0,
                         width = 100,
                         step = 0.1
                       )
                     )
                   ),
                   br(),
                   
                   
dmattek's avatar
dmattek committed
440
441
                   downPlotUI('downPlotHierSparHM', "Download PDF"),

dmattek's avatar
dmattek committed
442
443
444
445
446
447
448
449
450
451
452
453
                   numericInput('inPlotHierSparHeatMapHeight', 
                                'Display plot height [px]', 
                                value = 600, 
                                min = 100,
                                step = 100),
                   
                   actionButton('butPlotHierSparHeatMap', 'Plot!'),
                   plotOutput('outPlotHierSpar')
          ),
          # tabPanel('Heat-map int.',
          #          helpText("Choose your settings 2")),
          tabPanel('Time-courses',
dmattek's avatar
dmattek committed
454
                   downPlotUI('downPlotHierSparTraj', "Download PDF"),
dmattek's avatar
dmattek committed
455
456
457
                   actionButton('butPlotHierSparTraj', 'Plot!'),
                   plotOutput('outPlotHierSparTraj')),
          tabPanel('Cluster dist.',
dmattek's avatar
dmattek committed
458
                   downPlotUI('downPlotHierSparClDist', "Download PDF"),
dmattek's avatar
dmattek committed
459
460
461
                   actionButton('butPlotHierSparClDist', 'Plot!'),
                   plotOutput('outPlotHierSparClDist'))
        )
dmattek's avatar
Added:    
dmattek committed
462
463
464
465
466
      )
      # 
      # tabPanel(
      #   'Bayesian Cl.',
      #   clustBayUI('TabClustBay'))
467
      
dmattek's avatar
dmattek committed
468
469
470
    ))
  )
))