Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #26

Merged
merged 20 commits into from
Mar 1, 2023
Merged

Dev #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y \
libxml2-dev

# Install R depedencies
RUN install2.r shiny pkgload remotes devtools bio3d bs4Dash config data.table DT golem NGLVieweR RcppTOML readr rjson shinyjs blogdown colourpicker shinyfullscreen shinycssloaders shinyWidgets
RUN install2.r shiny pkgload remotes devtools bio3d bs4Dash config data.table DT golem NGLVieweR RcppTOML readr rjson shinyjs blogdown colourpicker shinyfullscreen shinycssloaders shinyWidgets ggplot2 ggpubr

# Copy the app directory into the image
COPY ./kvfinder-web-portal/ /srv/shiny-server/kvfinder-web-portal/
Expand Down
4 changes: 3 additions & 1 deletion kvfinder-web-portal/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Imports:
shinycssloaders,
shinyfullscreen,
shinyjs,
shinyWidgets
shinyWidgets,
ggplot2,
ggpubr
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
1 change: 1 addition & 0 deletions kvfinder-web-portal/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import(blogdown)
import(bs4Dash)
import(colourpicker)
import(data.table)
import(ggplot2)
import(golem)
import(httr)
import(jsonlite)
Expand Down
164 changes: 156 additions & 8 deletions kvfinder-web-portal/R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#' DO NOT REMOVE.
#' @import shiny
#' @import shinyjs
#' @import ggplot2
#'
#'
#' @noRd
#'
Expand Down Expand Up @@ -174,6 +176,10 @@ app_server <- function(input, output, session) {
id = "download2",
time = 0
)
hideElement(
id = "table_footer",
time = 0
)
hideElement(
id = "view_str",
time = 0
Expand Down Expand Up @@ -247,6 +253,14 @@ app_server <- function(input, output, session) {
id = "cavity_hyd",
time = 0
)
hideElement(
id = "scale_plot_deep",
time = 0
)
hideElement(
id = "scale_plot",
time = 0
)
}
})
#----------------------------------------------------
Expand Down Expand Up @@ -288,6 +302,10 @@ app_server <- function(input, output, session) {
id = "download2",
time = 0
)
showElement(
id = "table_footer",
time = 0
)
}
})
# disable check button button to force the users to resubmit job and to avoid inconsistencies in the interface
Expand Down Expand Up @@ -361,6 +379,14 @@ app_server <- function(input, output, session) {
id = "cavity_hyd_pg2",
time = 0
)
hideElement(
id = "scale_plot_deep",
time = 0
)
hideElement(
id = "scale_plot",
time = 0
)
})
#----------------------------------------------------

Expand Down Expand Up @@ -439,6 +465,14 @@ app_server <- function(input, output, session) {
id = "cavity_hyd",
time = 0
)
showElement(
id = "scale_plot_deep",
time = 0
)
showElement(
id = "scale_plot",
time = 0
)
# disable view button to avoid user to click on it multiple times
disable("view_str")
},
Expand Down Expand Up @@ -486,12 +520,10 @@ app_server <- function(input, output, session) {

# Select cavity to be visualized from clicking on cavity selector button
observeEvent(input$select_cavity, {
print('exeuting select')
select_cav(input = input, output = output, result_pdb_list = result_pdb, is_pg2 = FALSE)
})

observeEvent(input$interface_res, {
print('exeuting select')
interface_cav(input = input, output = output, result_pdb_list = result_pdb, is_pg2 = FALSE)
})

Expand Down Expand Up @@ -528,35 +560,74 @@ app_server <- function(input, output, session) {
})

observeEvent(input$input_cavity_deep, {
if(input$input_cavity_deep == TRUE){
updateCheckboxInput(session, "input_cavity_hyd", value = FALSE)
}

color_cavity_deepth(input = input, output = output, is_pg2 = FALSE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )
})

output$scale_plot_deep <- renderPlot({
depth_scale = c(0,result_pdb$list_depth, max(unlist(result_pdb$result_toml$MAX_DEPTH)))
df <- data.frame(x = seq(1,length(depth_scale)), y = depth_scale)
p <- ggplot2::ggplot(data = df, aes(x = x, y = y, colour = y)) +
geom_point() +
#scale_colour_gradient2(name = "Deepth (A)", low = "yellow", mid = "white", high = "blue", midpoint = 0.59,breaks = seq(-1,2.5,0.5))+
scale_color_gradientn(name = "Deepth (A)", colours = rev(rainbow(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",
panel.background = element_rect(fill='transparent'),
plot.background = element_rect(fill='transparent'),
legend.background = element_rect(fill='transparent'),
legend.box.background = element_rect(fill='transparent'))+
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 <- ggpubr::get_legend(p)
ggpubr::as_ggplot(leg)

}, bg="transparent") #, height =50, width = '100%'
})

observeEvent(input$input_cavity_hyd, {
if(input$input_cavity_hyd == TRUE){
updateCheckboxInput(session, "input_cavity_deep", value = FALSE)
}
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)) +
p <- ggplot2::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") +
legend.justification = "center",
panel.background = element_rect(fill='transparent'),
plot.background = element_rect(fill='transparent'),
legend.background = element_rect(fill='transparent'),
legend.box.background = element_rect(fill='transparent'))+
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)
leg <- ggpubr::get_legend(p)
ggpubr::as_ggplot(leg)

}) #, height =50, width = '100%'
}, bg="transparent") #, height =50, width = '100%'
})



