diff --git a/ml/global.R b/ml/global.R index 7464fdf..4c4d468 100644 --- a/ml/global.R +++ b/ml/global.R @@ -189,3 +189,143 @@ makeplot = function(x, # the DataFrame to plot # ggplotly() } +if (interactive()){ + server=shinyServer(function(input, output) { + observeEvent({ + input$combined_model + input$combined_data + input$combined_training_genes + input$score_dropdown + input$resample_dropdown + input$drug_dropdown + input$split_dropdown + + },{ + combined_model = input$combined_model + selection = input$score_dropdown + resampler = input$resample_dropdown + selected_drug = input$drug_dropdown + selected_split = input$split_dropdown + combined_data = input$combined_data + combined_training_genes = input$combined_training_genes + + selected_gene = combo[combo$drug == selected_drug,'gene'] + + # hide stuff if selected + if(combined_model == "combined") { + #if(combined_model == TRUE) { + + hide("split_dropdown") + #show("resample_dropdown") + show("combined_data") + show("combined_training_genes") + filedata = paste0(combined_training_genes, + 'genes_logo_skf_BT_', + selected_gene, + '_', + combined_data + ) + print(filedata) + + print('doing COMBINED plot') + output$plot <- renderPlot(makeplot(loaded_files[[filedata]], + selection, + "none", # always 'none' for combined plot + gene = combo[drug==selected_drug,"gene"], + combined_training_genes = combined_training_genes, + display_combined = TRUE, + ) + ) + # e.g. + # makeplot(loaded_files$`5genes_logo_skf_BT_pnca_actual`, "MCC", "none" , gene = 'foo', combined_training_genes = '1234', display_combined = TRUE) + } else { + show("split_dropdown") + #show("resample_dropdown") + hide("combined_data") + hide("combined_training_genes") + filedata = paste0(combo[drug==selected_drug,"gene"], + '_baselineC_', + selected_split + ) + print(filedata) + print("doing GENE plot") + output$plot <- renderPlot(makeplot(loaded_files[[filedata]], + selection, + resampler, + gene = combo[drug==selected_drug,"gene"], + display_combined = FALSE, + ) + ) + + + } + # 6genes_logo_skf_BT_gid_complete + + # filedata example for combined: 6genes_logo_skf_BT_embb_actual + # 6genes_logo_skf_BT_embb_combined + }) + } + ) + + ui=dashboardPage(skin="purple", + dashboardHeader(title="Score Selector"), + dashboardSidebar( + radioButtons("combined_model", + label="Graph Model", + choiceNames = c("Combined", "Gene"), + choiceValues = c("combined", "gene"), + selected="gene" + ), + + # checkboxInput("combined_model", + # "Combined Model", + # value=FALSE + # ), + #), + + radioButtons("combined_data", + label="Data Type", + choiceNames = c("Complete", "Actual", "Feature Selection"), + choiceValues = c("complete", "actual", "FS"), + selected="complete" + ), + radioButtons("combined_training_genes", + label="Training Genes", + choiceNames = c("One", "Two", "Five", "Six"), + choiceValues = c("1", "2", "5","6"), + selected = "5" + ), + radioButtons("drug_dropdown", + label="Drug", + choices = drug, + selected="pyrazinamide" + ), + radioButtons("split_dropdown", + label="Split", + choices = split_type, + selected="cd_7030" + ), + radioButtons("score_dropdown", + label="Score", + choices = scores, + selected="MCC" + ), + radioButtons("resample_dropdown", + label="Resampling", + choices = resample_types, + selected="none" # "none" is a value + ) + ), + dashboardBody( + useShinyjs(), + #plotlyOutput("plot", height = 800), + plotOutput("plot", height = 800), + # %>% withSpinner(color="#0dc5c1"), # uncomment if you want the spinner + #downloadButton("save", "Download Plot"), + #DT::dataTableOut("plotdata"), + verbatimTextOutput("debug") + ) + ) + app <- shinyApp(ui, server) + runApp(app) +} \ No newline at end of file diff --git a/ml/ui.R b/ml/ui.R index 30e2908..3796a9e 100644 --- a/ml/ui.R +++ b/ml/ui.R @@ -44,7 +44,7 @@ dashboardPage(skin="purple", radioButtons("split_dropdown", label="Split", choices = split_type, - selected="7030" + selected="cd_7030" ), radioButtons("score_dropdown", label="Score",