Skip to content

Commit

Permalink
Merge branch 'devel' into jomain
Browse files Browse the repository at this point in the history
  • Loading branch information
jorainer committed Apr 18, 2024
2 parents da6a2ac + 6e64dd7 commit faba48d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 10 deletions.
9 changes: 8 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
# xcms 4.1

## Changes in version 4.1.13
## Changes in version 4.1.14

- Add `plotPrecursorIons()` function.

## Changes in version 4.1.13

- Add parameter `rtimeDifferenceThreshold` to `ObiwarpParam` allowing to
customize the threshold used by obiwarp to determine whether *gaps* are
present in the sequence of retention times of a sample. This addresses/fixes
issue #739.

## Changes in version 4.1.12

- Implementation of the `LamaParama` class and method for the `adjustRtime()`
Expand Down
12 changes: 12 additions & 0 deletions R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ setGeneric("addProcessHistory", function(object, ...)
#' start and end points and `response = 100` warping using all bijective
#' anchors.
#'
#' @param rtimeDifferenceThreshold For `ObiwarpParam`: `numeric(1)` defining
#' the threshold to identify a *gap* in the sequence of retention times of
#' (MS1) spectra of a sample/file. A gap is defined if the difference in
#' retention times between consecutive spectra is
#' `> rtimeDifferenceThreshold` of the median observed difference or
#' retenion times of that data sample/file. Spectra with an retention time
#' after such a *gap* will not be adjusted. The default for this parameter
#' is `rtimeDifferenceThreshold = 5`. For Waters data with lockmass scans
#' or LC-MS/MS data this might however be a too low threshold and it should
#' be increased. See also
#' [issue #739](https://github.com/sneumann/xcms/issues/739).
#'
#' @param smooth For `PeakGroupsParam`: `character(1)` defining the function to
#' be used to interpolate corrected retention times for all peak groups.
#' Can be either `"loess"` or `"linear"`.
Expand Down
6 changes: 4 additions & 2 deletions R/DataClasses.R
Original file line number Diff line number Diff line change
Expand Up @@ -1522,7 +1522,8 @@ setClass("ObiwarpParam",
localAlignment = "logical",
initPenalty = "numeric",
subset = "integer",
subsetAdjust = "character"),
subsetAdjust = "character",
rtimeDifferenceThreshold = "numeric"),
contains = "Param",
prototype = prototype(
binSize = 1,
Expand All @@ -1536,7 +1537,8 @@ setClass("ObiwarpParam",
localAlignment = FALSE,
initPenalty = 0,
subset = integer(),
subsetAdjust = "average"),
subsetAdjust = "average",
rtimeDifferenceThreshold = 5),
validity = function(object) {
msg <- character()
if (length(object@binSize) > 1 |
Expand Down
1 change: 1 addition & 0 deletions R/MsExperiment-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@

.mse_obiwarp_chunks <- function(x, param, msLevel = 1L, chunkSize = 1L,
BPPARAM = bpparam()) {
message("value ", param@rtimeDifferenceThreshold)
rt_raw <- split(rtime(x), fromFile(x))
subset_idx <- subset(param)
if (length(subset_idx))
Expand Down
8 changes: 4 additions & 4 deletions R/functions-OnDiskMSnExp.R
Original file line number Diff line number Diff line change
Expand Up @@ -448,15 +448,15 @@ findPeaks_MSW_Spectrum_list <- function(x, method = "MSW", param) {
## median difference between spectras' scan time.
mstdiff <- median(c(scantime1_diff, scantime2_diff), na.rm = TRUE)

mst1 <- which(scantime1_diff > 5 * mstdiff)[1]
mst1 <- which(scantime1_diff > param@rtimeDifferenceThreshold * mstdiff)[1]
if (!is.na(mst1)) {
message("Found gaps in scan times of the center sample: cut ",
warning("Found gaps in scan times of the center sample: cut ",
"scantime-vector at ", scantime1[mst1]," seconds.")
scantime1 <- scantime1[seq_len(max(2, (mst1 - 1)))]
}
mst2 <- which(scantime2_diff > 5 * mstdiff)[1]
mst2 <- which(scantime2_diff > param@rtimeDifferenceThreshold * mstdiff)[1]
if (!is.na(mst2)) {
message("Found gaps in scan time. Cutting scantime-vector at ",
warning("Found gaps in scan time. Cutting scantime-vector at ",
scantime2[mst2]," seconds.")
scantime2 <- scantime2[seq_len(max(2, (mst2 - 1)))]
}
Expand Down
6 changes: 4 additions & 2 deletions R/functions-Params.R
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,17 @@ ObiwarpParam <- function(binSize = 1, centerSample = integer(), response = 1L,
gapExtend = numeric(), factorDiag = 2, factorGap = 1,
localAlignment = FALSE, initPenalty = 0,
subset = integer(),
subsetAdjust = c("average", "previous")) {
subsetAdjust = c("average", "previous"),
rtimeDifferenceThreshold = 5) {
subsetAdjust <- match.arg(subsetAdjust)
new("ObiwarpParam", binSize = binSize,
centerSample = as.integer(centerSample),
response = as.integer(response), distFun = distFun,
gapInit = gapInit, gapExtend = gapExtend, factorDiag = factorDiag,
factorGap = factorGap, localAlignment = localAlignment,
initPenalty = initPenalty, subset = as.integer(subset),
subsetAdjust = subsetAdjust)
subsetAdjust = subsetAdjust,
rtimeDifferenceThreshold = rtimeDifferenceThreshold[1L])
}

#' @return The \code{FillChromPeaksParam} function returns a
Expand Down
15 changes: 14 additions & 1 deletion man/adjustRtime.Rd

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

0 comments on commit faba48d

Please sign in to comment.