sneumann / xcms

This is the git repository matching the Bioconductor package xcms: LC/MS and GC/MS Data Analysis
Other
183 stars 80 forks source link

xcms adjustRtime OrbiwarpParam on Rapid Polarity Switch Data #506

Open grangel0955 opened 4 years ago

grangel0955 commented 4 years ago

I am getting the following errors when trying to run the following xcms_3.8.2 script on data generated by a Lumos Fusion instrument in rapid polarity switching mode. I separated data on polarity and am focusing on the positive subset (xdata_pos). I have success running the xcms vignette (http://bioconductor.org/packages/3.10/bioc/vignettes/xcms/inst/doc/xcms.html) nearly as-is up until the alignment, when I get this error:

xdata_pos <- adjustRtime(xdata_pos, param = ObiwarpParam(binSize = 0.6, subset=c(6:80))) Sample number 38 used as center sample. Error in (function (x) : attempt to apply non-function Aligning Pool1.mzML against d1c-shld1.mzML ... Found gaps in scan times of the center sample: cut scantime-vector at NA seconds. Found gaps in scan time of file Pool1.mzML: cut scantime-vector at NA seconds. Error in if (rtmaxdiff > (5 * mstdiff)) { : argument is of length zero

The script is as below:

library(xcms) library(RColorBrewer) library(pander) library(magrittr) library(pheatmap) library(SummarizedExperiment) library(MSnbase)

register(SerialParam())

mzMLfiles <- dir(path=".../mzML_files/", full.names = TRUE, recursive = TRUE) pd <- data.frame(sample_name = sub(basename(mzMLfiles), pattern = ".mzML", replacement = "", fixed = TRUE), sample_group = c(rep("Blank", 5), rep("Pool", 7), rep('RBCs', 12), rep("Day0", 3), rep("Day1", 18), rep("Day2", 6), rep("Day3", 6), rep("Day4", 6), rep("Day5", 6), rep("Day6", 3), rep("Day7", 3), rep("Day8", 2), rep('Day9', 3) ), stringsAsFactors = FALSE) raw_data <- readMSData(files = mzMLfiles, pdata = new("NAnnotatedDataFrame", pd), mode = "onDisk", centroided=T ) raw_data_pos <- filterPolarity(raw_data, 1) cwp_pos <- CentWaveParam(peakwidth = c(20, 80), noise = 5000, ppm=70) xdata_pos <- findChromPeaks(raw_data_pos, param = cwp_pos)

samples 1:5 are blanks

xdata_pos <- adjustRtime(xdata_pos, param = ObiwarpParam(binSize = 0.6, subset=c(6:80)))

Any help would be greatly appreciated!

jorainer commented 4 years ago

There are some issues with gaps in retention times in xcms-obiwarp. Some of the problems should have fixed in the more recent version of xcms (3.10.1, which can be installed on R version >= 4 with BiocManager::install("xcms")) - but whether this also fixes the problem you see with your data I don't know.

Alternatively, you could always fall back to the peak groups alignment approach which is more robust against gaps in retention times.