diff --git a/drug-target/server.R b/drug-target/server.R index ffc57b3..684c708 100644 --- a/drug-target/server.R +++ b/drug-target/server.R @@ -124,9 +124,18 @@ function(input, output, session) { # different data ranges required for SNP distances - snp_ligand_dist_df3 = merged_df3[merged_df3$ligand_distance% withSpinner(color="#0dc5c1"), - height=800 - ) - ), width=6 - ), - column(conditionalPanel( - condition="input.sidebar.match(/^Lineage.*/)", box( - title="Lineage SNP Diversity" - , status = "info" - , width=NULL - , plotOutput("lin_sc", height="700px") %>% withSpinner(color="#0dc5c1"), - height=800 - ) - ), width=6 - ) - - ), - # Explicit fluidRow() for Site SNP Count - fluidRow( - column(conditionalPanel( - condition="input.sidebar == 'Site SNP count'", - box( - title="Site SNP count" - , status = "info" - , width=NULL - , plotOutput("site_snp_count_bp") %>% withSpinner(color="#0dc5c1") - ) - ), width=6 - ), - column(conditionalPanel( - condition="input.sidebar == 'Site SNP count'", - box( - title="Ligand Distance" - , status = "info" - , width=NULL - , plotOutput("site_snp_count_bp_ligand") %>% withSpinner(color="#0dc5c1") - ) - ), width=6 - ), - column(conditionalPanel( - condition="input.sidebar == 'Site SNP count'", - box( - title="Interface Distance" - , status = "info" - , width=NULL - , plotOutput("site_snp_count_interface") %>% withSpinner(color="#0dc5c1") - ) - ), width=6 - ), - column(conditionalPanel( - condition="input.sidebar == 'Site SNP count'", - box( - title="NCA Distance" - , status = "info" - , width=NULL - , plotOutput("site_snp_count_nca") %>% withSpinner(color="#0dc5c1") - ) - ), width=6 - ) - ), - - # # Explicit fluidRow() for Stability Count - # fluidRow( - # column( - # conditionalPanel( - # condition="input.sidebar.match(/^Lineage.*/)", - # lapply( - # # FIXME: using a hardcoded target DF for this IS WRONG AND WILL BREAK - # stability_boxes_df[stability_boxes_df$outcome_colname %in% colnames(embb_merged_df3),"outcome_colname"], - # function(x){ - # print(paste0("outcome_colname: ",x)) - # box(plotOutput(x), width=4) - # } - # ), - # width=12 - # ) - # ) - # ), - - #### fluidRow()s for "Stability Count" in the sidebar #### - fluidRow( - conditionalPanel( - condition=" + ), + conditionalPanel( + condition="input.sidebar == 'Correlation'", + selectInput( + "corr_method", + label="Correlation Method", + choices = list("spearman", + "pearson", + "kendall"), + selected="spearman" + ) + ), + conditionalPanel( + condition="input.sidebar == 'Correlation'", + numericInput( + "corr_lig_dist" + , "Ligand Distance Cutoff (Å)", value=1 + ) + ), + conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + numericInput( + "snp_ligand_dist" + , "Ligand Distance Cutoff (Å)", value=10 + ) + ), + conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + numericInput( + "snp_interface_dist" + , "Interface Distance Cutoff (Å)", value=10 + ) + ), + conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + numericInput( + "snp_nca_dist" + , "NCA Distance Cutoff (Å)", value=10 + ) + ), + + conditionalPanel( + condition="input.sidebar == 'Correlation'", + checkboxGroupInput( + "corr_selected", + "Parameters", + choiceNames = c( + "DeepDDG", + "Dynamut2", + "FoldX", + "ConSurf"#, + ), + choiceValues = c( + "DeepDDG", + "Dynamut2", + "FoldX", + "ConSurf"#, + ), + selected = c( + "DeepDDG", + "Dynamut2", + "FoldX", + "ConSurf"#, + ) + ) + ), + + # conditionalPanel( + # condition="input.sidebar == 'DM OM Plots'", + # selectInput( + # "dm_om_param", + # label="Stability Parameter", + # choices = keys(dm_om_map), + # selected="SNAP2") + # ), + # colour_categ + conditionalPanel( + condition="input.sidebar == 'Stability SNP by site'", + selectInput( + "stability_snp_param", + label="Stability Parameter", + choices = stability_boxes_df$stability_type, + selected="Average") + ), + conditionalPanel( + condition="input.sidebar == 'Stability SNP by site'", + checkboxInput("reorder_custom_h", + label="Reorder by SNP count", + FALSE) + ), + conditionalPanel( + condition="input.sidebar.match(/^Lineage.*/)", + checkboxInput("all_lineages", + label="All Lineages", + FALSE) + ), + # an example of how you can match multiple things in frontend JS + conditionalPanel( + condition="input.sidebar == 'LogoP SNP' || + input.sidebar =='Stability SNP by site' || + input.sidebar =='Consurf' || + input.sidebar =='LogoP OR'", + actionButton("clear_ngl", + "Clear Structure") + ), + conditionalPanel( + condition="input.sidebar == 'LogoP SNP' || + input.sidebar =='Stability SNP by site' || + input.sidebar =='Consurf' || + input.sidebar =='LogoP OR'", + actionButton("test_ngl", + "Test NGLViewR") + )#, + + # downloadButton("save", + # "Download Plot" + # ) + # actionButton( + # "reload_target", + # label="Reload Target\nData (slow!)" + # ) + + ) + ), + #### body #### + body <- dashboardBody( + + tabItems( + tabItem(tabName = "dashboard", + h2("Dashboard tab content") + ), + + tabItem(tabName = "widgets", + h2("Widgets tab content") + ) + ), + # creates a 'Conditional Panel' containing a plot object from each of our + # ggplot plot functions (and its associated data frame) + fluidRow(column(width=12, + lapply(plot_functions_df$tab_name, + function(x){ + + plot_function=plot_functions_df[ + plot_functions_df$tab_name==x, + "plot_function"] + + plot_df=plot_functions_df[ + plot_functions_df$tab_name==x, + "plot_df"] + cat(paste0('\nCreating output: ', x)) + generate_conditionalPanel(x, plot_function, plot_df) + + } + ) + ) + ), + # Explicit fluidRow() for Lineage plots together + fluidRow( + column(conditionalPanel( + condition="input.sidebar.match(/^Lineage.*/)", box( + title="Lineage Distribution" + , status = "info" + , width=NULL + , plotOutput("lineage_distP", height="700px") %>% withSpinner(color="#0dc5c1"), + height=800 + ) + ), width=6 + ), + column(conditionalPanel( + condition="input.sidebar.match(/^Lineage.*/)", box( + title="Lineage SNP Diversity" + , status = "info" + , width=NULL + , plotOutput("lin_sc", height="700px") %>% withSpinner(color="#0dc5c1"), + height=800 + ) + ), width=6 + ) + + ), + # Explicit fluidRow() for Site SNP Count + fluidRow( + column(conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + box( + title="Site SNP count" + , status = "info" + , width=NULL + , plotOutput("site_snp_count_bp") %>% withSpinner(color="#0dc5c1") + ) + ), width=6 + ), + column(conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + box( + title="Ligand Distance" + , status = "info" + , width=NULL + , plotOutput("site_snp_count_bp_ligand") %>% withSpinner(color="#0dc5c1") + ) + ), width=6 + ), + column(conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + box( + title="Interface Distance" + , status = "info" + , width=NULL + , plotOutput("site_snp_count_interface") %>% withSpinner(color="#0dc5c1") + ) + ), width=6 + ), + column(conditionalPanel( + condition="input.sidebar == 'Site SNP count'", + box( + title="RNA Distance" + , status = "info" + , width=NULL + , plotOutput("site_snp_count_nca") %>% withSpinner(color="#0dc5c1") + ) + ), width=6 + ) + ), + + # # Explicit fluidRow() for Stability Count + # fluidRow( + # column( + # conditionalPanel( + # condition="input.sidebar.match(/^Lineage.*/)", + # lapply( + # # FIXME: using a hardcoded target DF for this IS WRONG AND WILL BREAK + # stability_boxes_df[stability_boxes_df$outcome_colname %in% colnames(embb_merged_df3),"outcome_colname"], + # function(x){ + # print(paste0("outcome_colname: ",x)) + # box(plotOutput(x), width=4) + # } + # ), + # width=12 + # ) + # ) + # ), + + #### fluidRow()s for "Stability Count" in the sidebar #### + fluidRow( + conditionalPanel( + condition=" input.sidebar == 'LogoP SNP' || input.sidebar =='Stability SNP by site' || input.sidebar =='Consurf' || input.sidebar =='LogoP OR'", - column(NGLVieweROutput("structure"), - width=3 - ) - ), - conditionalPanel( - condition=" + column(NGLVieweROutput("structure"), + width=3 + ) + ), + conditionalPanel( + condition=" input.sidebar == 'LogoP SNP' || input.sidebar == 'Stability SNP by site' || input.sidebar == 'Site SNP count' || input.sidebar == 'Consurf' || input.sidebar == 'LogoP OR'", - column( - DT::dataTableOutput('table'), - width=9 - ) - ) - ), - ) + column( + DT::dataTableOutput('table'), + width=9 + ) + ) + ), + ) ) \ No newline at end of file