From 0379c91d8b619531ac3009c88e1ca0f1a33ad362 Mon Sep 17 00:00:00 2001 From: Markus List Date: Thu, 9 Nov 2017 15:05:58 +0100 Subject: [PATCH] fixed problem --- .gitignore | 6 +++++ app/server.r | 65 ++++++++++++++++++++++++---------------------------- app/ui.r | 30 ++++++++++++------------ 3 files changed, 51 insertions(+), 50 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d190d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +*.Rproj +*.cache diff --git a/app/server.r b/app/server.r index 6e70e7b..fe56cc1 100644 --- a/app/server.r +++ b/app/server.r @@ -1,8 +1,8 @@ function(input, output) { - + #keeping track of he inserted UIs inserted <- c() - + #Adding the UI after choosing the UserID and clicking on the button observeEvent(input$start_btn, { id <- input$start_btn @@ -18,39 +18,38 @@ function(input, output) { else{ user <- input$user_key showNotification(deepblue_echo(user_key = input$user_key), type = "message", duration = 10) - } - + } + #progress bar for loading the UI withProgress(message = "Getting Projects, Epigenetics Marks, Chromosomes and Tests",min = 0, max = 2, value = 0, { - + incProgress(amount = 1, message = "building input interface") - + insertUI(selector = '#addOptions', where = "afterBegin", #We wrap the element in a div with id to remove it when the restart buttong pressed ui = tags$div( - + id = id, selectInput('genome', "Select Genome", c(deepblue_list_genomes(user_key = user)$name,"NULL"), selected = "NULL"), - + selectInput('project', 'Select Project', c(deepblue_list_projects(user_key = user)$name, "NULL"), selected = "NULL"), - + selectInput('epigenetic_mark', 'Select an Epigenetic Mark', c(deepblue_list_epigenetic_marks(user_key = user)$name, "NULL"), multiple = TRUE, selected = "NULL"), - + actionButton('list_exper_btn', "List Experiments"), - - + radioButtons("type_of_score", "Choose method to calculate scoring matrix",choices= c("Annotations" = "annotation", "Tiling Regions" = "tiling")), - - + + conditionalPanel( condition = "input.type_of_score == 'tiling'", radioButtons("tiling_size", "Select Tiling Region Size", choices = @@ -60,16 +59,16 @@ function(input, output) { ) inserted <<- c(id, inserted) incProgress(amount = 1, message = "done") - + }) }) - + #Adding a small UI for choosing the chromosome according the genome chosen observeEvent(input$genome, { if(input$genome != "NULL"){ # chromsome <- input$genome genomes <- deepblue_list_genomes(user_key = input$user_key) - + insertUI(selector = '#addChromosomes', where = "afterEnd", ui = tags$div( @@ -82,8 +81,8 @@ function(input, output) { ) } }) - - + + #To remove the inserted UI and start again observeEvent(input$end_btn, { removeUI( @@ -95,37 +94,33 @@ function(input, output) { selector = '#add_chr', multiple = TRUE ) }) - - + + #List experiments and info for experiments in a list all_experiments <- eventReactive(input$list_exper_btn, { #getting experments - browser() all_experiments <- list_experiments(genome = input$genome, epigenetic_mark = input$epigenetic_mark, project = input$project, user_key = input$user_key) }) - - eventReactive(input$list_exper_btn, { - output$table <- renderTable(all_experiments()) - - }) - + + output$table <- renderTable(all_experiments()[[1]]) + + #make a table of metadata experiments_info_meta <- eventReactive(input$plot_btn, { - browser() #extract metadata experiments_info_meta <- extract_metadata(all_experiments()[[2]]) - + }) - + #Get the score matrix filtered_score_matrix <- eventReactive(input$plot_btn, { #get scoring matrix score_matrix_tiling_regions(experiments = all_experiments()[[1]], experiments_info_meta = experiments_info_meta(), - genome = input$genome, chr = input$chr, user_key = input$user_key) + genome = input$genome, chr = input$chr, user_key = input$user_key) }) - + #plot data plot_pca <- eventReactive(input$plot_btn, { #get plot @@ -134,7 +129,7 @@ function(input, output) { filtered_score_matrix = filtered_score_matrix(), epigenetic_mark = input$epigenetic_mark) }) - + output$plot <- renderPlotly(plot_pca()) - + } diff --git a/app/ui.r b/app/ui.r index d18025b..334aa73 100644 --- a/app/ui.r +++ b/app/ui.r @@ -12,36 +12,36 @@ library(stats) library(plotly) library(shiny) -source("/home/fawaz/Desktop/Max_Planck_Job/shiny_apps/shinyApp/functions/extract_metadata.r") -source("/home/fawaz/Desktop/Max_Planck_Job/shiny_apps/shinyApp/functions/list_experiments.r") -source("/home/fawaz/Desktop/Max_Planck_Job/shiny_apps/shinyApp/functions/score_matrix_tiling_regions.r") -source("/home/fawaz/Desktop/Max_Planck_Job/shiny_apps/shinyApp/functions/plot_pca_labels.r") -source("/home/fawaz/Desktop/Max_Planck_Job/shiny_apps/shinyApp/functions/plot_correlation.r") +source("../functions/extract_metadata.r") +source("../functions/list_experiments.r") +source("../functions/score_matrix_tiling_regions.r") +source("../functions/plot_pca_labels.r") +source("../functions/plot_correlation.r") #JvkPLwsTHbb3Fyi4 fluidPage( - + sidebarPanel( - + textInput("user_key", "User Key", value = "anonymous_key"), - + actionButton('start_btn', "Log-in with your ID and start"), actionButton('end_btn', 'Start Again'), - + tags$div(id = 'addOptions'), tags$div(id = 'addChromosomes'), - - actionButton("plot_btn", "Caclulate and Plot") - + + actionButton("plot_btn", "Calculate and Plot") + ), - + mainPanel( tabsetPanel(type = "tabs", tabPanel("Table", tableOutput("table")), tabPanel("Summary", tableOutput("summary")), tabPanel("Plot", plotlyOutput('plot', width = "100%", height = "600px")) - + ) ) -) \ No newline at end of file +)