ui.R 16.2 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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
      tags$hr(),
      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
50 51
      uiOutput('varSelMeas2'),
      
dmattek's avatar
dmattek committed
52 53 54
      tags$hr(),
      checkboxInput('chBtimeTrim', 'Trim x-axis', FALSE),
      uiOutput('uiSlTimeTrim'),
dmattek's avatar
dmattek committed
55 56 57 58 59
      tags$hr(),
      checkboxInput('chBnorm', 'Normalization', FALSE),
      uiOutput('uiChBnorm'),
      uiOutput('uiSlNorm'),
      uiOutput('uiChBnormRobust'),
dmattek's avatar
dmattek committed
60 61 62
      uiOutput('uiChBnormGroup'),
      tags$hr(),
      checkboxInput('chBoutliers', 'Remove outliers', FALSE),
dmattek's avatar
dmattek committed
63 64 65
      uiOutput('uiSlOutliers'),
      uiOutput("uiTxtOutliers"),
      downloadButton('downloadDataClean', 'Download mod\'d data')
66
    ),
dmattek's avatar
dmattek committed
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
    
    mainPanel(tabsetPanel(
      tabPanel(
        "Time courses",
        br(),
        fluidRow(
          column(
            4,
            numericInput(
              'inPlotTrajFacetNcol',
              '#Columns:',
              value = 4,
              min = 1,
              width = '100px',
              step = 1
            )
          ),
          column(
            4,
            numericInput(
              'inPlotTrajHeight',
              'Height [px]:',
              value = 800,
              min = 100,
              width = '100px',
              step = 50
            )
          ),
          column(
            4,
            numericInput(
              'inPlotTrajWidth',
              'Width [%]:',
              value = 100,
              min = 10,
              max = 100,
              width = '100px',
              step = 10
            )
          )
        ),
        checkboxInput('chBhighlightTraj', 'Highlight trajectories?', FALSE),
        uiOutput('varSelHighlight'),
        br(),
        actionButton('butPlotTraj', 'Plot!'),
dmattek's avatar
dmattek committed
112
        uiOutput('uiPlotTraj'),
dmattek's avatar
dmattek committed
113
        downPlotUI('downPlotTraj', "Download PDF")
dmattek's avatar
dmattek committed
114
      ),
dmattek's avatar
dmattek committed
115
      
dmattek's avatar
dmattek committed
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
      tabPanel("Box-plots",
               br(),
               fluidRow(
                 column(
                   6,
                   checkboxInput('inPlotBoxNotches', 'Box plot notches?', FALSE),
                   checkboxInput('inPlotBoxOutliers', 'Box plot outliers?', TRUE)
                 ),
                 column(
                   6,
                   selectInput('selPlotBoxLegendPos', 
                               label = 'Select legend position',
                               choices = list(
                                 "Top" = 'top',
                                 "Right" = 'right',
                                 "Bottom" = 'bottom'
                               ),
                               selected = 'top')
                 )
               ),
               
               uiOutput('varSelTpts'),
               
               actionButton('butPlotBox', 'Plot!'),
               plotOutput('outPlotBox', height = 800),
dmattek's avatar
dmattek committed
141
               downPlotUI('downPlotBox', "Download PDF")
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
      ),
      

      tabPanel(
        'Hierarchical',
        br(),
        fluidRow(
          column(
            6,
            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
            )
          ),
          column(6,
                 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
189 190 191
                 uiOutput('uiPlotHierClSel'),
                 #downCellClUI('downDataHier', "Download Data")
                 downloadButton('downCellCl', 'Download CSV with cell IDs and cluster no.')
dmattek's avatar
dmattek committed
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
          )
        ),
        
        
        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
280
                   downPlotUI('downPlotHier', "Download PDF"),
dmattek's avatar
dmattek committed
281 282 283 284 285 286
                   actionButton('butPlotHierHeatMap', 'Plot!'),
                   plotOutput('outPlotHier')
          ),
          # tabPanel('Heat-map int.',
          #          helpText("Choose your settings 2")),
          tabPanel('Time-courses',
dmattek's avatar
dmattek committed
287
                   downPlotUI('downPlotHierTraj', "Download PDF"),
dmattek's avatar
dmattek committed
288 289 290
                   actionButton('butPlotHierTraj', 'Plot!'),
                   plotOutput('outPlotHierTraj')),
          tabPanel('Cluster dist.',
dmattek's avatar
dmattek committed
291
                   downPlotUI('downPlotHierClDist', "Download PDF"),
dmattek's avatar
dmattek committed
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
                   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
346 347
            uiOutput('uiPlotHierSparClSel'),
            downloadButton('downCellClSpar', 'Download CSV with cell IDs and cluster no.')
dmattek's avatar
dmattek committed
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 440 441 442 443 444 445 446 447 448 449 450 451 452
          )
        ),
        
        
        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
453 454
                   downPlotUI('downPlotHierSparHM', "Download PDF"),

dmattek's avatar
dmattek committed
455 456 457 458 459 460 461 462 463 464 465 466
                   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
467
                   downPlotUI('downPlotHierSparTraj', "Download PDF"),
dmattek's avatar
dmattek committed
468 469 470
                   actionButton('butPlotHierSparTraj', 'Plot!'),
                   plotOutput('outPlotHierSparTraj')),
          tabPanel('Cluster dist.',
dmattek's avatar
dmattek committed
471
                   downPlotUI('downPlotHierSparClDist', "Download PDF"),
dmattek's avatar
dmattek committed
472 473 474
                   actionButton('butPlotHierSparClDist', 'Plot!'),
                   plotOutput('outPlotHierSparClDist'))
        )
dmattek's avatar
dmattek committed
475 476 477 478
      )
    ))
  )
))