msa dashboard
This commit is contained in:
parent
88aaf56729
commit
3037d6e3ef
6 changed files with 643 additions and 0 deletions
|
@ -316,3 +316,344 @@ consurf_colours = c(
|
|||
, "9" = rgb(0.63,0.16,0.37)
|
||||
)
|
||||
|
||||
if (interactive()){
|
||||
options(shiny.launch.browser = FALSE) # i am a big girl and can tie my own laces
|
||||
options(shiny.port = 8000) # don't change the port every time
|
||||
options(shiny.host = '0.0.0.0') # This means "listen to all addresses on all interfaces"
|
||||
options(width=120)
|
||||
options(DT.options = list(scrollX = TRUE))
|
||||
|
||||
ui=dashboardPage(skin="purple",
|
||||
dashboardHeader(title = "Drug/Target Explorer"),
|
||||
|
||||
dashboardSidebar(
|
||||
sidebarMenu( id = "sidebar",
|
||||
selectInput(
|
||||
"switch_target",
|
||||
label="Switch to New Target",
|
||||
choices = c(
|
||||
"alr",
|
||||
"embb",
|
||||
"gid",
|
||||
"katg",
|
||||
"pnca",
|
||||
"rpob"
|
||||
),
|
||||
selected="embb"),
|
||||
menuItem("LogoP SNP", tabName="LogoP SNP"),
|
||||
menuItem("Lineage Sample Count", tabName="Lineage Sample Count"),
|
||||
menuItem("Site SNP count", tabName="Site SNP count"),
|
||||
menuItem("Stability SNP by site", tabName="Stability SNP by site"),
|
||||
menuItem("DM OM Plots", tabName="DM OM Plots"),
|
||||
menuItem("Correlation", tabName="Correlation"),
|
||||
menuItem("Lineage Distribution", tabName="Lineage Distribution"),
|
||||
menuItem("Consurf", tabName="Consurf"),
|
||||
menuItem("LogoP OR", tabName="LogoP OR"),
|
||||
menuItem("LogoP ED", tabName="LogoP ED"),
|
||||
menuItem('Stability count', tabName='Stability count'),
|
||||
|
||||
# These conditionalPanel()s make extra settings appear in the sidebar when needed
|
||||
conditionalPanel(
|
||||
condition="input.sidebar == 'LogoP SNP'",
|
||||
textInput(
|
||||
"omit_snp_count",
|
||||
"Omit SNPs",
|
||||
value = c(0),
|
||||
placeholder = "1,3,6"
|
||||
)
|
||||
),
|
||||
# NOTE:
|
||||
# I *think* we can cheat here slightly and use the min/max from
|
||||
# merged_df3[['position']] for everything because the various
|
||||
# dataframes for a given gene/drug combination have the
|
||||
# same range of positions. May need fixing, especially
|
||||
# if we get/shrink the imported data files to something
|
||||
# more reasonable.
|
||||
conditionalPanel(
|
||||
condition="
|
||||
input.sidebar == 'LogoP SNP'||
|
||||
input.sidebar == 'Stability SNP by site' ||
|
||||
input.sidebar == 'Consurf' ||
|
||||
input.sidebar == 'LogoP OR' ||
|
||||
input.sidebar == 'Site SNP count'",
|
||||
sliderInput(
|
||||
"display_position_range"
|
||||
, "Display Positions"
|
||||
, min=1, max=150, value=c(1,150) # 150 is just a little less than the smallest pos_count
|
||||
)
|
||||
),
|
||||
conditionalPanel(
|
||||
condition="input.sidebar == 'LogoP ED'",
|
||||
sliderInput(
|
||||
"display_position_full_range"
|
||||
, "Display Positions"
|
||||
, min=1, max=150, value=c(1,150)
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
conditionalPanel(
|
||||
condition="
|
||||
input.sidebar == 'LogoP SNP' ||
|
||||
input.sidebar == 'LogoP OR' ||
|
||||
input.sidebar == 'LogoP ED'",
|
||||
selectInput(
|
||||
"logoplot_colour_scheme",
|
||||
label="Logo Plot Colour Scheme",
|
||||
choices = logoPlotSchemes,
|
||||
selected="chemistry"
|
||||
)
|
||||
),
|
||||
#conditionalPanel(
|
||||
# condition="input.sidebar == 'LogoP SNP' || input.sidebar == 'LogoP ED'|| input.sidebar == 'Consurf'",
|
||||
# numericInput(
|
||||
# "table_position"
|
||||
# , "Table Position", value=1
|
||||
# )
|
||||
#),
|
||||
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 == 'Correlation'",
|
||||
checkboxGroupInput(
|
||||
"corr_selected",
|
||||
"Parameters",
|
||||
choiceNames = c(
|
||||
"DeepDDG",
|
||||
"Dynamut2",
|
||||
"FoldX",
|
||||
"ConSurf"#,
|
||||
#"dst_mode"
|
||||
),
|
||||
choiceValues = c(
|
||||
"DeepDDG",
|
||||
"Dynamut2",
|
||||
"FoldX",
|
||||
"ConSurf"#,
|
||||
#"dst_mode"
|
||||
),
|
||||
selected = c(
|
||||
"DeepDDG",
|
||||
"Dynamut2",
|
||||
"FoldX",
|
||||
"ConSurf"#,
|
||||
#"dst_mode"
|
||||
)
|
||||
)
|
||||
),
|
||||
|
||||
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' ||
|
||||
input.sidebar =='LogoP ED'",
|
||||
actionButton("clear_ngl",
|
||||
"Clear Structure")
|
||||
),
|
||||
conditionalPanel(
|
||||
condition="input.sidebar == 'LogoP SNP' ||
|
||||
input.sidebar =='Stability SNP by site' ||
|
||||
input.sidebar =='Consurf' ||
|
||||
input.sidebar =='LogoP OR' ||
|
||||
input.sidebar =='LogoP ED'",
|
||||
actionButton("test_ngl",
|
||||
"Test NGLViewR")
|
||||
)#,
|
||||
|
||||
# downloadButton("save",
|
||||
# "Download Plot"
|
||||
# )
|
||||
# actionButton(
|
||||
# "reload_target",
|
||||
# label="Reload Target\nData (slow!)"
|
||||
# )
|
||||
|
||||
)
|
||||
),
|
||||
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)
|
||||
|
||||
}
|
||||
)
|
||||
)
|
||||
),
|
||||
#### 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' ||
|
||||
input.sidebar =='LogoP ED'",
|
||||
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' ||
|
||||
input.sidebar == 'LogoP ED'",
|
||||
column(
|
||||
DT::dataTableOutput('table'),
|
||||
width=9
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
server = 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")
|
||||
hide("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
|
||||
})
|
||||
}
|
||||
app <- shinyApp(ui, server)
|
||||
runApp(app)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue