ui.R 14 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
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
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
        br(),
dmattek's avatar
Mod:  
dmattek committed
80
        modTrajPlotUI('modTrajPlot')
dmattek's avatar
dmattek committed
81
        ),
dmattek's avatar
Mod:  
dmattek committed
82
      
dmattek's avatar
dmattek committed
83
      
dmattek's avatar
dmattek committed
84 85 86
      tabPanel(
        "Box-plots",
        tabBoxPlotUI('tabBoxPlot')
dmattek's avatar
dmattek committed
87 88 89
      ),
      

dmattek's avatar
dmattek committed
90 91 92 93 94 95
      # scatter plot
      tabPanel(
        'Scatter',
        tabScatterPlotUI('tabScatter')
      ),
      
dmattek's avatar
dmattek committed
96 97 98 99
      tabPanel(
        'Hierarchical',
        br(),
        fluidRow(
dmattek's avatar
dmattek committed
100
          column(4,
dmattek's avatar
dmattek committed
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
            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
127
          column(4,
dmattek's avatar
dmattek committed
128 129 130 131 132 133 134 135 136 137 138
                 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
139 140 141
                 uiOutput('uiPlotHierClSel'),
                 #downCellClUI('downDataHier', "Download Data")
                 downloadButton('downCellCl', 'Download CSV with cell IDs and cluster no.')
dmattek's avatar
dmattek committed
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
          )
        ),
        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
228
                   downPlotUI('downPlotHier', "Download PDF"),
dmattek's avatar
dmattek committed
229 230 231 232 233 234
                   actionButton('butPlotHierHeatMap', 'Plot!'),
                   plotOutput('outPlotHier')
          ),
          # tabPanel('Heat-map int.',
          #          helpText("Choose your settings 2")),
          tabPanel('Time-courses',
dmattek's avatar
Mod:  
dmattek committed
235 236
                   modTrajPlotUI('modPlotHierTraj')),
          
dmattek's avatar
dmattek committed
237
          tabPanel('Cluster dist.',
dmattek's avatar
Mod:  
dmattek committed
238 239
                   modClDistPlotUI('hierClDistPlot', 'xxx'))
          
dmattek's avatar
dmattek committed
240 241 242 243 244 245 246 247 248
        )
      ),
      
      
      tabPanel(
        'Hier. Sparse',
        br(),
        fluidRow(
          column(
dmattek's avatar
Mod:  
dmattek committed
249
            4,
dmattek's avatar
dmattek committed
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266
            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
dmattek's avatar
Mod:  
dmattek committed
267 268 269 270 271
            )
          ),
          
          column(
            4,
dmattek's avatar
dmattek committed
272 273 274 275
            sliderInput(
              'inPlotHierSparNclust',
              '#dendrogram branches to colour',
              min = 1,
dmattek's avatar
Mod:  
dmattek committed
276
              max = 20,
dmattek's avatar
dmattek committed
277 278 279 280
              value = 1,
              step = 1,
              ticks = TRUE,
              round = TRUE
dmattek's avatar
Mod:  
dmattek committed
281 282 283 284
            ),
            checkboxInput('chBPlotHierSparClSel', 'Manually select clusters to display'),
            uiOutput('uiPlotHierSparClSel'),
            downloadButton('downCellClSpar', 'Download CSV with cell IDs and cluster no.')
dmattek's avatar
dmattek committed
285 286 287
          ),
          
          column(
dmattek's avatar
Mod:  
dmattek committed
288
            4,
dmattek's avatar
dmattek committed
289 290 291 292 293 294 295 296
            checkboxInput('inHierSparAdv',
                          'Advanced options',
                          FALSE),
            uiOutput(
              'uiPlotHierSparNperms'
            ),
            uiOutput(
              'uiPlotHierSparNiter'
dmattek's avatar
Mod:  
dmattek committed
297
            )
dmattek's avatar
dmattek committed
298 299 300 301 302 303 304 305 306 307 308
          )
        ),
        
        
        br(),
        #checkboxInput('inPlotHierSparInteractive', 'Interactive Plot?',  value = FALSE),
        
        tabsetPanel(
          tabPanel('Heat-map',
                   fluidRow(
                     column(3,
dmattek's avatar
Mod:  
dmattek committed
309
                            checkboxInput('selectPlotHierSparDend', 'Plot dendrogram and re-order samples', TRUE),
dmattek's avatar
dmattek committed
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
                            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
dmattek's avatar
Mod:  
dmattek committed
328 329 330 331 332 333
                            ),
                            numericInput('inPlotHierSparHeatMapHeight', 
                                         'Display plot height [px]', 
                                         value = 600, 
                                         min = 100,
                                         step = 100)
dmattek's avatar
dmattek committed
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
                     ),
                     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
400 401
                   downPlotUI('downPlotHierSparHM', "Download PDF"),

dmattek's avatar
dmattek committed
402 403 404 405 406 407
                   actionButton('butPlotHierSparHeatMap', 'Plot!'),
                   plotOutput('outPlotHierSpar')
          ),
          # tabPanel('Heat-map int.',
          #          helpText("Choose your settings 2")),
          tabPanel('Time-courses',
dmattek's avatar
Mod:  
dmattek committed
408
                   modTrajPlotUI('modPlotHierSparTraj')),
dmattek's avatar
dmattek committed
409
          tabPanel('Cluster dist.',
dmattek's avatar
Mod:  
dmattek committed
410
                   modClDistPlotUI('hierClSparDistPlot'))
dmattek's avatar
dmattek committed
411
        )
dmattek's avatar
dmattek committed
412 413 414 415 416
      )
      # 
      # tabPanel(
      #   'Bayesian Cl.',
      #   clustBayUI('TabClustBay'))
417
      
dmattek's avatar
dmattek committed
418 419 420
    ))
  )
))