dashboard stuff

This commit is contained in:
Tanushree Tunstall 2022-09-26 15:58:14 +01:00
parent 84662ec948
commit f5d5923e42
3 changed files with 314 additions and 327 deletions

View file

@ -312,343 +312,343 @@ if (interactive()){
options(DT.options = list(scrollX = TRUE)) options(DT.options = list(scrollX = TRUE))
#### UI #### #### UI ####
ui <- dashboardPage(skin="purple", ui <- dashboardPage(skin="purple",
dashboardHeader(title = "Drug/Target Explorer"), dashboardHeader(title = "Drug/Target Explorer"),
dashboardSidebar( dashboardSidebar(
sidebarMenu( id = "sidebar", sidebarMenu( id = "sidebar",
selectInput( selectInput(
"switch_target", "switch_target",
label="Switch to New Target", label="Switch to New Target",
choices = c( choices = c(
"alr", "alr",
"embb", "embb",
"gid", "gid",
"katg", "katg",
"pnca", "pnca",
"rpob" "rpob"
), ),
selected="embb"), selected="embb"),
menuItem("LogoP SNP", tabName="LogoP SNP"), menuItem("LogoP SNP", tabName="LogoP SNP"),
#menuItem("Lineage Sample Count", tabName="Lineage Sample Count"), #menuItem("Lineage Sample Count", tabName="Lineage Sample Count"),
menuItem("Site SNP count", tabName="Site SNP count"), menuItem("Site SNP count", tabName="Site SNP count"),
menuItem("Stability SNP by site", tabName="Stability SNP by site"), menuItem("Stability SNP by site", tabName="Stability SNP by site"),
menuItem("DM OM Plots", tabName="DM OM Plots"), menuItem("DM OM Plots", tabName="DM OM Plots"),
menuItem("Correlation", tabName="Correlation"), menuItem("Correlation", tabName="Correlation"),
#menuItem("Lineage Distribution", tabName="Lineage Distribution"), #menuItem("Lineage Distribution", tabName="Lineage Distribution"),
menuItem("Consurf", tabName="Consurf"), menuItem("Consurf", tabName="Consurf"),
menuItem("LogoP OR", tabName="LogoP OR"), menuItem("LogoP OR", tabName="LogoP OR"),
menuItem("Lineage", tabName="Lineage"), menuItem("Lineage", tabName="Lineage"),
#menuItem('Stability count', tabName='Stability count'), #menuItem('Stability count', tabName='Stability count'),
# These conditionalPanel()s make extra settings appear in the sidebar when needed # These conditionalPanel()s make extra settings appear in the sidebar when needed
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'LogoP SNP'", condition="input.sidebar == 'LogoP SNP'",
textInput( textInput(
"omit_snp_count", "omit_snp_count",
"Omit SNPs", "Omit SNPs",
value = c(0), value = c(0),
placeholder = "1,3,6" placeholder = "1,3,6"
) )
), ),
# NOTE: # NOTE:
# I *think* we can cheat here slightly and use the min/max from # I *think* we can cheat here slightly and use the min/max from
# merged_df3[['position']] for everything because the various # merged_df3[['position']] for everything because the various
# dataframes for a given gene/drug combination have the # dataframes for a given gene/drug combination have the
# same range of positions. May need fixing, especially # same range of positions. May need fixing, especially
# if we get/shrink the imported data files to something # if we get/shrink the imported data files to something
# more reasonable. # more reasonable.
conditionalPanel( conditionalPanel(
condition=" condition="
input.sidebar == 'LogoP SNP'|| input.sidebar == 'LogoP SNP'||
input.sidebar == 'Stability SNP by site' || input.sidebar == 'Stability SNP by site' ||
input.sidebar == 'Consurf' || input.sidebar == 'Consurf' ||
input.sidebar == 'LogoP OR'", input.sidebar == 'LogoP OR'",
sliderInput( sliderInput(
"display_position_range" "display_position_range"
, "Display Positions" , "Display Positions"
, min=1, max=150, value=c(1,150) # 150 is just a little less than the smallest pos_count , min=1, max=150, value=c(1,150) # 150 is just a little less than the smallest pos_count
) )
), ),
conditionalPanel( conditionalPanel(
condition=" condition="
input.sidebar == 'LogoP SNP' || input.sidebar == 'LogoP SNP' ||
input.sidebar == 'LogoP OR' || input.sidebar == 'LogoP OR' ||
input.sidebar == 'LogoP ED'", input.sidebar == 'LogoP ED'",
selectInput( selectInput(
"logoplot_colour_scheme", "logoplot_colour_scheme",
label="Logo Plot Colour Scheme", label="Logo Plot Colour Scheme",
choices = logoPlotSchemes, choices = logoPlotSchemes,
selected="chemistry" selected="chemistry"
) )
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Correlation'", condition="input.sidebar == 'Correlation'",
selectInput( selectInput(
"corr_method", "corr_method",
label="Correlation Method", label="Correlation Method",
choices = list("spearman", choices = list("spearman",
"pearson", "pearson",
"kendall"), "kendall"),
selected="spearman" selected="spearman"
) )
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Correlation'", condition="input.sidebar == 'Correlation'",
numericInput( numericInput(
"corr_lig_dist" "corr_lig_dist"
, "Ligand Distance Cutoff (Å)", value=1 , "Ligand Distance Cutoff (Å)", value=1
) )
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
numericInput( numericInput(
"snp_ligand_dist" "snp_ligand_dist"
, "Ligand Distance Cutoff (Å)", value=10 , "Ligand Distance Cutoff (Å)", value=10
) )
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
numericInput( numericInput(
"snp_interface_dist" "snp_interface_dist"
, "Interface Distance Cutoff (Å)", value=10 , "Interface Distance Cutoff (Å)", value=10
) )
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
numericInput( numericInput(
"snp_nca_dist" "snp_nca_dist"
, "NCA Distance Cutoff (Å)", value=10 , "NCA Distance Cutoff (Å)", value=10
) )
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Correlation'", condition="input.sidebar == 'Correlation'",
checkboxGroupInput( checkboxGroupInput(
"corr_selected", "corr_selected",
"Parameters", "Parameters",
choiceNames = c( choiceNames = c(
"DeepDDG", "DeepDDG",
"Dynamut2", "Dynamut2",
"FoldX", "FoldX",
"ConSurf"#, "ConSurf"#,
), ),
choiceValues = c( choiceValues = c(
"DeepDDG", "DeepDDG",
"Dynamut2", "Dynamut2",
"FoldX", "FoldX",
"ConSurf"#, "ConSurf"#,
), ),
selected = c( selected = c(
"DeepDDG", "DeepDDG",
"Dynamut2", "Dynamut2",
"FoldX", "FoldX",
"ConSurf"#, "ConSurf"#,
) )
) )
), ),
# conditionalPanel( # conditionalPanel(
# condition="input.sidebar == 'DM OM Plots'", # condition="input.sidebar == 'DM OM Plots'",
# selectInput( # selectInput(
# "dm_om_param", # "dm_om_param",
# label="Stability Parameter", # label="Stability Parameter",
# choices = keys(dm_om_map), # choices = keys(dm_om_map),
# selected="SNAP2") # selected="SNAP2")
# ), # ),
# colour_categ # colour_categ
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Stability SNP by site'", condition="input.sidebar == 'Stability SNP by site'",
selectInput( selectInput(
"stability_snp_param", "stability_snp_param",
label="Stability Parameter", label="Stability Parameter",
choices = stability_boxes_df$stability_type, choices = stability_boxes_df$stability_type,
selected="Average") selected="Average")
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'Stability SNP by site'", condition="input.sidebar == 'Stability SNP by site'",
checkboxInput("reorder_custom_h", checkboxInput("reorder_custom_h",
label="Reorder by SNP count", label="Reorder by SNP count",
FALSE) FALSE)
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar.match(/^Lineage.*/)", condition="input.sidebar.match(/^Lineage.*/)",
checkboxInput("all_lineages", checkboxInput("all_lineages",
label="All Lineages", label="All Lineages",
FALSE) FALSE)
), ),
# an example of how you can match multiple things in frontend JS # an example of how you can match multiple things in frontend JS
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'LogoP SNP' || condition="input.sidebar == 'LogoP SNP' ||
input.sidebar =='Stability SNP by site' || input.sidebar =='Stability SNP by site' ||
input.sidebar =='Consurf' || input.sidebar =='Consurf' ||
input.sidebar =='LogoP OR'", input.sidebar =='LogoP OR'",
actionButton("clear_ngl", actionButton("clear_ngl",
"Clear Structure") "Clear Structure")
), ),
conditionalPanel( conditionalPanel(
condition="input.sidebar == 'LogoP SNP' || condition="input.sidebar == 'LogoP SNP' ||
input.sidebar =='Stability SNP by site' || input.sidebar =='Stability SNP by site' ||
input.sidebar =='Consurf' || input.sidebar =='Consurf' ||
input.sidebar =='LogoP OR'", input.sidebar =='LogoP OR'",
actionButton("test_ngl", actionButton("test_ngl",
"Test NGLViewR") "Test NGLViewR")
)#, )#,
# downloadButton("save", # downloadButton("save",
# "Download Plot" # "Download Plot"
# ) # )
# actionButton( # actionButton(
# "reload_target", # "reload_target",
# label="Reload Target\nData (slow!)" # label="Reload Target\nData (slow!)"
# ) # )
) )
), ),
#### body #### #### body ####
body <- dashboardBody( body <- dashboardBody(
tabItems( tabItems(
tabItem(tabName = "dashboard", tabItem(tabName = "dashboard",
h2("Dashboard tab content") h2("Dashboard tab content")
), ),
tabItem(tabName = "widgets", tabItem(tabName = "widgets",
h2("Widgets tab content") h2("Widgets tab content")
) )
), ),
# creates a 'Conditional Panel' containing a plot object from each of our # creates a 'Conditional Panel' containing a plot object from each of our
# ggplot plot functions (and its associated data frame) # ggplot plot functions (and its associated data frame)
fluidRow(column(width=12, fluidRow(column(width=12,
lapply(plot_functions_df$tab_name, lapply(plot_functions_df$tab_name,
function(x){ function(x){
plot_function=plot_functions_df[ plot_function=plot_functions_df[
plot_functions_df$tab_name==x, plot_functions_df$tab_name==x,
"plot_function"] "plot_function"]
plot_df=plot_functions_df[ plot_df=plot_functions_df[
plot_functions_df$tab_name==x, plot_functions_df$tab_name==x,
"plot_df"] "plot_df"]
cat(paste0('\nCreating output: ', x)) cat(paste0('\nCreating output: ', x))
generate_conditionalPanel(x, plot_function, plot_df) generate_conditionalPanel(x, plot_function, plot_df)
} }
) )
) )
), ),
# Explicit fluidRow() for Lineage plots together # Explicit fluidRow() for Lineage plots together
fluidRow( fluidRow(
column(conditionalPanel( column(conditionalPanel(
condition="input.sidebar.match(/^Lineage.*/)", box( condition="input.sidebar.match(/^Lineage.*/)", box(
title="Lineage Distribution" title="Lineage Distribution"
, status = "info" , status = "info"
, width=NULL , width=NULL
, plotOutput("lineage_distP", height="700px") %>% withSpinner(color="#0dc5c1"), , plotOutput("lineage_distP", height="700px") %>% withSpinner(color="#0dc5c1"),
height=800 height=800
) )
), width=6 ), width=6
), ),
column(conditionalPanel( column(conditionalPanel(
condition="input.sidebar.match(/^Lineage.*/)", box( condition="input.sidebar.match(/^Lineage.*/)", box(
title="Lineage SNP Diversity" title="Lineage SNP Diversity"
, status = "info" , status = "info"
, width=NULL , width=NULL
, plotOutput("lin_sc", height="700px") %>% withSpinner(color="#0dc5c1"), , plotOutput("lin_sc", height="700px") %>% withSpinner(color="#0dc5c1"),
height=800 height=800
) )
), width=6 ), width=6
) )
), ),
# Explicit fluidRow() for Site SNP Count # Explicit fluidRow() for Site SNP Count
fluidRow( fluidRow(
column(conditionalPanel( column(conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
box( box(
title="Site SNP count" title="Site SNP count"
, status = "info" , status = "info"
, width=NULL , width=NULL
, plotOutput("site_snp_count_bp") %>% withSpinner(color="#0dc5c1") , plotOutput("site_snp_count_bp") %>% withSpinner(color="#0dc5c1")
) )
), width=6 ), width=6
), ),
column(conditionalPanel( column(conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
box( box(
title="Ligand Distance" title="Ligand Distance"
, status = "info" , status = "info"
, width=NULL , width=NULL
, plotOutput("site_snp_count_bp_ligand") %>% withSpinner(color="#0dc5c1") , plotOutput("site_snp_count_bp_ligand") %>% withSpinner(color="#0dc5c1")
) )
), width=6 ), width=6
), ),
column(conditionalPanel( column(conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
box( box(
title="Interface Distance" title="Interface Distance"
, status = "info" , status = "info"
, width=NULL , width=NULL
, plotOutput("site_snp_count_interface") %>% withSpinner(color="#0dc5c1") , plotOutput("site_snp_count_interface") %>% withSpinner(color="#0dc5c1")
) )
), width=6 ), width=6
), ),
column(conditionalPanel( column(conditionalPanel(
condition="input.sidebar == 'Site SNP count'", condition="input.sidebar == 'Site SNP count'",
box( box(
title="RNA Distance" title="RNA Distance"
, status = "info" , status = "info"
, width=NULL , width=NULL
, plotOutput("site_snp_count_nca") %>% withSpinner(color="#0dc5c1") , plotOutput("site_snp_count_nca") %>% withSpinner(color="#0dc5c1")
) )
), width=6 ), width=6
) )
), ),
# # Explicit fluidRow() for Stability Count # # Explicit fluidRow() for Stability Count
# fluidRow( # fluidRow(
# column( # column(
# conditionalPanel( # conditionalPanel(
# condition="input.sidebar.match(/^Lineage.*/)", # condition="input.sidebar.match(/^Lineage.*/)",
# lapply( # lapply(
# # FIXME: using a hardcoded target DF for this IS WRONG AND WILL BREAK # # 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"], # stability_boxes_df[stability_boxes_df$outcome_colname %in% colnames(embb_merged_df3),"outcome_colname"],
# function(x){ # function(x){
# print(paste0("outcome_colname: ",x)) # print(paste0("outcome_colname: ",x))
# box(plotOutput(x), width=4) # box(plotOutput(x), width=4)
# } # }
# ), # ),
# width=12 # width=12
# ) # )
# ) # )
# ), # ),
#### fluidRow()s for "Stability Count" in the sidebar #### #### fluidRow()s for "Stability Count" in the sidebar ####
fluidRow( fluidRow(
conditionalPanel( conditionalPanel(
condition=" condition="
input.sidebar == 'LogoP SNP' || input.sidebar == 'LogoP SNP' ||
input.sidebar =='Stability SNP by site' || input.sidebar =='Stability SNP by site' ||
input.sidebar =='Consurf' || input.sidebar =='Consurf' ||
input.sidebar =='LogoP OR'", input.sidebar =='LogoP OR'",
column(NGLVieweROutput("structure"), column(NGLVieweROutput("structure"),
width=3 width=3
) )
), ),
conditionalPanel( conditionalPanel(
condition=" condition="
input.sidebar == 'LogoP SNP' || input.sidebar == 'LogoP SNP' ||
input.sidebar == 'Stability SNP by site' || input.sidebar == 'Stability SNP by site' ||
input.sidebar == 'Site SNP count' || input.sidebar == 'Site SNP count' ||
input.sidebar == 'Consurf' || input.sidebar == 'Consurf' ||
input.sidebar == 'LogoP OR'", input.sidebar == 'LogoP OR'",
column( column(
DT::dataTableOutput('table'), DT::dataTableOutput('table'),
width=9 width=9
)
)
),
) )
)
),
)
) )
server <- function(input, output, session) { server <- function(input, output, session) {

View file

@ -1,9 +1,3 @@
# library(shiny)
# library(shinycssloaders)
# library(DT)
# library(NGLVieweR)
# library(hash)
function(input, output, session) { function(input, output, session) {
#output$LogoPlotSnps = renderPlot(LogoPlotSnps(mutable_df3)) #output$LogoPlotSnps = renderPlot(LogoPlotSnps(mutable_df3))

View file

@ -1,10 +1,3 @@
# library(shiny)
# library(shinydashboard)
# library(shinycssloaders)
# library(DT)
# library(NGLVieweR)
# library(hash)
#### Shiny UI ##### #### Shiny UI #####
dashboardPage(skin="purple", dashboardPage(skin="purple",