Skip to content

Commit

Permalink
Fix remove baseline, add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
lalo-caballero committed Dec 5, 2023
1 parent 1c7412b commit 55dfc60
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 20 deletions.
1 change: 1 addition & 0 deletions R/baseline-GCIMSDataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 2 additions & 1 deletion R/baseline-GCIMSSample.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion man/estimateBaseline-GCIMSDataset-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion man/estimateBaseline-GCIMSSample-method.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vignettes/creating-a-workflow-step.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
27 changes: 13 additions & 14 deletions vignettes/introduction-to-gcims.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```


Expand Down Expand Up @@ -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
)
```
Expand Down

0 comments on commit 55dfc60

Please sign in to comment.