Skip to content

Commit

Permalink
fix: issue #654
Browse files Browse the repository at this point in the history
- Fix problem with `fillChromPeaks` after `MatchedFilterParam` peak detection on
  very sparse data (i.e. data with many empty spectra).
  • Loading branch information
jorainer committed Jan 13, 2023
1 parent d10dee2 commit 7dbc636
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: xcms
Version: 3.21.0
Version: 3.21.1
Title: LC-MS and GC-MS Data Analysis
Description: Framework for processing and visualization of chromatographically
separated and single-spectra mass spectral data. Imports from AIA/ANDI NetCDF,
Expand Down
13 changes: 11 additions & 2 deletions R/functions-XCMSnExp.R
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,19 @@ dropGenericProcessHistory <- function(x, fun) {
object, rt = range(peakArea[, c("rtmin", "rtmax")]) + c(-2, 2))
object <- filterMsLevel(object, msLevel)
if (!length(object)) {
message("FAIL: no MS level ", msLevel, " data available.")
message("FAIL: no data available for the requested m/z - rt range.")
return(res)
}
spctr <- spectra(object, BPPARAM = SerialParam())
## Issue #653: empty spectra is not supported; this is the same fix applied
## to matchedFilter peak detection.
spctr <- lapply(spctr, function(z) {
if (!length(z@mz)) {
z@mz <- 0.0
z@intensity <- 0.0
}
z
})
mzs <- lapply(spctr, mz)
vps <- lengths(mzs)
ints <- unlist(lapply(spctr, intensity), use.names = FALSE)
Expand Down Expand Up @@ -475,7 +484,7 @@ dropGenericProcessHistory <- function(x, fun) {
mass <- brks[-length(brks)] + bin_half ## midpoint for the breaks
mass_range <- range(mass)

for (i in 1:nrow(res)) {
for (i in seq_len(nrow(res))) {
rtr <- peakArea[i, c("rtmin", "rtmax")]
mzr <- peakArea[i, c("mzmin", "mzmax")]
## Ensure that the rt region is within the rtrange of the data.
Expand Down
7 changes: 7 additions & 0 deletions inst/NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Changes in version 3.21.1
----------------------

- Fix error with `fillChromPeaks` on sparse data (many empty spectra) and peak
detection performed with `MatchedFilterParam` (issue #653).


Changes in version 3.19.2
----------------------

Expand Down

0 comments on commit 7dbc636

Please sign in to comment.