Skip to content

Commit faba48d

Browse files
committed
Merge branch 'devel' into jomain
2 parents da6a2ac + 6e64dd7 commit faba48d

File tree

7 files changed

+47
-10
lines changed

7 files changed

+47
-10
lines changed

NEWS.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
# xcms 4.1
22

3-
## Changes in version 4.1.13
3+
## Changes in version 4.1.14
44

55
- Add `plotPrecursorIons()` function.
66

7+
## Changes in version 4.1.13
8+
9+
- Add parameter `rtimeDifferenceThreshold` to `ObiwarpParam` allowing to
10+
customize the threshold used by obiwarp to determine whether *gaps* are
11+
present in the sequence of retention times of a sample. This addresses/fixes
12+
issue #739.
13+
714
## Changes in version 4.1.12
815

916
- Implementation of the `LamaParama` class and method for the `adjustRtime()`

R/AllGenerics.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,18 @@ setGeneric("addProcessHistory", function(object, ...)
194194
#' start and end points and `response = 100` warping using all bijective
195195
#' anchors.
196196
#'
197+
#' @param rtimeDifferenceThreshold For `ObiwarpParam`: `numeric(1)` defining
198+
#' the threshold to identify a *gap* in the sequence of retention times of
199+
#' (MS1) spectra of a sample/file. A gap is defined if the difference in
200+
#' retention times between consecutive spectra is
201+
#' `> rtimeDifferenceThreshold` of the median observed difference or
202+
#' retenion times of that data sample/file. Spectra with an retention time
203+
#' after such a *gap* will not be adjusted. The default for this parameter
204+
#' is `rtimeDifferenceThreshold = 5`. For Waters data with lockmass scans
205+
#' or LC-MS/MS data this might however be a too low threshold and it should
206+
#' be increased. See also
207+
#' [issue #739](https://github.com/sneumann/xcms/issues/739).
208+
#'
197209
#' @param smooth For `PeakGroupsParam`: `character(1)` defining the function to
198210
#' be used to interpolate corrected retention times for all peak groups.
199211
#' Can be either `"loess"` or `"linear"`.

R/DataClasses.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,8 @@ setClass("ObiwarpParam",
15221522
localAlignment = "logical",
15231523
initPenalty = "numeric",
15241524
subset = "integer",
1525-
subsetAdjust = "character"),
1525+
subsetAdjust = "character",
1526+
rtimeDifferenceThreshold = "numeric"),
15261527
contains = "Param",
15271528
prototype = prototype(
15281529
binSize = 1,
@@ -1536,7 +1537,8 @@ setClass("ObiwarpParam",
15361537
localAlignment = FALSE,
15371538
initPenalty = 0,
15381539
subset = integer(),
1539-
subsetAdjust = "average"),
1540+
subsetAdjust = "average",
1541+
rtimeDifferenceThreshold = 5),
15401542
validity = function(object) {
15411543
msg <- character()
15421544
if (length(object@binSize) > 1 |

R/MsExperiment-functions.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333

334334
.mse_obiwarp_chunks <- function(x, param, msLevel = 1L, chunkSize = 1L,
335335
BPPARAM = bpparam()) {
336+
message("value ", param@rtimeDifferenceThreshold)
336337
rt_raw <- split(rtime(x), fromFile(x))
337338
subset_idx <- subset(param)
338339
if (length(subset_idx))

R/functions-OnDiskMSnExp.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,15 @@ findPeaks_MSW_Spectrum_list <- function(x, method = "MSW", param) {
448448
## median difference between spectras' scan time.
449449
mstdiff <- median(c(scantime1_diff, scantime2_diff), na.rm = TRUE)
450450

451-
mst1 <- which(scantime1_diff > 5 * mstdiff)[1]
451+
mst1 <- which(scantime1_diff > param@rtimeDifferenceThreshold * mstdiff)[1]
452452
if (!is.na(mst1)) {
453-
message("Found gaps in scan times of the center sample: cut ",
453+
warning("Found gaps in scan times of the center sample: cut ",
454454
"scantime-vector at ", scantime1[mst1]," seconds.")
455455
scantime1 <- scantime1[seq_len(max(2, (mst1 - 1)))]
456456
}
457-
mst2 <- which(scantime2_diff > 5 * mstdiff)[1]
457+
mst2 <- which(scantime2_diff > param@rtimeDifferenceThreshold * mstdiff)[1]
458458
if (!is.na(mst2)) {
459-
message("Found gaps in scan time. Cutting scantime-vector at ",
459+
warning("Found gaps in scan time. Cutting scantime-vector at ",
460460
scantime2[mst2]," seconds.")
461461
scantime2 <- scantime2[seq_len(max(2, (mst2 - 1)))]
462462
}

R/functions-Params.R

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,17 @@ ObiwarpParam <- function(binSize = 1, centerSample = integer(), response = 1L,
311311
gapExtend = numeric(), factorDiag = 2, factorGap = 1,
312312
localAlignment = FALSE, initPenalty = 0,
313313
subset = integer(),
314-
subsetAdjust = c("average", "previous")) {
314+
subsetAdjust = c("average", "previous"),
315+
rtimeDifferenceThreshold = 5) {
315316
subsetAdjust <- match.arg(subsetAdjust)
316317
new("ObiwarpParam", binSize = binSize,
317318
centerSample = as.integer(centerSample),
318319
response = as.integer(response), distFun = distFun,
319320
gapInit = gapInit, gapExtend = gapExtend, factorDiag = factorDiag,
320321
factorGap = factorGap, localAlignment = localAlignment,
321322
initPenalty = initPenalty, subset = as.integer(subset),
322-
subsetAdjust = subsetAdjust)
323+
subsetAdjust = subsetAdjust,
324+
rtimeDifferenceThreshold = rtimeDifferenceThreshold[1L])
323325
}
324326

325327
#' @return The \code{FillChromPeaksParam} function returns a

man/adjustRtime.Rd

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)