diff --git a/global.R b/global.R new file mode 100644 index 0000000000000000000000000000000000000000..2af434e080bb491eefcde6d56ad75f760076d7f3 --- /dev/null +++ b/global.R @@ -0,0 +1,5 @@ +source("modules/hierclustfunction.R") +source("modules/interpolCompleteFunc.R") +source("modules/reacRollWinMODULE.R") +source("modules/reacHierClustMODULE.R") +source('modules/rolling_window_loop.R') diff --git a/hierclustfunction.R b/modules/hierclustfunction.R similarity index 100% rename from hierclustfunction.R rename to modules/hierclustfunction.R diff --git a/interpolCompleteFunc.R b/modules/interpolCompleteFunc.R similarity index 100% rename from interpolCompleteFunc.R rename to modules/interpolCompleteFunc.R diff --git a/reacHierClustMODULE.R b/modules/reacHierClustMODULE.R similarity index 100% rename from reacHierClustMODULE.R rename to modules/reacHierClustMODULE.R diff --git a/reacRollWinMODULE.R b/modules/reacRollWinMODULE.R similarity index 100% rename from reacRollWinMODULE.R rename to modules/reacRollWinMODULE.R diff --git a/rolling_window_loop.R b/modules/rolling_window_loop.R similarity index 100% rename from rolling_window_loop.R rename to modules/rolling_window_loop.R diff --git a/reacNewApproach.R b/server.R similarity index 67% rename from reacNewApproach.R rename to server.R index 9cffad6d40bc0c370d75b359761ac19a3f986c70..a3fab9a7430d5fa5a0e43d214797f1bd068d979b 100644 --- a/reacNewApproach.R +++ b/server.R @@ -3,13 +3,12 @@ #' Author: Mauro Gwerder #' #' In this main file, the input data is processed for feeding it into the modules. -#' UI & Server are combined in this file #' #' package requirements: library(shiny) library(shinydashboard) -library(shinyjs) # http://deanattali.com/shinyjs/ +#library(shinyjs) # http://deanattali.com/shinyjs/ library(ggplot2) library(data.table) library(gplots) # for heatmap.2 @@ -20,68 +19,6 @@ library(imputeTS) # for interpolating NAs options(shiny.maxRequestSize = 400 * 1024 ^ 2) -source("hierclustfunction.R") -source("interpolCompleteFunc.R") -source("reacRollWinMODULE.R") -source("reacHierClustMODULE.R") -source('rolling_window_loop.R') - -ui <- dashboardPage( # starts shiny in dashboard - - dashboardHeader( - - # Application title - title ="Outlier Detection" - - ), - dashboardSidebar( - - # dashboard-equivalent to "tabs" in normal shiny - sidebarMenu( - - # Every item stands for one tab. "Rolling Window" and "hierarchical clustering" will show outputs of the - # correspondent modules, whereas "Generate synthetic Data" & "Load Data" represent dropdown-menus that load - # or generate datasets. - menuItem("Rolling Window", tabName = "rollwindow", icon = icon("windows")), - - menuItem("hierarchical clustering", tabName = "hiercluster", icon = icon("tree")), - - menuItem("Generate synthetic Data", tabName = "synDataOpt", icon = icon("random"), # tab for synthetic Data options - sliderInput("slider.syn", "amount of outliers", 0, 30, 1), - checkboxInput("check.super", "add innovative outliers"), - actionButton("b.syndata", "generate synthetic data"), - br()), - - menuItem("Load Data", tabName = " ownDataOpt", icon = icon("file"), - fileInput("file.name", "file name:", - accept = c('text/csv', 'text/comma-separated-values,text/plain') - ), - # extracted columns from the loaded dataset will be displayed for selection - uiOutput("uiOut.ID"), - uiOutput("uiOut.time"), - uiOutput("uiOut.meas"), - uiOutput("uiOut.FOV"), - actionButton("b.loaddata", "load File"), - br()) - ) - ), - dashboardBody( - - # Includes the usage of ShinyJS - not used in the app for now - useShinyjs(), - tabItems( - - # references to the modules "RollWin" & "HierCluster" - tabItem(tabName = "rollwindow", - RollWinInput("RollWin") - ), - tabItem(tabName = "hiercluster", - HierClusterInput("HierCluster") - ) - ) - ) -) - server <- function(input, output) { # clustering and generation of heatmap @@ -190,7 +127,7 @@ server <- function(input, output) { return(dm.out) }) - + # generates synthetic dataset. # Function "LOCgenTraj" taken from Maciej Dobrzynski from his application "Timecourse inspector" synData <- eventReactive(input$b.syndata, { @@ -213,7 +150,7 @@ server <- function(input, output) { # To enable this, button clicks will be registered so that only the last click decides on # which source is piloted. dataInBoth <- reactive({ - + InLoadData <- input$b.loaddata InSynData <- input$b.syndata @@ -229,10 +166,10 @@ server <- function(input, output) { # isolate the checks of counter reactiveValues # as we set the values in this same reactive - if (InLoadData != isolate(counter$loadData)) { + if (InLoadData != isolate(counter$loadData)) { cat("dataInBoth if InLoadData\n") - dm = loadColData() - + dm = loadColData() + counter$loadData <- InLoadData } else if (InSynData != isolate(counter$synData)) { @@ -250,5 +187,3 @@ server <- function(input, output) { } - shinyApp(ui, server) - diff --git a/ui.R b/ui.R new file mode 100644 index 0000000000000000000000000000000000000000..d1b264c328c78e23e481e8be92a6eacf8c34b1fe --- /dev/null +++ b/ui.R @@ -0,0 +1,58 @@ +library(shinydashboard) +#library(shinyjs) # http://deanattali.com/shinyjs/ + +ui <- dashboardPage( # starts shiny in dashboard + + dashboardHeader( + + # Application title + title ="Outlier Detection" + + ), + dashboardSidebar( + + # dashboard-equivalent to "tabs" in normal shiny + sidebarMenu( + + # Every item stands for one tab. "Rolling Window" and "hierarchical clustering" will show outputs of the + # correspondent modules, whereas "Generate synthetic Data" & "Load Data" represent dropdown-menus that load + # or generate datasets. + menuItem("Rolling Window", tabName = "rollwindow", icon = icon("windows")), + + menuItem("hierarchical clustering", tabName = "hiercluster", icon = icon("tree")), + + menuItem("Generate synthetic Data", tabName = "synDataOpt", icon = icon("random"), # tab for synthetic Data options + sliderInput("slider.syn", "amount of outliers", 0, 30, 1), + checkboxInput("check.super", "add innovative outliers"), + actionButton("b.syndata", "generate synthetic data"), + br()), + + menuItem("Load Data", tabName = " ownDataOpt", icon = icon("file"), + fileInput("file.name", "file name:", + accept = c('text/csv', 'text/comma-separated-values,text/plain') + ), + # extracted columns from the loaded dataset will be displayed for selection + uiOutput("uiOut.ID"), + uiOutput("uiOut.time"), + uiOutput("uiOut.meas"), + uiOutput("uiOut.FOV"), + actionButton("b.loaddata", "load File"), + br()) + ) + ), + dashboardBody( + + # Includes the usage of ShinyJS - not used in the app for now + #useShinyjs(), + tabItems( + + # references to the modules "RollWin" & "HierCluster" + tabItem(tabName = "rollwindow", + RollWinInput("RollWin") + ), + tabItem(tabName = "hiercluster", + HierClusterInput("HierCluster") + ) + ) + ) +)