Skip to content

Commit

Permalink
fix: add fix for plot,MsExperiment for LC-MS/MS data
Browse files Browse the repository at this point in the history
- Add the fix merged with PR #741 into the devel branch also to the release
  branch.
- The fix addresses the error generated when `plot,MsExperiment` is called on a
  `MsExperiment` with MS1 and MS2 spectra (issue #734).
  • Loading branch information
jorainer committed Jun 7, 2024
1 parent 386bd40 commit 3574486
Show file tree
Hide file tree
Showing 4 changed files with 16 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: 4.2.1
Version: 4.2.2
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
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# xcms 4.2

## Changes in version 4.2.2

- Fix for issue #734: `plot,MsExperiment` is now working with `MsExperiment`
that have also MS2 Data.


## Changes in version 4.2.1

- Fix in `dropFeatureDefinitions()` that was not correctly removing additional
Expand Down
5 changes: 3 additions & 2 deletions R/XcmsExperiment-plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -380,12 +380,13 @@ setMethod(
fns <- basename(fileNames(x))
for (i in seq_along(x)) {
z <- x[i]
lst <- as(filterMsLevel(spectra(z), msLevel = msLevel), "list")
flt <- filterMsLevel(spectra(z), msLevel = msLevel)
lst <- as(flt, "list")
lns <- lengths(lst) / 2
lst <- do.call(rbind, lst)
if (!length(lst))
next
df <- data.frame(rt = rep(rtime(z), lns), lst)
df <- data.frame(rt = rep(rtime(flt), lns), lst)
colnames(df)[colnames(df) == "intensity"] <- "i"
do.call(MSnbase:::.plotXIC,
c(list(x = df, main = fns[i], layout = NULL), dots))
Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test_XcmsExperiment-plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ df <- data.frame(mzML_file = basename(fls),
dataOrigin = fls,
sample = c("ko15", "ko16", "ko18"))
mse <- readMsExperiment(spectraFiles = fls, sampleData = df)
mse_ms2 <- readMsExperiment(msdata::proteomics(full.names=TRUE)[4])
p <- CentWaveParam(noise = 10000, snthresh = 40, prefilter = c(3, 10000))
xmse <- findChromPeaks(mse, param = p)
pdp <- PeakDensityParam(sampleGroups = rep(1, 3))
Expand Down Expand Up @@ -51,3 +52,8 @@ test_that("plot,XcmsExperiment and .xmse_plot_xic works", {
tmp <- filterMz(filterRt(xmse, rt = c(2550, 2800)), mz = c(342.5, 344.5))
plot(tmp)
})

test_that(".xmse_plot_xic works with ms2 data", {
tmp <- filterMz(filterRt(mse_ms2, rt= c(2160, 2190)), mz = c(990,1000))
plot(tmp)
})

0 comments on commit 3574486

Please sign in to comment.