##### View in Get latest results page (pg2)

# Click view in the secondary page to initialize the result visualization with the NGL engine
Expand Down Expand Up @@ -633,6 +704,14 @@ app_server <- function(input, output, session) {
id = "cavity_hyd_pg2",
time = 0
)
showElement(
id = "scale_plot_deep_pg2",
time = 0
)
showElement(
id = "scale_plot_pg2",
time = 0
)
disable("view_str_pg2")
})

Expand Down Expand Up @@ -711,12 +790,81 @@ app_server <- function(input, output, session) {
take_snapshot(input = input, output = output, is_pg2 = TRUE)
})

observeEvent(input$interface_res_pg2, {
interface_cav(input = input, output = output, result_pdb_list = result_pdb, is_pg2 = TRUE)
})

observeEvent(input$input_cavity_deep_pg2, {
if(input$input_cavity_deep_pg2 == TRUE){
updateCheckboxInput(session, "input_cavity_hyd_pg2", value = FALSE)
}

color_cavity_deepth(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )

output$scale_plot_deep_pg2 <- renderPlot({
depth_scale = c(0,result_pdb$list_depth, max(unlist(result_pdb$result_toml$MAX_DEPTH)))
df <- data.frame(x = seq(1,length(depth_scale)), y = depth_scale)
p <- ggplot2::ggplot(data = df, aes(x = x, y = y, colour = y)) +
geom_point() +
#scale_colour_gradient2(name = "Deepth (A)", low = "yellow", mid = "white", high = "blue", midpoint = 0.59,breaks = seq(-1,2.5,0.5))+
scale_color_gradientn(name = "Deepth (A)", colours = rev(rainbow(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",
panel.background = element_rect(fill='transparent'),
plot.background = element_rect(fill='transparent'),
legend.background = element_rect(fill='transparent'),
legend.box.background = element_rect(fill='transparent'))+
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 <- ggpubr::get_legend(p)
ggpubr::as_ggplot(leg)

}, bg="transparent") #, height =50, width = '100%'



})

observeEvent(input$input_cavity_hyd_pg2, {
if(input$input_cavity_hyd_pg2 == TRUE){
updateCheckboxInput(session, "input_cavity_deep_pg2", value = FALSE)
}

color_cavity_hyd(input = input, output = output, is_pg2 = TRUE, cav_rep_list=cav_rep_list,result_pdb_list=result_pdb )

output$scale_plot_pg2 <- 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 <- ggplot2::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",
panel.background = element_rect(fill='transparent'),
plot.background = element_rect(fill='transparent'),
legend.background = element_rect(fill='transparent'),
legend.box.background = element_rect(fill='transparent'))+
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 <- ggpubr::get_legend(p)
ggpubr::as_ggplot(leg)

}, bg="transparent") #, height =50, width = '100%'

})

#----------------------------------------------------
Expand Down
21 changes: 21 additions & 0 deletions kvfinder-web-portal/R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ app_ui <- function(request) {
plotOutput("scale_plot", height = '50', width = '50%'))
)
),
conditionalPanel(
condition="input.input_cavity_deep==1",
fluidRow(
column(12, align='center',
plotOutput("scale_plot_deep", height = '50', width = '50%'))
)
),
fluidRow(
column(2, uiOutput("selection_pdb")),
column(2, uiOutput("cavity_rep")),
Expand Down Expand Up @@ -247,6 +254,20 @@ app_ui <- function(request) {
fluidRow(
NGLVieweROutput("structure_pg2", width = "100%", height = "600px")
),
conditionalPanel(
condition="input.input_cavity_hyd_pg2==1",
fluidRow(
column(12, align='center',
plotOutput("scale_plot_pg2", height = '50', width = '50%'))
)
),
conditionalPanel(
condition="input.input_cavity_deep_pg2==1",
fluidRow(
column(12, align='center',
plotOutput("scale_plot_deep_pg2", height = '50', width = '50%'))
)
),
fluidRow(
column(2, uiOutput("selection_pdb_pg2")),
column(2, uiOutput("cavity_rep_pg2")),
Expand Down
21 changes: 9 additions & 12 deletions kvfinder-web-portal/R/mod_server_changeCAVcolor.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ change_cav_color <- function(input, output, is_pg2, cav_rep_list) {
input_cavity_color <- "input_cavity_color"
structure <- "structure"
}
print('inside cav color')
print(cav_rep_list)
# if(length(cav_rep_list) > 1){
# NGLVieweR_proxy(structure) %>%
# updateColor("point", input[[input_cavity_color]])
# } else{
# NGLVieweR_proxy(structure) %>%
# updateColor("sel3", input[[input_cavity_color]])
# }
# print(cav_rep_list)
# print(tail(cav_rep_list,n=1))
NGLVieweR_proxy(structure) %>%

if(!is.null(cav_rep_list)){ #this is to make sure that this will work on the second time loaded page
NGLVieweR_proxy(structure) %>%
updateColor(tail(cav_rep_list,n=1), input[[input_cavity_color]])
} else {
NGLVieweR_proxy(structure) %>%
updateColor("point", input[[input_cavity_color]])
}


}
Loading