diff --git a/DESCRIPTION b/DESCRIPTION index 7fedd0f..f42123c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: ddpcr Title: Analysis and Visualization of Droplet Digital PCR in R and on the Web -Version: 1.1.2 +Version: 1.2.0 Authors@R: c( person("Dean", "Attali", email = "daattali@gmail.com", role = c("aut", "cre")) ) diff --git a/NAMESPACE b/NAMESPACE index 993c0e1..aaf45a3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -72,6 +72,7 @@ export(get_wells_btwn) export(has_signif_negative_cluster) export(has_step) export(is_dir) +export(is_dirty) export(is_empty_plate) export(is_file) export(is_range) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..665536c --- /dev/null +++ b/NEWS.md @@ -0,0 +1,7 @@ +# shinyjs 1.2.0 + +2016-03-22 + +- Added a 'dirty' bit to a plate, to keep track of whether any changes to the settings have been made that require a re-run of the analysis. Both the shiny app and the command line inform the user if they are using a dirty plate object + +- A few bug fixes in the shiny app (don't show in Advanced Settings section the settings that are already shown in Basic Settings, don't show Advanced Settings parameters of other plate types) \ No newline at end of file diff --git a/R/plate-attribs.R b/R/plate-attribs.R index a65ed7a..cc0b624 100644 --- a/R/plate-attribs.R +++ b/R/plate-attribs.R @@ -270,6 +270,12 @@ params <- function(plate, category, name) { #' @export `params<-` <- function(plate, category, name, value) { stopifnot(plate %>% inherits("ddpcr_plate")) + + # If a setting is changed after any analysis steps took place, mark the + # plate as 'dirty' + if (!is_empty_plate(plate) && status(plate) > step(plate, "INITIALIZE")) { + plate[['dirty']] <- TRUE + } replace <- 'params' if (!missing(category)) { @@ -552,3 +558,14 @@ y_var <- function(plate) { params(plate, 'GENERAL', 'Y_VAR') <- value plate } + +#' Is the plate object dirty (ie has changed since the analysis was run)? +#' @param plate A ddPCR plate +#' @return \code{TRUE} if any plate settings have changed that require the plate +#' analysis to re-run; \code{FALSE} otherwise +#' @keywords internal +#' @export +is_dirty <- function(plate) { + stopifnot(plate %>% inherits("ddpcr_plate")) + plate[['dirty']] +} \ No newline at end of file diff --git a/R/plate-print.R b/R/plate-print.R index 969fd96..a97c79b 100644 --- a/R/plate-print.R +++ b/R/plate-print.R @@ -64,4 +64,8 @@ print.ddpcr_plate <- function(x, ...) { "\n" ) } + + if (is_dirty(x)) { + cat0("\nNote: some settings have changed, please re-run the analysis with `analyze(plate, restart = TRUE)` for changes to take effect") + } } \ No newline at end of file diff --git a/R/plate-utils.R b/R/plate-utils.R index 6ee4e3e..e79dd61 100644 --- a/R/plate-utils.R +++ b/R/plate-utils.R @@ -14,6 +14,7 @@ empty_plate <- function() { params = NULL, clusters = NULL, steps = NULL, + dirty = NULL, version = NULL ) } @@ -44,6 +45,7 @@ init_plate <- function(plate) { status(plate) <- step(plate, 'INITIALIZE') plate[['version']] <- as.character(utils::packageVersion("ddpcr")) + plate[['dirty']] <- FALSE step_end() plate diff --git a/R/plate.R b/R/plate.R index bc9a966..ec7fdb5 100644 --- a/R/plate.R +++ b/R/plate.R @@ -247,6 +247,7 @@ analyze <- function(plate, restart = FALSE) { if (restart) { msg("Restarting analysis") status(plate) <- 0 + plate[['dirty']] <- FALSE } steps_left <- length(steps(plate)) - status(plate) plate %<>% next_step(n = steps_left) diff --git a/R/sample_data.R b/R/sample_data.R index f86d814..c22e195 100644 --- a/R/sample_data.R +++ b/R/sample_data.R @@ -24,9 +24,8 @@ NULL #' @rdname sample_data #' @export -sample_data_dir <- function(size = c("small", "large")) { - size <- match.arg(size) - system.file("sample_data", size, package = "ddpcr") +sample_data_dir <- function() { + system.file("sample_data", "small", package = "ddpcr") } #' @rdname sample_data diff --git a/R/save_load.R b/R/save_load.R index 23ca086..da1b33c 100644 --- a/R/save_load.R +++ b/R/save_load.R @@ -34,6 +34,7 @@ save_plate <- function(plate, file) { params = params(plate), clusters = clusters(plate), steps = steps(plate), + dirty = plate[['dirty']], version = plate[['version']] ) saveRDS(object = object, file = file) @@ -66,11 +67,12 @@ load_plate <- function(file) { plate_data(plate) <- object[['plate_data']] plate_meta(plate) <- object[['plate_meta']] name(plate) <- object[['name']] - status(plate) <- object[['status']] params(plate) <- object[['params']] clusters(plate) <- object[['clusters']] steps(plate) <- object[['steps']] + plate[['dirty']] <- object[['dirty']] plate[['version']] <- object[['version']] + status(plate) <- object[['status']] }, error = function(err) { err_msg(paste("The given file is not a valid ddPCR file", diff --git a/README.md b/README.md index fbfd40f..4b0ab95 100644 --- a/README.md +++ b/README.md @@ -798,7 +798,7 @@ Now we can analyze the plate #> Classifying droplets... - #> DONE (0 seconds) + #> DONE (1 seconds) #> Reclassifying droplets... skipped (not enough wells with significant mutant clusters) @@ -1044,6 +1044,7 @@ by running `ddpcr:::init_plate`. #> #> status(plate) <- step(plate, 'INITIALIZE') #> plate[['version']] <- as.character(utils::packageVersion("ddpcr")) + #> plate[['dirty']] <- FALSE #> step_end() #> #> plate diff --git a/inst/sample_data/empty_plate.rds b/inst/sample_data/empty_plate.rds index 9c83d30..845fad9 100644 Binary files a/inst/sample_data/empty_plate.rds and b/inst/sample_data/empty_plate.rds differ diff --git a/inst/sample_data/large/large.rds b/inst/sample_data/large/large.rds index 917f6a0..2ad6f42 100644 Binary files a/inst/sample_data/large/large.rds and b/inst/sample_data/large/large.rds differ diff --git a/inst/sample_data/small/analyzed.rds b/inst/sample_data/small/analyzed.rds index 9468f87..3272006 100644 Binary files a/inst/sample_data/small/analyzed.rds and b/inst/sample_data/small/analyzed.rds differ diff --git a/inst/sample_data/small/analyzed_pnpp.rds b/inst/sample_data/small/analyzed_pnpp.rds index 0979ccf..b0da06d 100644 Binary files a/inst/sample_data/small/analyzed_pnpp.rds and b/inst/sample_data/small/analyzed_pnpp.rds differ diff --git a/inst/sample_data/small/small.rds b/inst/sample_data/small/small.rds index d82741c..e9f675d 100644 Binary files a/inst/sample_data/small/small.rds and b/inst/sample_data/small/small.rds differ diff --git a/inst/shiny/server.R b/inst/shiny/server.R index c6e4208..8709733 100644 --- a/inst/shiny/server.R +++ b/inst/shiny/server.R @@ -24,7 +24,11 @@ shinyServer(function(input, output, session) { # we have a dataset to work with or if we're waiting for dataset to be chosen output$datasetChosen <- reactive({ FALSE }) outputOptions(output, 'datasetChosen', suspendWhenHidden = FALSE) - + + observeEvent(dataValues$plate, { + shinyjs::toggle(id = "plateDirty", condition = is_dirty(dataValues$plate)) + }) + # save button (download dataset) button is clicked output$saveBtn <- downloadHandler( filename = function() { @@ -78,10 +82,10 @@ shinyServer(function(input, output, session) { # hide the loading message hide("loading-content", TRUE, "fade") -# TODO remove this , for testing purposes only +#TODO remove this , for testing purposes only # dataValues$plate <- new_plate(dir = sample_data_dir(), # type = plate_types$fam_positive_pnpp) # -# output$datasetChosen <- reactive({ TRUE }) +# output$datasetChosen <- reactive({ TRUE }) # updateTabsetPanel(session, "mainNav", "settingsTab") }) \ No newline at end of file diff --git a/inst/shiny/server/tab-settings.R b/inst/shiny/server/tab-settings.R index 61052fd..b3005f8 100644 --- a/inst/shiny/server/tab-settings.R +++ b/inst/shiny/server/tab-settings.R @@ -128,15 +128,19 @@ observeEvent(input$wellsUsedPlotBrush, { # check all advanced settings and save them observeEvent(input$updateAdvancedSettings, { withBusyIndicator("resetParamsBtn", { + disable("updateAdvancedSettings") advanced_param_regex <- "^advanced_setting_param_(.*)__(.*)$" all_params <- grep(advanced_param_regex, names(input), value = TRUE) lapply(all_params, function(x) { + if (!is.null(input[[x]]) && !is.na(input[[x]])) { major_name <- gsub(advanced_param_regex, "\\1", x) minor_name <- gsub(advanced_param_regex, "\\2", x) - params(dataValues$plate, major_name, minor_name) <- input[[x]] + if (!is.null(params(dataValues$plate, major_name, minor_name))) { + params(dataValues$plate, major_name, minor_name) <- input[[x]] + } } }) enable("updateAdvancedSettings") @@ -167,12 +171,12 @@ observeEvent(dataValues$plate, { lapply( plate %>% params %>% .[[major_name]] %>% names, function(minor_name) { - param_name <- sprintf("%s", major_name, minor_name) + param_name <- sprintf("%s::%s", major_name, minor_name) params_ignore <- c( "GENERAL::X_VAR", "GENERAL::Y_VAR", "GENERAL::POSITIVE_NAME", "GENERAL::NEGATIVE_NAME", - "CLASSIFY::X_THRESHOLD", "CLASSIFY::Y_THRESHOLD" + "GENERAL::POSITIVE_DIMENSION" ) if (param_name %in% params_ignore) { diff --git a/inst/shiny/ui/header.R b/inst/shiny/ui/header.R index 2378ba2..19db3d9 100644 --- a/inst/shiny/ui/header.R +++ b/inst/shiny/ui/header.R @@ -17,7 +17,13 @@ column( "droplets" ), - downloadButton('saveBtn', 'Save data', class = "btn-sm") + downloadButton('saveBtn', 'Save data', class = "btn-sm"), + div( + id = "plateDirty", + class = "alert alert-danger", + strong("Note:"), + "Some settings have changed, please re-run the analysis for changes to take effect" + ) ) ) ) \ No newline at end of file diff --git a/inst/shiny/www/style.css b/inst/shiny/www/style.css index bbb9cf7..240a3e4 100644 --- a/inst/shiny/www/style.css +++ b/inst/shiny/www/style.css @@ -17,6 +17,10 @@ body { color: #FFFFFF; } +#plateDirty { + margin-top: 12px; +} + .navbar { margin-bottom: 0; } diff --git a/man/is_dirty.Rd b/man/is_dirty.Rd new file mode 100644 index 0000000..5e45934 --- /dev/null +++ b/man/is_dirty.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plate-attribs.R +\name{is_dirty} +\alias{is_dirty} +\title{Is the plate object dirty (ie has changed since the analysis was run)?} +\usage{ +is_dirty(plate) +} +\arguments{ +\item{plate}{A ddPCR plate} +} +\value{ +\code{TRUE} if any plate settings have changed that require the plate +analysis to re-run; \code{FALSE} otherwise +} +\description{ +Is the plate object dirty (ie has changed since the analysis was run)? +} +\keyword{internal} + diff --git a/man/sample_data.Rd b/man/sample_data.Rd index b1d3ca0..2aa4c07 100644 --- a/man/sample_data.Rd +++ b/man/sample_data.Rd @@ -8,7 +8,7 @@ \alias{sample_results_file} \title{Get sample data} \usage{ -sample_data_dir(size = c("small", "large")) +sample_data_dir() sample_data_file() diff --git a/vignettes/overview_files/figure-markdown_strict/crosshairresults-1.png b/vignettes/overview_files/figure-markdown_strict/crosshairresults-1.png index 7e8577d..e0ff2af 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/crosshairresults-1.png and b/vignettes/overview_files/figure-markdown_strict/crosshairresults-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/plotcrosshair-1.png b/vignettes/overview_files/figure-markdown_strict/plotcrosshair-1.png index edfec84..3e98a1a 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/plotcrosshair-1.png and b/vignettes/overview_files/figure-markdown_strict/plotcrosshair-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/plotparams-1.png b/vignettes/overview_files/figure-markdown_strict/plotparams-1.png index 7dc3d94..5b62d51 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/plotparams-1.png and b/vignettes/overview_files/figure-markdown_strict/plotparams-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/plotparams-2.png b/vignettes/overview_files/figure-markdown_strict/plotparams-2.png index 4cb618f..78504d4 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/plotparams-2.png and b/vignettes/overview_files/figure-markdown_strict/plotparams-2.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/plotraw-1.png b/vignettes/overview_files/figure-markdown_strict/plotraw-1.png index 2fd14f0..677e7a5 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/plotraw-1.png and b/vignettes/overview_files/figure-markdown_strict/plotraw-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/plotsimple-1.png b/vignettes/overview_files/figure-markdown_strict/plotsimple-1.png index 42e4b56..2a38aa2 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/plotsimple-1.png and b/vignettes/overview_files/figure-markdown_strict/plotsimple-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/pnppplot-1.png b/vignettes/overview_files/figure-markdown_strict/pnppplot-1.png index 18dba74..9cef205 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/pnppplot-1.png and b/vignettes/overview_files/figure-markdown_strict/pnppplot-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/quickstart-1.png b/vignettes/overview_files/figure-markdown_strict/quickstart-1.png index 2fe78dc..f5195fc 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/quickstart-1.png and b/vignettes/overview_files/figure-markdown_strict/quickstart-1.png differ diff --git a/vignettes/overview_files/figure-markdown_strict/quickstart-2.png b/vignettes/overview_files/figure-markdown_strict/quickstart-2.png index f895478..e4e54c5 100644 Binary files a/vignettes/overview_files/figure-markdown_strict/quickstart-2.png and b/vignettes/overview_files/figure-markdown_strict/quickstart-2.png differ