Dashboards/ml/server.R

131 lines
No EOL
4.3 KiB
R

library(shiny)
shinyServer(function(input, output, session) {
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']
# if (combined_data == "FS"){
# updateRadioButtons(
# inputId="combined_training_genes",
# choiceNames = c("One", "Two"),
# choiceValues = c("1", "2"),
# selected = "2"
# )
# } else{
# updateRadioButtons(
# inputId="combined_training_genes",
# choiceNames = c("Five", "Six"),
# choiceValues = c("5","6"),
# selected = "5"
# )
# }
# 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")
#show("feature_plot")
filedata = paste0(combined_training_genes,
'genes_logo_skf_BT_',
selected_gene,
'_',
"complete"
#combined_data
)
feature_data = paste0(as.character(as.numeric(combined_training_genes)-4), # lol
'genes_logo_skf_BT_',
selected_gene,
'_FS'
)
print(filedata)
print('doing COMBINED plot')
output$plot <- renderPlot(
makeplot(
loaded_files[[filedata]],
selection,
resampler,
gene = combo[drug==selected_drug,"gene"],
combined_training_genes = combined_training_genes,
display_combined = TRUE
),height=450
)
print("doing FEATURE SELECTION plot corresponding to COMBINED plot")
output$feature_plot <- renderPlot(
makeplot(
loaded_files[[feature_data]],
selection,
"none", # always 'none' for Feature Selection
gene = combo[drug==selected_drug,"gene"],
combined_training_genes = combined_training_genes,
display_combined = TRUE
),height=450
)
# 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")
#hide("feature_plot")
filedata = paste0(
combo[drug==selected_drug,"gene"],
'_baselineC_',
selected_split
)
feature_data = paste0(
combo[drug==selected_drug,"gene"],
'_baselineC_',
selected_split,
"_FS"
)
print(filedata)
print("doing GENE plot")
output$plot <- renderPlot(makeplot(loaded_files[[filedata]],
selection,
resampler,
gene = combo[drug==selected_drug,"gene"],
display_combined = FALSE
),height=450
)
print("doing FEATURE SELECTION plot corresponding to GENE plot")
output$feature_plot <- renderPlot(makeplot(loaded_files[[feature_data]],
selection,
"none",
gene = combo[drug==selected_drug,"gene"],
display_combined = FALSE
),height=450
)
}
# 6genes_logo_skf_BT_gid_complete
# filedata example for combined: 6genes_logo_skf_BT_embb_actual
# 6genes_logo_skf_BT_embb_combined
})
}
)