Skip to content

Commit

Permalink
Follow changes in nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
nfrerebeau committed Apr 9, 2024
1 parent a11b8af commit f2df7bd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 69 deletions.
109 changes: 41 additions & 68 deletions R/module_coda.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,47 @@ coda_ui <- function(id) {
# Create a namespace function using the provided id
ns <- NS(id)

fluidRow(
column(
width = 4,
wellPanel(
selectizeInput(
inputId = ns("codes"),
label = bslib::tooltip(
span("Unique identifiers", icon("info-circle")),
"Define the unique identifier (eg. laboratory codes) of each observation."
),
choices = NULL,
selected = NULL,
multiple = FALSE,
options = list(plugins = "clear_button")
sidebarLayout(
sidebarPanel(
selectizeInput(
inputId = ns("codes"),
label = bslib::tooltip(
span("Unique identifiers", icon("info-circle")),
"Define the unique identifier (eg. laboratory codes) of each observation."
),
selectizeInput(
inputId = ns("samples"),
label = bslib::tooltip(
span("Sample names", icon("info-circle")),
"Duplicated sample names will be interpreted as repeated measurements."
),
choices = NULL,
selected = NULL,
multiple = FALSE,
options = list(plugins = "clear_button")
choices = NULL,
selected = NULL,
multiple = FALSE,
options = list(plugins = "clear_button")
),
selectizeInput(
inputId = ns("samples"),
label = bslib::tooltip(
span("Sample names", icon("info-circle")),
"Duplicated sample names will be interpreted as repeated measurements."
),
selectizeInput(
inputId = ns("groups"),
label = bslib::tooltip(
span("Groups", icon("info-circle")),
"Empty strings will be interpreted as unassigned samples."
),
choices = NULL,
selected = NULL,
multiple = FALSE,
options = list(plugins = "clear_button")
)
), # wellPanel
choices = NULL,
selected = NULL,
multiple = FALSE,
options = list(plugins = "clear_button")
),
selectizeInput(
inputId = ns("groups"),
label = bslib::tooltip(
span("Groups", icon("info-circle")),
"Empty strings will be interpreted as unassigned samples."
),
choices = NULL,
selected = NULL,
multiple = FALSE,
options = list(plugins = "clear_button")
),
hr(),
## Output: display description
h5("Description"),
uiOutput(outputId = ns("description"))
), # column
column(
width = 8,
), # sidebarPanel
mainPanel(
tabsetPanel(
tabPanel(
title = "Detection limits",
Expand All @@ -72,8 +70,8 @@ coda_ui <- function(id) {
DT::dataTableOutput(outputId = ns("table"))
)
)
) # column
) # fluidRow
) # mainPanel
) # sidebarLayout
}

# Server =======================================================================
Expand Down Expand Up @@ -213,33 +211,8 @@ coda_server <- function(id, x) {

output$description <- renderUI({
req(clean())
assigned <- nexus::is_assigned(clean())
n_col <- ncol(clean())
n_obs <- nrow(clean())
n_spl <- length(unique(nexus::get_samples(clean())))
n_rep <- sum(nexus::is_replicated(clean()))
n_grp <- length(unique(nexus::get_groups(clean())[assigned]))
n_out <- sum(!assigned)

msg_parts <- sprintf("%d parts: %s", n_col, paste0(colnames(clean()), collapse = ", "))
msg_obs <- sprintf("%d %s:", n_obs, ngettext(n_obs, "observation", "observations"))
msg_spl <- sprintf("%d unique %s", n_spl, ngettext(n_spl, "sample", "samples"))
msg_rep <- sprintf("%d replicated %s", n_rep, ngettext(n_rep, "observation", "observations"))
msg_grp <- sprintf("%d %s", n_grp, ngettext(n_grp, "group", "groups"))
msg_out <- sprintf("%d unassigned %s", n_out, ngettext(n_out, "sample", "samples"))

tags$ul(
class = "list-group list-group-flush",
tags$li(class="list-group-item", msg_parts),
tags$li(class="list-group-item", msg_spl),
tags$li(class="list-group-item", msg_rep),
tags$li(
class="list-group-item",
msg_grp,
tags$ul(class = "list-group list-group-flush", list_group())
),
tags$li(class="list-group-item", msg_out)
)
descr <- capture.output(nexus::describe(clean()))
markdown(descr)
})

## Render tables -----
Expand Down
1 change: 0 additions & 1 deletion R/module_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,6 @@ prepare_server <- function(id, x) {
x = data_clean(),
val = input
)
print(each_var)
keep <- Reduce(f = `&`, x = each_var)
if (all(!keep)) return(data_clean())
data_clean()[keep, , drop = FALSE]
Expand Down

0 comments on commit f2df7bd

Please sign in to comment.