diff --git a/DESCRIPTION b/DESCRIPTION index 6a2cac4..5cc6bed 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,6 +11,7 @@ Imports: briKmeans, bslib, cowplot, + datamods, DBI, dplyr, foreach, diff --git a/NAMESPACE b/NAMESPACE index 7aa9e69..30b1c39 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,6 +21,8 @@ importFrom(briKmeans,kma.similarity) importFrom(bslib,card) importFrom(bslib,card_header) importFrom(cowplot,theme_cowplot) +importFrom(datamods,select_group_server) +importFrom(datamods,select_group_ui) importFrom(dplyr,"%>%") importFrom(dplyr,arrange) importFrom(dplyr,bind_rows) diff --git a/R/qc_tab.R b/R/qc_tab.R index e6caea4..35cdaa1 100644 --- a/R/qc_tab.R +++ b/R/qc_tab.R @@ -7,6 +7,8 @@ #' @name qc_tab #' #' @param id Shiny namespace ID +#' @param con Active DBI database connection +#' @param user Username of the user #' #' @return A modularized tagList #' @export @@ -14,11 +16,18 @@ #' @importFrom shiny numericInput #' @importFrom shiny sliderInput #' @importFrom shiny tagList -qc_sidebarUI <- function(id) +#' +#' @importFrom datamods select_group_ui +qc_sidebarUI <- function(id, con, user) { ns <- NS(id) tagList( + select_group_ui(id = ns("qc_channels"), + params = list(list(inputId = "expID", label = "Experiment"), + list(inputId = "sID", label = "Sample"), + list(inputId = "chanID", label = "Channel")), + inline = FALSE), sliderInput(ns('qc_min_track_len'), 'Minimum Track Length', 3, 60, value = 6), # minimum track length in minutes numericInput(ns('qc_n_cells'), 'Number of cells', value = 100) ) @@ -36,6 +45,8 @@ qc_sidebarUI <- function(id) #' @importFrom bslib card #' @importFrom bslib card_header #' +#' @importFrom datamods select_group_ui +#' #' @importFrom shiny NS #' @importFrom shiny plotOutput #' @importFrom shiny tagList @@ -55,10 +66,9 @@ qc_cardsUI <- function(id) #' #' @rdname qc_tab #' -#' @param con Active DBI database connection -#' @param user Username of the user -#' #' @export +#' @importFrom datamods select_group_server +#' #' @importFrom dplyr arrange #' @importFrom dplyr group_by #' @importFrom dplyr mutate @@ -84,6 +94,19 @@ qc_server <- function(id, con, user) id, function(input, output, session) { + ns <- NS(id) + + # pull available channels + chanSum <- reactive({ + get_dat(con, + user = user, + select = 'expID, chanID, sID, treatment', + from = 'chanSummary') %>% + mutate(expID = factor(expID), + chanID = factor(chanID), + sID = factor(sID)) + }) + # pull raw track information trackRaw <- reactive({ get_dat(con, @@ -92,6 +115,12 @@ qc_server <- function(id, con, user) from = 'trackRaw', where = 'chanID=2') }) + + # for channel/sample selection + selection <- select_group_server(id = "qc_channels", + data_r = chanSum, + vars_r = reactive(c('expID', 'sID', 'chanID')) + ) output$qc_track_len <- renderPlot({ group_by(trackRaw(), trackID) %>% @@ -114,8 +143,6 @@ qc_server <- function(id, con, user) mutate(time = frames / 2) - print(tmp) - ggplot(tmp, aes(time, n_tracks)) + geom_line() + labs(x = 'Time (min)', y = '# Tracks') diff --git a/man/qc_tab.Rd b/man/qc_tab.Rd index d3a6c26..364a173 100644 --- a/man/qc_tab.Rd +++ b/man/qc_tab.Rd @@ -8,7 +8,7 @@ \title{qc_sidebarUI UI element for the QC sidebar} \usage{ -qc_sidebarUI(id) +qc_sidebarUI(id, con, user) qc_cardsUI(id) diff --git a/shiny/app.R b/shiny/app.R index 8be6a3d..7c0ba3e 100644 --- a/shiny/app.R +++ b/shiny/app.R @@ -12,7 +12,6 @@ library(shiny) library(shinymanager) library(RSQLite) library(DBI) -library(config) library(bslib) library(ggplot2) @@ -74,5 +73,3 @@ server <- function(input, output, session) { ####### shinyApp(ui = ui, server = server) - -dbDisconnect(con)