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

898 save app state version 3 #372

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 5 additions & 4 deletions R/adtteSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ adtteSpecServer <- function(id, # nolint
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

# Join ADTTE with gene data.
adtte_joined <- reactive({
experiment_data <- experiment_data()
Expand Down Expand Up @@ -305,7 +307,7 @@ adtteSpecServer <- function(id, # nolint
# Start by disabling selection, will be overriden if there are valid choices.
session$sendCustomMessage(
"toggle_dropdown",
list(input_id = session$ns("paramcd"), disabled = TRUE)
list(input_id = ns("paramcd"), disabled = TRUE)
)

# Once available endpoints change, we update choices (and also the selection
Expand All @@ -326,12 +328,11 @@ adtteSpecServer <- function(id, # nolint
updateSelectizeInput(
"paramcd",
choices = paramcd_choices,
selected = new_selected,
session = session
selected = restoreInput(ns("paramcd"), new_selected)
)
session$sendCustomMessage(
"toggle_dropdown",
list(input_id = session$ns("paramcd"), disabled = (length(paramcd_choices) == 0))
list(input_id = ns("paramcd"), disabled = (length(paramcd_choices) == 0))
)
})

Expand Down
4 changes: 3 additions & 1 deletion R/assaySpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ assaySpecServer <- function(id, # nolint
assert_character(exclude_assays, any.missing = FALSE)

moduleServer(id, function(input, output, session) {
ns <- session$ns

# When the assay names change, update the choices for assay.
choices <- reactive({
assays <- assays()
Expand All @@ -131,7 +133,7 @@ assaySpecServer <- function(id, # nolint
updateSelectizeInput(session, "name", choices = choices)
session$sendCustomMessage(
"toggle_dropdown",
list(input_id = session$ns("name"), disabled = (length(choices) == 0))
list(input_id = ns("name"), disabled = (length(choices) == 0))
)
})

Expand Down
4 changes: 3 additions & 1 deletion R/barplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ srv_g_barplot <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")
assert_flag(.test)
moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down
4 changes: 3 additions & 1 deletion R/boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ srv_g_boxplot <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down
4 changes: 3 additions & 1 deletion R/forestplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ srv_g_forest_tte <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down
8 changes: 5 additions & 3 deletions R/geneSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ h_update_gene_selection <- function(session,
updateSelectizeInput(
session = session,
inputId = inputId,
selected = selected[is_new_selected],
choices = stats::setNames(choices$id, choices$name),
selected = restoreInput(session$ns(inputId), selected[is_new_selected]),
server = TRUE
)

Expand Down Expand Up @@ -300,6 +300,8 @@ geneSpecServer <- function(id, # nolint
assert_character(label_modal_footer)

moduleServer(id, function(input, output, session) {
ns <- session$ns

# The `reactiveValues` object for storing current gene text input.
# This will also be a data frame with id and name columns.
parsed_genes <- reactiveVal(NULL, label = "Parsed genes")
Expand Down Expand Up @@ -380,14 +382,14 @@ geneSpecServer <- function(id, # nolint
dataModal <- function(example_list) { # nolint
modalDialog(
textInput(
session$ns("gene_text"),
ns("gene_text"),
label = label_modal_title,
placeholder = example_list
),
do.call("span", as.list(label_modal_footer)),
footer = tagList(
modalButton("Cancel"),
actionButton(session$ns("ok_button"), "OK")
actionButton(ns("ok_button"), "OK")
)
)
}
Expand Down
4 changes: 3 additions & 1 deletion R/km.R
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ srv_g_km <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down
12 changes: 6 additions & 6 deletions R/pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ srv_g_pca <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down Expand Up @@ -201,9 +203,8 @@ srv_g_pca <- function(id,
if (filter_top) {
n_top <- input$n_top
updateSliderInput(
session = session,
inputId = "n_top",
value = min(n_top, n_genes),
value = restoreInput(ns("n_top"), min(n_top, n_genes)),
max = n_genes
)
}
Expand Down Expand Up @@ -238,10 +239,9 @@ srv_g_pca <- function(id,
id_names <- c("x_var", "y_var")
for (i in seq_along(id_names)) {
updateSelectizeInput(
session,
id_names[i],
inputId = id_names[i],
choices = pc_choices,
selected = pc_choices[i]
selected = restoreInput(ns(id_names[i]), pc_choices[i])
)
}
})
Expand Down
19 changes: 9 additions & 10 deletions R/quality.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,10 @@ srv_g_quality <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down Expand Up @@ -250,24 +252,21 @@ srv_g_quality <- function(id,
properties <- experiment_properties()

teal.widgets::updateOptionalSelectInput(
session,
"annotate",
inputId = "annotate",
choices = properties$annotations,
selected = "WidthBP"
selected = restoreInput(ns("annotate"), "WidthBP")
)
updateSliderInput(
session,
"min_cpm",
inputId = "min_cpm",
min = properties$min_cpm_calc,
max = properties$max_cpm_calc,
value = properties$min_cpm_calc
value = restoreInput(ns("min_cpm"), properties$min_cpm_calc)
)
updateSliderInput(
session,
"min_depth_continuous",
inputId = "min_depth_continuous",
min = properties$min_depth_calc,
max = properties$max_depth_calc,
value = properties$min_depth_calc
value = restoreInput(ns("min_depth_continuous"), properties$min_depth_calc)
)
})

Expand Down
11 changes: 6 additions & 5 deletions R/sampleVarSpec.R
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ sampleVarSpecServer <- function(id, # nolint
assert_string(label_modal_title)

moduleServer(id, function(input, output, session) {
ns <- session$ns

to_observe <- reactive({
list(experiment_name(), original_data())
})
Expand Down Expand Up @@ -320,10 +322,9 @@ sampleVarSpecServer <- function(id, # nolint
sel <- intersect(input$sample_var, col_data_vars)

teal.widgets::updateOptionalSelectInput(
session,
"sample_var",
inputId = "sample_var",
choices = col_data_vars,
selected = sel
selected = restoreInput(ns("sample_var"), sel)
)
})

Expand Down Expand Up @@ -383,7 +384,7 @@ sampleVarSpecServer <- function(id, # nolint
}
modalDialog(
shinyRadioMatrix::radioMatrixInput(
session$ns("comb_assignment"),
ns("comb_assignment"),
rowIDs = sample_var_levels,
rowIDsName = "Original levels",
rowLLabels = rep("", length = length(sample_var_levels)),
Expand All @@ -393,7 +394,7 @@ sampleVarSpecServer <- function(id, # nolint
tags$span(label_modal_title),
footer = tagList(
modalButton("Cancel"),
actionButton(session$ns("ok"), "OK")
actionButton(ns("ok"), "OK")
),
include_js_files("checkbox.js")
)
Expand Down
4 changes: 3 additions & 1 deletion R/scatterplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ srv_g_scatterplot <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment <- experimentSpecServer(
"experiment",
Expand Down
4 changes: 3 additions & 1 deletion R/volcanoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ srv_g_volcanoplot <- function(id,
checkmate::assert_class(shiny::isolate(data()), "teal_data")

moduleServer(id, function(input, output, session) {
ns <- session$ns

output$experiment_ui <- renderUI({
experimentSpecInput(session$ns("experiment"), data, mae_name)
experimentSpecInput(ns("experiment"), data, mae_name)
})
experiment_data <- experimentSpecServer(
"experiment",
Expand Down
Loading