diff --git a/R/baseline-GCIMSDataset.R b/R/baseline-GCIMSDataset.R index cc5d04c..207e94b 100644 --- a/R/baseline-GCIMSDataset.R +++ b/R/baseline-GCIMSDataset.R @@ -6,6 +6,7 @@ #' @param dt_peak_fwhm_ms Full Width at Half Maximum in milliseconds. Used to #' determine the length of the regions where local minima are searched. #' @param dt_region_multiplier A multiplier to calculate the region +#' @param remove A boolean, if TRUE it removes the baseline from the intensity #' @return The modified [GCIMSDataset] #' @export setMethod( diff --git a/R/baseline-GCIMSSample.R b/R/baseline-GCIMSSample.R index 0d2d6b3..6b48eec 100644 --- a/R/baseline-GCIMSSample.R +++ b/R/baseline-GCIMSSample.R @@ -11,11 +11,12 @@ #' @param dt_peak_fwhm_ms Full Width at Half Maximum in milliseconds. Used to #' determine the length of the regions where local minima are searched. #' @param dt_region_multiplier A multiplier to calculate the region +#' @param remove A boolean, if TRUE it removes the baseline from the intensity #' @return The modified [GCIMSSample] #' @export methods::setMethod( "estimateBaseline", "GCIMSSample", - function(object, dt_peak_fwhm_ms, dt_region_multiplier, rt_length_s, remove) { + function(object, dt_peak_fwhm_ms, dt_region_multiplier, rt_length_s, remove = TRUE) { rt <- rtime(object) dt <- dtime(object) int <- intensity(object) diff --git a/man/estimateBaseline-GCIMSDataset-method.Rd b/man/estimateBaseline-GCIMSDataset-method.Rd index 2517142..c6f469e 100644 --- a/man/estimateBaseline-GCIMSDataset-method.Rd +++ b/man/estimateBaseline-GCIMSDataset-method.Rd @@ -4,7 +4,13 @@ \alias{estimateBaseline,GCIMSDataset-method} \title{Estimate the baseline of a GCIMS Sample using a connect local minima algorithm} \usage{ -\S4method{estimateBaseline}{GCIMSDataset}(object, dt_peak_fwhm_ms, dt_region_multiplier, rt_length_s) +\S4method{estimateBaseline}{GCIMSDataset}( + object, + dt_peak_fwhm_ms, + dt_region_multiplier, + rt_length_s, + remove = TRUE +) } \arguments{ \item{object}{A \link{GCIMSDataset} object, modified in-place} @@ -16,6 +22,8 @@ determine the length of the regions where local minima are searched.} \item{rt_length_s}{The length of the baseline region. It should be comparable or longer than the peak width} + +\item{remove}{A boolean, if TRUE it removes the baseline from the intensity} } \value{ The modified \link{GCIMSDataset} diff --git a/man/estimateBaseline-GCIMSSample-method.Rd b/man/estimateBaseline-GCIMSSample-method.Rd index 634fa56..7900611 100644 --- a/man/estimateBaseline-GCIMSSample-method.Rd +++ b/man/estimateBaseline-GCIMSSample-method.Rd @@ -6,7 +6,13 @@ \alias{baseline<-,GCIMSSample-method} \title{Estimate the baseline of a GCIMS Sample using a connect local minima algorithm} \usage{ -\S4method{estimateBaseline}{GCIMSSample}(object, dt_peak_fwhm_ms, dt_region_multiplier, rt_length_s) +\S4method{estimateBaseline}{GCIMSSample}( + object, + dt_peak_fwhm_ms, + dt_region_multiplier, + rt_length_s, + remove = TRUE +) \S4method{baseline}{GCIMSSample}( object, @@ -30,6 +36,8 @@ determine the length of the regions where local minima are searched.} \item{rt_length_s}{The length of the baseline region. It should be comparable or longer than the peak width} +\item{remove}{A boolean, if TRUE it removes the baseline from the intensity} + \item{dt_range}{The minimum and maximum drift times to extract (length 2 vector)} \item{rt_range}{The minimum and maximum retention times to extract (length 2 vector)} diff --git a/vignettes/creating-a-workflow-step.Rmd b/vignettes/creating-a-workflow-step.Rmd index 7d260cf..ec03d4e 100644 --- a/vignettes/creating-a-workflow-step.Rmd +++ b/vignettes/creating-a-workflow-step.Rmd @@ -83,7 +83,7 @@ You can use this template for now: ```{r} cutDrift_Dataset <- function(x, dt_from, dt_to) { - delayed_op <- GCIMS:::GCIMSDelayedOp( + delayed_op <- DelayedOperation( name = "cutDrift", # Give a human-readable name fun = cutDrift_Sample, # The function that is applied to the sample params = list(dt_from = dt_from, dt_to = dt_to) # The arguments that function needs @@ -205,7 +205,7 @@ We use the same function for the dataset: ```{r} cutDrift2_Dataset <- function(x, dt_from, dt_to) { - delayed_op <- GCIMS:::GCIMSDelayedOp( + delayed_op <- DelayedOperation( name = "cutDrift2", # Give a human-readable name fun = cutDrift2_Sample, # The function that is applied to the sample params = list(dt_from = dt_from, dt_to = dt_to) # The arguments that function needs @@ -351,7 +351,7 @@ We now pass those extraction and aggregation functions as well: ```{r} cutDrift3_Dataset <- function(x, dt_from, dt_to) { - delayed_op <- GCIMS:::GCIMSDelayedOp( + delayed_op <- DelayedOperation( name = "cutDrift3", # Give a human-readable name fun = cutDrift2_Sample, # The function that is applied to the sample params = list(dt_from = dt_from, dt_to = dt_to), # The arguments that function needs diff --git a/vignettes/introduction-to-gcims.Rmd b/vignettes/introduction-to-gcims.Rmd index 3b7e3b6..379f808 100644 --- a/vignettes/introduction-to-gcims.Rmd +++ b/vignettes/introduction-to-gcims.Rmd @@ -46,7 +46,7 @@ show_progress_bar <- interactive() && is.null(getOption("knitr.in.progress")) # disable parallellization: (Useful for better error reporting) #register(SerialParam(progressbar = show_progress_bar), default = TRUE) # enable parallellization with 3 workers (you can use more if you have them): -register(SnowParam(workers = 3, progressbar = show_progress_bar, exportglobals = FALSE), default = TRUE) +register(SnowParam(workers = 2, progressbar = show_progress_bar, exportglobals = FALSE), default = TRUE) ``` @@ -546,27 +546,26 @@ ggplot(to_plot) + You can also apply it to a single sample: ```{r} -ket1 <- estimateBaseline( +ket1_no_basline <- estimateBaseline( ket1, dt_peak_fwhm_ms = 0.2, dt_region_multiplier = 12, - rt_length_s = 200 + rt_length_s = 200, + remove = TRUE +) +ket1_basline <- estimateBaseline( + ket1, + dt_peak_fwhm_ms = 0.2, + dt_region_multiplier = 12, + rt_length_s = 200, + remove = FALSE ) -``` - - -```{r} -plot(ket1) -``` - -```{r} -plot(ket1, remove_baseline = TRUE) ``` ```{r} cowplot::plot_grid( - plot(ket1, rt_range = c(0, 500), dt_range = c(6, 16)), - plot(ket1, rt_range = c(0, 500), dt_range = c(6, 16), remove_baseline = TRUE), + plot(ket1_no_basline, rt_range = c(0, 500), dt_range = c(6, 16)), + plot(x = ket1_basline, rt_range = c(0, 500), dt_range = c(6, 16)), ncol = 2 ) ```