From fe25b04024e37696d393e59f24cc52add5333fd7 Mon Sep 17 00:00:00 2001 From: Helder Ribeiro Date: Mon, 27 Feb 2023 20:17:28 -0500 Subject: [PATCH 1/4] add hydropathy to view --- kvfinder-web-portal/NAMESPACE | 1 + kvfinder-web-portal/R/app_server.R | 25 ++++++++- kvfinder-web-portal/R/app_ui.R | 6 ++- .../R/mod_server_colorCAVhyd.R | 51 +++++++++++++++++++ .../R/mod_server_createINITscene.R | 9 ++++ kvfinder-web-portal/man/color_cavity_hyd.Rd | 20 ++++++++ 6 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 kvfinder-web-portal/R/mod_server_colorCAVhyd.R create mode 100644 kvfinder-web-portal/man/color_cavity_hyd.Rd diff --git a/kvfinder-web-portal/NAMESPACE b/kvfinder-web-portal/NAMESPACE index 91e0456..dfa1b29 100644 --- a/kvfinder-web-portal/NAMESPACE +++ b/kvfinder-web-portal/NAMESPACE @@ -10,6 +10,7 @@ export(check_results) export(choose_input) export(choose_run_mode) export(color_cavity_deepth) +export(color_cavity_hyd) export(create_init_scene) export(create_work_scene) export(deal_sele_nonstand) diff --git a/kvfinder-web-portal/R/app_server.R b/kvfinder-web-portal/R/app_server.R index f4ec533..837483d 100644 --- a/kvfinder-web-portal/R/app_server.R +++ b/kvfinder-web-portal/R/app_server.R @@ -243,6 +243,10 @@ app_server <- function(input, output, session) { id = "cavity_deep", time = 0 ) + hideElement( + id = "cavity_hyd", + time = 0 + ) } }) #---------------------------------------------------- @@ -353,6 +357,10 @@ app_server <- function(input, output, session) { id = "cavity_deep_pg2", time = 0 ) + hideElement( + id = "cavity_hyd_pg2", + time = 0 + ) }) #---------------------------------------------------- @@ -427,6 +435,10 @@ app_server <- function(input, output, session) { id = "cavity_deep", time = 0 ) + showElement( + id = "cavity_hyd", + time = 0 + ) # disable view button to avoid user to click on it multiple times disable("view_str") }, @@ -519,7 +531,10 @@ app_server <- function(input, output, session) { color_cavity_deepth(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb ) }) - + observeEvent(input$input_cavity_hyd, { + color_cavity_hyd(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb ) + }) + ##### View in Get latest results page (pg2) # Click view in the secondary page to initialize the result visualization with the NGL engine @@ -592,6 +607,10 @@ app_server <- function(input, output, session) { id = "cavity_deep_pg2", time = 0 ) + showElement( + id = "cavity_hyd_pg2", + time = 0 + ) disable("view_str_pg2") }) @@ -673,6 +692,10 @@ app_server <- function(input, output, session) { observeEvent(input$input_cavity_deep_pg2, { color_cavity_deepth(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb ) }) + + observeEvent(input$input_cavity_hyd_pg2, { + color_cavity_hyd(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb ) + }) #---------------------------------------------------- } diff --git a/kvfinder-web-portal/R/app_ui.R b/kvfinder-web-portal/R/app_ui.R index 64109c3..bfede62 100644 --- a/kvfinder-web-portal/R/app_ui.R +++ b/kvfinder-web-portal/R/app_ui.R @@ -159,7 +159,8 @@ app_ui <- function(request) { column(2, uiOutput("cavity_rep")), column(2, uiOutput("cavity_color")), column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_deep"))), - column(4, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface"))), + column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_hyd"))), + column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface"))), ), fluidRow( column(2, uiOutput("protein_rep")), @@ -243,7 +244,8 @@ app_ui <- function(request) { column(2, uiOutput("cavity_rep_pg2")), column(2, uiOutput("cavity_color_pg2")), column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_deep_pg2"))), - column(4, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface_pg2"))), + column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("cavity_hyd_pg2"))), + column(2, div(style = "display: inline-block; vertical-align: -20px;", uiOutput("show_interface_pg2"))), ), fluidRow( column(2, uiOutput("protein_rep_pg2")), diff --git a/kvfinder-web-portal/R/mod_server_colorCAVhyd.R b/kvfinder-web-portal/R/mod_server_colorCAVhyd.R new file mode 100644 index 0000000..0ac3cf1 --- /dev/null +++ b/kvfinder-web-portal/R/mod_server_colorCAVhyd.R @@ -0,0 +1,51 @@ +#' Function that change background color in NGL viewer +#' +#' @param input shiny input +#' @param output shiny output +#' @param is_pg2 logical TRUE/FALSE. If TRUE, we calling to create result in page 2 (get latest results page). +#' @param cav_rep_list +#' @param result_pdb_list +#' +#' +#' @import shiny +#' @import NGLVieweR +#' +#' @export +#' + +color_cavity_hyd <- function(input, output, is_pg2, cav_rep_list, result_pdb_list) { + if (is_pg2 == TRUE) { + input_cavity_hyd <- "input_cavity_hyd_pg2" + structure <- "structure_pg2" + } else { + input_cavity_hyd <- "input_cavity_hyd" + structure <- "structure" + } + #print(result_pdb_list$result_toml$MAX_DEPTH) + #print(max(unlist(result_pdb_list$result_toml$MAX_DEPTH))) + #NGLVieweR_proxy(structure) %>% + # removeSelection(name = tail(cav_rep_list, n = 2)[1]) + # After the initial structure is invisible, we can add a new representation to the current scene + + if(input[[input_cavity_hyd]] == TRUE){ + NGLVieweR_proxy(structure) %>% + addSelection("point", + param = + list( + name = "hyd", # now the created selection is named "sel3" + sele = paste(result_pdb_list$result_cav_names, collapse = " or "), + colorScheme = 'occupancy', + colorScale = c('blue', 'white', 'yellow'), + colorReverse = TRUE, + colorDomain = c(-1.42, 2.6) + #colorScheme = scheme_color_list[[tail(protein_col_scheme_list, n = 1)]] + ) + ) + } else{ + NGLVieweR_proxy(structure) %>% + removeSelection(name = "hyd") + } + + # NGLVieweR_proxy(structure) %>% + # updateColor(tail(cav_rep_list,n=1),color= "resname") +} diff --git a/kvfinder-web-portal/R/mod_server_createINITscene.R b/kvfinder-web-portal/R/mod_server_createINITscene.R index 59d4685..d5f2a2a 100644 --- a/kvfinder-web-portal/R/mod_server_createINITscene.R +++ b/kvfinder-web-portal/R/mod_server_createINITscene.R @@ -32,6 +32,7 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col fullscreen_title <- "fullscreen_title_pg2" cavity_rep <- "cavity_rep_pg2" cavity_deep <- "cavity_deep_pg2" + cavity_hyd <- "cavity_hyd_pg2" # if in the main page } else { structure <- "structure" @@ -50,6 +51,7 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col fullscreen_title <- "fullscreen_title" cavity_rep <- "cavity_rep" cavity_deep <- "cavity_deep" + cavity_hyd <- "cavity_hyd" } #------------------------------------------------------------------------------------------------------- @@ -187,5 +189,12 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col checkboxInput(inputId = paste("input_", cavity_deep, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Cavity depth")) ) }) + + output[[cavity_hyd]] <- renderUI({ + div( + style = "font-size:12px;", + checkboxInput(inputId = paste("input_", cavity_hyd, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Cavity hydropathy")) + ) + }) #---------------------------------------------------------------------------------------------------------------- } diff --git a/kvfinder-web-portal/man/color_cavity_hyd.Rd b/kvfinder-web-portal/man/color_cavity_hyd.Rd new file mode 100644 index 0000000..8f1ce09 --- /dev/null +++ b/kvfinder-web-portal/man/color_cavity_hyd.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mod_server_colorCAVhyd.R +\name{color_cavity_hyd} +\alias{color_cavity_hyd} +\title{Function that change background color in NGL viewer} +\usage{ +color_cavity_hyd(input, output, is_pg2, cav_rep_list, result_pdb_list) +} +\arguments{ +\item{input}{shiny input} + +\item{output}{shiny output} + +\item{is_pg2}{logical TRUE/FALSE. If TRUE, we calling to create result in page 2 (get latest results page).} + +\item{result_pdb_list}{} +} +\description{ +Function that change background color in NGL viewer +} From 53d297427517fd5603dea8a6b536c81dadd9152e Mon Sep 17 00:00:00 2001 From: Helder Ribeiro Date: Mon, 27 Feb 2023 22:47:16 -0500 Subject: [PATCH 2/4] add hyd scale --- kvfinder-web-portal/R/app_server.R | 22 ++++++++++++++++++++++ kvfinder-web-portal/R/app_ui.R | 7 +++++++ 2 files changed, 29 insertions(+) diff --git a/kvfinder-web-portal/R/app_server.R b/kvfinder-web-portal/R/app_server.R index 837483d..3b4f7d8 100644 --- a/kvfinder-web-portal/R/app_server.R +++ b/kvfinder-web-portal/R/app_server.R @@ -533,6 +533,28 @@ app_server <- function(input, output, session) { observeEvent(input$input_cavity_hyd, { color_cavity_hyd(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb ) + output$scale_plot <- renderPlot({ + EisenbergWeiss_scale = c(-0.64, 2.6,0.8,0.92,-0.3,0.87,0.76, + -0.49,0.41,-1.42,-1.09,1.54,-0.66,-1.22, + -0.12,0.18,0.05, -0.83, -0.27, -1.11) + df <- data.frame(x = seq(1,length(EisenbergWeiss_scale)), y = EisenbergWeiss_scale) + p <- ggplot(data = df, aes(x = x, y = y, colour = y)) + + geom_point() + + scale_colour_gradient2(name = "Hydropathy", low = "yellow", mid = "white", high = "blue", midpoint = 0.59,breaks = seq(-1,2.5,0.5))+ + theme(plot.title = element_text(hjust = 0.5), + legend.position = "bottom", + legend.key.width= unit(0.2, 'npc'), + #legend.spacing = unit(0.25,"cm"), + legend.title = element_text(hjust = 0.5), + legend.justification = "center") + + guides(colour = guide_colourbar(title.position="top", title.hjust = 0.5), + size = guide_legend(title.position="top", title.hjust = 0.5)) + + # ggpubr does this for you + leg <- get_legend(p) + as_ggplot(leg) + + }) #, height =50, width = '100%' }) ##### View in Get latest results page (pg2) diff --git a/kvfinder-web-portal/R/app_ui.R b/kvfinder-web-portal/R/app_ui.R index bfede62..d997215 100644 --- a/kvfinder-web-portal/R/app_ui.R +++ b/kvfinder-web-portal/R/app_ui.R @@ -154,6 +154,13 @@ app_ui <- function(request) { NGLVieweROutput("structure", width = "100%", height = "75vh") ) ), + conditionalPanel( + condition="input.input_cavity_hyd==1", + fluidRow( + column(12, align='center', + plotOutput("scale_plot", height = '50', width = '50%')) + ) + ), fluidRow( column(2, uiOutput("selection_pdb")), column(2, uiOutput("cavity_rep")), From 89d7bb6f845e3855ef223d876e85961802a12251 Mon Sep 17 00:00:00 2001 From: Helder Ribeiro Date: Mon, 27 Feb 2023 23:24:14 -0500 Subject: [PATCH 3/4] add hyd in table --- kvfinder-web-portal/R/app_ui.R | 1 + kvfinder-web-portal/R/mod_server_checkResults.R | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kvfinder-web-portal/R/app_ui.R b/kvfinder-web-portal/R/app_ui.R index d997215..67c011b 100644 --- a/kvfinder-web-portal/R/app_ui.R +++ b/kvfinder-web-portal/R/app_ui.R @@ -142,6 +142,7 @@ app_ui <- function(request) { tags$br(), uiOutput("results_table"), tags$br(), + htmlOutput("table_footer") ), column( 7, diff --git a/kvfinder-web-portal/R/mod_server_checkResults.R b/kvfinder-web-portal/R/mod_server_checkResults.R index 46bcdc8..5adc024 100644 --- a/kvfinder-web-portal/R/mod_server_checkResults.R +++ b/kvfinder-web-portal/R/mod_server_checkResults.R @@ -86,10 +86,11 @@ check_results <- function(input, output, run_id, is_pg2, url_address, session) { }) output[[table_out]] <- DT::renderDataTable( data.table( - `Cavity ID` = names(result_toml$AREA), + `ID` = names(result_toml$AREA), `Area (A²)` = unlist(result_toml$AREA), - `Volume (A³)` = unlist(result_toml$VOLUME), - `Avg Depth (A)` = unlist(result_toml$AVG_DEPTH) + `Vol. (A³)` = unlist(result_toml$VOLUME), + `Dep. (A)` = unlist(result_toml$AVG_DEPTH), + `Hyd.` = unlist(result_toml$AVG_HYDROPATHY) ), filter = c("none"), style = "auto", @@ -97,7 +98,7 @@ check_results <- function(input, output, run_id, is_pg2, url_address, session) { buttons = c("excel", "pdf"), autoWidth = TRUE, scrollX = TRUE, - columnDefs = list(list(targets=c(4), visible=TRUE, width='75')) + columnDefs = list(list(targets=c(5), visible=TRUE, width='60')) ), extensions = "Buttons" ) @@ -130,11 +131,16 @@ check_results <- function(input, output, run_id, is_pg2, url_address, session) { write_toml(param_list, output = filename) } ) - # create visualization button output[[view_output]] <- renderUI({ actionButton(inputId = view_str, label = "View", icon = icon("eye"), style = "color: #fff; background-color: #6c757d; border-color: #6c757d") }) + + output$table_footer <- renderText({ + paste( + p("ID: Cavity ID, Area: Cavity area, Vol: Cavity volume, Dep: Cavity depth, Hyd: Cavity hydropathy.") + ) + }) # create list to store results result_list <- list( retrieve_input_pdb = retrieve_input_pdb, From bedcbd834c9ebb182e01124c9fe3456e7e31a8a1 Mon Sep 17 00:00:00 2001 From: Helder Ribeiro Date: Mon, 27 Feb 2023 23:36:23 -0500 Subject: [PATCH 4/4] organize layout --- kvfinder-web-portal/R/mod_server_checkResults.R | 2 +- kvfinder-web-portal/R/mod_server_createINITscene.R | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kvfinder-web-portal/R/mod_server_checkResults.R b/kvfinder-web-portal/R/mod_server_checkResults.R index 5adc024..ca60680 100644 --- a/kvfinder-web-portal/R/mod_server_checkResults.R +++ b/kvfinder-web-portal/R/mod_server_checkResults.R @@ -138,7 +138,7 @@ check_results <- function(input, output, run_id, is_pg2, url_address, session) { output$table_footer <- renderText({ paste( - p("ID: Cavity ID, Area: Cavity area, Vol: Cavity volume, Dep: Cavity depth, Hyd: Cavity hydropathy.") + p("ID: Cavity ID, Area: Cavity area, Vol: Cavity volume, Dep: Cavity average depth, Hyd: Cavity average hydropathy.") ) }) # create list to store results diff --git a/kvfinder-web-portal/R/mod_server_createINITscene.R b/kvfinder-web-portal/R/mod_server_createINITscene.R index d5f2a2a..85b4a75 100644 --- a/kvfinder-web-portal/R/mod_server_createINITscene.R +++ b/kvfinder-web-portal/R/mod_server_createINITscene.R @@ -89,7 +89,7 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col output[[show_interface]] <- renderUI({ div( style = "font-size:12px;", - checkboxInput(inputId = interface_res, label = div(style = "font-size:12px;display:inline-block", "Show interface residues")) + checkboxInput(inputId = interface_res, label = div(style = "font-size:12px;display:inline-block", "Interface AA")) ) }) # protein color scheme selector @@ -186,14 +186,14 @@ create_init_scene <- function(input, output, result_pdb_list, is_pg2, scheme_col output[[cavity_deep]] <- renderUI({ div( style = "font-size:12px;", - checkboxInput(inputId = paste("input_", cavity_deep, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Cavity depth")) + checkboxInput(inputId = paste("input_", cavity_deep, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Depth")) ) }) output[[cavity_hyd]] <- renderUI({ div( style = "font-size:12px;", - checkboxInput(inputId = paste("input_", cavity_hyd, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Cavity hydropathy")) + checkboxInput(inputId = paste("input_", cavity_hyd, sep = ""), label = div(style = "font-size:12px;display:inline-block", "Hydropathy")) ) }) #----------------------------------------------------------------------------------------------------------------