From d06b32b33afa619a4edd2ad95644c59b6108d63e Mon Sep 17 00:00:00 2001 From: Dillon Hammill Date: Tue, 14 May 2024 08:54:51 +1000 Subject: [PATCH] Support instrument ranges in cyto_plot_calibarte(). --- DESCRIPTION | 2 +- NEWS.md | 6 +++++- R/cyto_plot-helpers.R | 36 ++++++++++++++++++++++++++++-------- man/cyto_plot_calibrate.Rd | 14 ++++++++------ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d735cf51..1b0d8344 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: CytoExploreR Type: Package Title: Interactive Analysis of Cytometry Data -Version: 2.0.5 +Version: 2.0.6 Date: 2024-04-10 Authors@R: c( person("Dillon", "Hammill", role = c("aut", "cre"), email = "Dillon.Hammill@anu.edu.au"), diff --git a/NEWS.md b/NEWS.md index b74fd9bc..3e691752 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,11 @@ -# CytoExploreR 2.0.6 (pre-release) +# CytoExploreR 2.0.7 (pre-release) * The behavior of `cyto_merge_by()` when `merge_by = NA` has changed from collapsing all samples to instead split samples individually. This is because splitting by `name` may not always work in cases where multiple samples share the same file names. This change requires updates to openCyto which should be re-installed when updating to the new version of CytoExploreR. +# CytoExploreR 2.0.6 + +* `cyto_plot_calibrate()` can now use the full instrument ranges for calibration through `type = "instrument"`. + # CytoExploreR 2.0.5 * `cyto_import()` has gained a logical `nodes` argument that allows for bypassing of the unique nodes test and renaming (it can be temperamental for complex node names). diff --git a/R/cyto_plot-helpers.R b/R/cyto_plot-helpers.R index 1b6b3e92..8978a1cc 100644 --- a/R/cyto_plot-helpers.R +++ b/R/cyto_plot-helpers.R @@ -2035,12 +2035,14 @@ cyto_plot_layout <- function(...){ #' extract samples that should be used to calibrate the channels, set to NULL #' by default to calibrate channels using data from all samples. #' @param type indicates the type of calibration to perform, options include -#' \code{"range"} or \code{"quantile"}, set to \code{"quantile"} by default. -#' Range calibration simply uses the full range of values across samples for -#' the calibration. Quantile calibration computes an lower and upper quantile -#' for each channel, values falling outside the calibration range are assigned -#' the bottom or top colour. Alternatively, users can also supply their own -#' custom calibration function to \code{type} that accepts a matrix. +#' \code{"instrument"}, \code{"range"} or \code{"quantile"}, set to +#' \code{"quantile"} by default. Instrument calibartion uses the full +#' instrument range in each channel for calibration. Range calibration simply +#' uses the full range of values across samples for the calibration. Quantile +#' calibration computes an lower and upper quantile for each channel, values +#' falling outside the calibration range are assigned the bottom or top +#' colour. Alternatively, users can also supply their own custom calibration +#' function to \code{type} that accepts a matrix. #' @param probs vector of lower and upper probabilities passed to #' \code{stats:quantile} to compute quantiles, set to \code{c(0.01, 0.99)} by #' default. @@ -2183,8 +2185,26 @@ cyto_plot_calibrate <- function(x, } # ONLY COMPUTE LIMITS IF NOT SUPPLIED if(any(is.na(z))) { - # RANGE - if(grepl("^r", type, ignore.case = TRUE)) { + # INSTRUMENT|MACHINE + if(grepl("^i|^m", type, ignore.case = TRUE)) { + res <- cyto_apply( + x, + function(w) { + range( + w, + "instrument" + ) + }, + select = 1, + parent = parent, + channels = channels[cnt], + input = "cytoframe", + inverse = FALSE, + copy = FALSE, + ... + ) + # RANGE|DATA + } else if(grepl("^r|^d", type, ignore.case = TRUE)) { res <- cyto_apply( x, "cyto_stat_range", diff --git a/man/cyto_plot_calibrate.Rd b/man/cyto_plot_calibrate.Rd index 12e95ae8..8871146a 100644 --- a/man/cyto_plot_calibrate.Rd +++ b/man/cyto_plot_calibrate.Rd @@ -41,12 +41,14 @@ extract samples that should be used to calibrate the channels, set to NULL by default to calibrate channels using data from all samples.} \item{type}{indicates the type of calibration to perform, options include -\code{"range"} or \code{"quantile"}, set to \code{"quantile"} by default. -Range calibration simply uses the full range of values across samples for -the calibration. Quantile calibration computes an lower and upper quantile -for each channel, values falling outside the calibration range are assigned -the bottom or top colour. Alternatively, users can also supply their own -custom calibration function to \code{type} that accepts a matrix.} +\code{"instrument"}, \code{"range"} or \code{"quantile"}, set to +\code{"quantile"} by default. Instrument calibartion uses the full +instrument range in each channel for calibration. Range calibration simply +uses the full range of values across samples for the calibration. Quantile +calibration computes an lower and upper quantile for each channel, values +falling outside the calibration range are assigned the bottom or top +colour. Alternatively, users can also supply their own custom calibration +function to \code{type} that accepts a matrix.} \item{probs}{vector of lower and upper probabilities passed to \code{stats:quantile} to compute quantiles, set to \code{c(0.01, 0.99)} by