Skip to content

Commit

Permalink
app rearrangement and structure
Browse files Browse the repository at this point in the history
  • Loading branch information
werpuc committed Jan 17, 2024
1 parent 2eabb14 commit 433bbdb
Show file tree
Hide file tree
Showing 2 changed files with 139 additions and 21 deletions.
75 changes: 66 additions & 9 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ app_server <- function(input, output, session) {

})

uc_diff_dataset <- reactive({

HRaDeX::create_uc_distance_dataset(state_1_uc(),
state_2_uc())
})

## TAB: HIRES ##

output[["states_params_plot"]] <- ggiraph::renderGirafe({
Expand All @@ -143,18 +149,21 @@ app_server <- function(input, output, session) {
output[["uc_diff_plot"]] <- ggiraph::renderGirafe({

validate(need(!is.null(state_1_uc()) & !is.null(state_2_uc()), "Please upload necessary files."))
HRaDeX::plot_uc_distance(state_1_uc(),
state_2_uc(),

HRaDeX::plot_uc_distance(uc_diff_dataset(),
fractional = F,
interactive = T)

})

## TAB: CLASSIFICATION ##

output[["state_1_class_components"]] <- ggiraph::renderGirafe({

validate(need(!is.null(state_1_params()), "Please upload necessary files."))

HRaDeX::plot_hires_components(state_1_hires_params(),
interactive = T)
interactive = T)

})

Expand All @@ -163,7 +172,7 @@ app_server <- function(input, output, session) {
validate(need(!is.null(state_2_params()), "Please upload necessary files."))

HRaDeX::plot_hires_components(state_2_hires_params(),
interactive = T)
interactive = T)


})
Expand All @@ -174,8 +183,8 @@ app_server <- function(input, output, session) {
validate(need(!is.null(state_1_params()), ""))

HRaDeX::plot_cov_class(state_1_params(),
fractional = fractional(),
interactive = T)
fractional = fractional(),
interactive = T)



Expand All @@ -186,11 +195,12 @@ app_server <- function(input, output, session) {
validate(need(!is.null(state_2_params()), ""))

HRaDeX::plot_cov_class(state_2_params(),
fractional = fractional(),
interactive = T)
fractional = fractional(),
interactive = T)

})
## TAB: Peptides ##

## TAB: UPTAKE CURVES ##

peptide_list <- reactive({

Expand Down Expand Up @@ -249,4 +259,51 @@ app_server <- function(input, output, session) {

})

## TAB: STRUCTURE ##

protein_structure <- reactive({

validate(need(!is.null(input[["pdb_file"]]), "Please provide pdb file to see the 3D structure."))

HRaDeX::plot_3d_structure_blank(pdb_file_path = input[["pdb_file"]][["datapath"]])

})

protein_structure_out <- reactive({

# browser()

color_positions <- c(0)
if("color distance" %in% input[["values_structure"]]){
color_positions <- HRaDeX::prepare_diff_data(two_states_dataset(),
"dist",
input[["threshold_color"]])
}

uc_positions <- c(0)
if("uc distance" %in% input[["values_structure"]]){

uc_positions <- HRaDeX::prepare_diff_data(uc_diff_dataset(),
"uptake_diff",
input[["threshold_uc"]])
}

r3dmol::m_set_style(protein_structure(),
sel = r3dmol::m_sel(resi = color_positions),
style = r3dmol::m_style_cartoon(color = "blue")) |>
r3dmol::m_set_style(sel = r3dmol::m_sel(resi = uc_positions),
style = r3dmol::m_style_cartoon(color = "orange")) |>
r3dmol::m_set_style(sel = r3dmol::m_sel(resi = intersect(color_positions, uc_positions)),
style = r3dmol::m_style_cartoon(color = "red"))


})

output[["protein_structure"]] <- r3dmol::renderR3dmol({

r3dmol::m_button_spin(protein_structure_out())

})


}
85 changes: 73 additions & 12 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ app_ui <- function(request) {
fileInput(inputId = "file_state_1_uc",
label = "Provide uc data for the first state:"),
fileInput(inputId = "file_state_2_uc",
label = "Provide uc data for the second state:")
label = "Provide uc data for the second state:"),
fancy_icon = "cogs"
),
br(),
collapsible_card(
init_collapsed = T,
title = "UC data",
p("See the uptake curve for selected peptide in tab `Peptides`"),
p("See the uptake curve for selected peptide in tab `Uptake Curves`"),
dataTableOutput_h("peptide_list_data"),
actionButton(inputId = "reset_peptide_list",
label = "Reset chosen peptides"),
br()
br(),
fancy_icon = "cogs"
# sliderInput(inputId = "uc_plot_x_range",
# label = "Select x range: ",
# min = 0, max = 100,
Expand All @@ -50,24 +52,83 @@ app_ui <- function(request) {
# label = "Select y range: ",
# min = 0, max = 100,
# value = c(0, 100))
),
br(),
collapsible_card(
init_collapsed = T,
title = "Structure",
p("If the structure of the protein is available, upload the pdb file:"),
fileInput(inputId = "pdb_file",
label = "PDB file: ",
accept = ".pdb"),
checkboxGroupInput(inputId = "values_structure",
label = "Select values to be shown on the structure:",
choices = c("color distance", "uc distance"),
selected = "color distance"
),
numericInput(inputId = "threshold_color",
label = "Threshold for color distance:",
value = 0.1,
min = 0, max = 100),
numericInput(inputId = "threshold_uc",
label = "Threshold for UC distance:",
value = 150,
min = 0, max = 100),
fancy_icon = "cogs"
)
),
mainPanel(
tabsetPanel(
tabPanel(
"Hires",
ggiraph::girafeOutput("states_params_plot"),
ggiraph::girafeOutput("distance_plot"),
p("The residues with NA values for either state are not shown."),
ggiraph::girafeOutput("uc_diff_plot"),
ggiraph::girafeOutput("state_1_class_components"),
ggiraph::girafeOutput("state_2_class_components", width = "100%")
"Hires results",
br(),
tabsetPanel(
tabPanel(
"Plot",
ggiraph::girafeOutput("states_params_plot"),
),
tabPanel(
"Data"
)
),
br(),
tabsetPanel(
tabPanel(
"Plot",
ggiraph::girafeOutput("distance_plot"),
p("The residues with NA values for either state are not shown."),

),
tabPanel(
"Data"
)
),
br(),
tabsetPanel(
tabPanel(
"Plot",
ggiraph::girafeOutput("uc_diff_plot")
),
tabPanel(
"Data"
)
)
),
tabPanel(
"Peptides",
"Uptake Curves",
ggiraph::girafeOutput("uc_plot")
),
tabPanel(
"Classification",
ggiraph::girafeOutput("plot_peptides_coverage_1"),
ggiraph::girafeOutput("plot_peptides_coverage_2"),
ggiraph::girafeOutput("uc_plot")
ggiraph::girafeOutput("state_1_class_components"),
ggiraph::girafeOutput("state_2_class_components")
),
tabPanel(
"Structure",
br(),
r3dmol::r3dmolOutput("protein_structure", width = "100%", height = "1000px")
)
)

Expand Down

0 comments on commit 433bbdb

Please sign in to comment.