Skip to content

Commit 48f34b0

Browse files
committed
selectInput01 function outside the server logic, had to include an ns argument to it and whenever the function is called (INSIDE the server logic) you must incluse ns = ns
1 parent 5f4a53b commit 48f34b0

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

R/mod_curate.R

+20-17
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,6 @@ mod_curate_server <- function(id,r){
7171
shinyjs::show(id = "Curate")
7272
}) |> bindEvent(input$ok)
7373

74-
#selectInput custom function (row argument for ROWnames, default=COLnames for choices)
75-
selectInput01 <- function(id, label, n, r, row = FALSE) {
76-
if (row == FALSE) {
77-
selectInput(ns(id), label = label, choices = c("", colnames(r$fs)), selected = colnames(r$fs)[n])
78-
}
79-
else {
80-
selectInput(ns(id), label = label, choices = c("", rownames(pData(r$fs))), rownames(pData(r$fs))[n])
81-
}
82-
}
83-
8474
# Restart curation MODAL
8575
modal_confirm <- modalDialog(
8676
"Are you sure you want to continue?",
@@ -95,13 +85,13 @@ mod_curate_server <- function(id,r){
9585
output$input_selection <- renderUI({
9686
req(r$fs)
9787
tagList(
98-
selectInput01("forward_scatter", "Forward Scatter", n = 1, r = r),
99-
selectInput01("side_scatter", "Side Scatter", n = 2, r = r),
100-
selectInput01("kras_channel", "KRas channel", n = 3, r = r),
101-
selectInput01("myhc_channel", "Myosin channel", n = 6, r = r),
102-
selectInput01("negative_control", "Negative control", n = 1, r = r, row = TRUE),
103-
selectInput01("positive_control_kras", "Positive control (KRas)", n = 2, r = r, row = TRUE),
104-
selectInput01("positive_control_myhc", "Positive control (MYHC)", n = 3, r = r, row = TRUE)
88+
selectInput01("forward_scatter", "Forward Scatter", n = 1, r = r, ns = ns),
89+
selectInput01("side_scatter", "Side Scatter", n = 2, r = r, ns = ns),
90+
selectInput01("kras_channel", "KRas channel", n = 3, r = r, ns = ns),
91+
selectInput01("myhc_channel", "Myosin channel", n = 6, r = r, ns = ns),
92+
selectInput01("negative_control", "Negative control", n = 1, r = r, row = TRUE, ns = ns),
93+
selectInput01("positive_control_kras", "Positive control (KRas)", n = 2, r = r, row = TRUE, ns = ns),
94+
selectInput01("positive_control_myhc", "Positive control (MYHC)", n = 3, r = r, row = TRUE, ns = ns)
10595
)
10696
})
10797

@@ -319,6 +309,19 @@ make_gate <- function(lower_limit, col_name, filterId) {
319309
return(rectangleGate(filterId = filterId, .gate = mat))
320310
}
321311

312+
#selectInput01:
313+
#row argument:
314+
#- TRUE for ROWnames in selectInput's "choices" argument
315+
# - FALSE (default) for COLnames in selectInput's "choices" argument
316+
selectInput01 <- function(id, label, n, r, row = FALSE, ns) {
317+
if (row == FALSE) {
318+
selectInput(ns(id), label = label, choices = c("", colnames(r$fs)), selected = colnames(r$fs)[n])
319+
}
320+
else {
321+
selectInput(ns(id), label = label, choices = c("", rownames(pData(r$fs))), rownames(pData(r$fs))[n])
322+
}
323+
}
324+
322325

323326
## To be copied in the UI
324327
# mod_curate_ui("curate_1")

0 commit comments

Comments
 (0)