sneumann / xcms

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

obiwarp error - Found gaps: cut scantime-vector #242

Open karlfraser opened 6 years ago

karlfraser commented 6 years ago

Hi,

I am processing 550 files from a Q-Exactive lipidomics experiment where data dependent MS/MS data was collected. I only want to use the MS1 data to generate a peak area data matrix. I have converted the files to centroid MS1 data (mzML files) only using proteowizard and get an error when processing with xcms. It performs the xset command perfectly, but fails when I run the obiwrap command for alignment, I get the following error:

"> xs.grp.rt <- retcor.obiwarp(xs.grp, plottype = "deviation") center sample: 20150226_NP-ve_064 Processing: 20141212_NP-ve_004 Create profile matrix with method 'bin' and step 1 ... OK Create profile matrix with method 'bin' and step 1 ... OK 20141212_NP-ve_015 Create profile matrix with method 'bin' and step 1 ... OK 20141212_NP-ve_027 Create profile matrix with method 'bin' and step 1 ... OK Create profile matrix with method 'bin' and step 1 ... OK Found gaps: cut scantime-vector at 245.289 seconds 20141212_NP-ve_038 Create profile matrix with method 'bin' and step 1 ... OK Found gaps: cut scantime-vector at 245.4391 seconds Error in .local(object, ...) : Dimensions of profile matrices do not match !"

It seems to only get a few files in each time, and if I remove some files it still fails but on different files. I don't understand this error. We process thousands of samples with xset and orbiwrap (generally but not always collected in MS1 only) and this is the only time I have had this error. Any idea what is happening and how I can get around this problem?

Many thanks Karl PS: system info is:

print(sessionInfo()) R version 3.4.2 (2017-09-28) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale: [1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 LC_MONETARY=English_New Zealand.1252 [4] LC_NUMERIC=C LC_TIME=English_New Zealand.1252

attached base packages: [1] parallel stats graphics grDevices utils datasets methods base

other attached packages: [1] multtest_2.34.0 snow_0.4-2 CAMERA_1.34.0 xcms_3.0.0 MSnbase_2.4.0 ProtGenerics_1.10.0 [7] mzR_2.12.0 Rcpp_0.12.13 BiocParallel_1.12.0 Biobase_2.38.0 BiocGenerics_0.24.0

loaded via a namespace (and not attached): [1] splines_3.4.2 lattice_0.20-35 colorspace_1.3-2 htmltools_0.3.6 stats4_3.4.2
[6] base64enc_0.1-3 vsn_3.46.0 XML_3.98-1.9 survival_2.41-3 RBGL_1.54.0
[11] rlang_0.1.2 foreign_0.8-69 affy_1.56.0 RColorBrewer_1.1-2 affyio_1.48.0
[16] foreach_1.4.3 plyr_1.8.4 stringr_1.2.0 mzID_1.16.0 zlibbioc_1.24.0
[21] munsell_0.4.3 pcaMethods_1.70.0 gtable_0.2.0 htmlwidgets_0.9 codetools_0.2-15
[26] knitr_1.17 latticeExtra_0.6-28 IRanges_2.12.0 doParallel_1.0.11 BiocInstaller_1.28.0
[31] MassSpecWavelet_1.44.0 preprocessCore_1.40.0 htmlTable_1.9 acepack_1.4.1 backports_1.1.1
[36] checkmate_1.8.5 scales_0.5.0 limma_3.34.0 S4Vectors_0.16.0 Hmisc_4.0-3
[41] graph_1.56.0 gridExtra_2.3 RANN_2.5.1 impute_1.52.0 ggplot2_2.2.1
[46] digest_0.6.12 stringi_1.1.5 grid_3.4.2 tools_3.4.2 magrittr_1.5
[51] lazyeval_0.2.1 tibble_1.3.4 Formula_1.2-2 cluster_2.0.6 pkgconfig_2.0.1
[56] MASS_7.3-47 Matrix_1.2-11 data.table_1.10.4-3 iterators_1.0.8 MALDIquant_1.16.4
[61] rpart_4.1-11 igraph_1.1.2 nnet_7.3-12 compiler_3.4.2

sneumann commented 6 years ago

Hi, thanks for the very detailed report. This has come up earlier in https://github.com/rietho/IPO/issues/43 and some excellent discussion in https://github.com/sneumann/xcms/issues/194 If you can try the new interface (see http://bioconductor.org/packages/3.7/bioc/vignettes/xcms/inst/doc/new_functionality.html) and it works there, I think we should start deprecating obiwarp in the old interface. Yours, Steffen

jorainer commented 6 years ago

This problem might have been fixed in the new user interface. I've rewritten and simplified the obiwarp function for this new user interface.

The new interface is based on classes from the MSnbase package and it would thus also be straight forward to do the MS1 sub-setting directly in R. Assuming that you have a vector with file names files and a data.frame phenod with the phenotypical description of your samples (i.e. group assignment etc):

library(xcms)
## Read the data; will actually not read the full data but only metadata info
raw <- readMSData(files, pdata = new("NAnnotatedDataFrame", phenod), mode = "onDisk")

## Optionally subset to MS1 only
raw <- filterMsLevel(raw, msLevel = 1L)

## Define the settings for the centwave peak detection
cwp <- CentWaveParam(<your settings>)
xdata <- findChromPeaks(raw, param = cwp)

## Obiwarp.
xdata <- adjustRtime(xdata, param = ObiwarpParam())

Let me know if you get also the same error with the new function.

karlfraser commented 6 years ago

That has solved it thank you very much. Just one more follow up question. How would I go about using diffreport on this as this seems to be using XCMSnEXP rather than xcmsSet?? Any help or a small bit of example code for this newer version would be much appreciated.

Kind Regards Karl

jorainer commented 6 years ago

Personally, I'd like users to perform a differential abundance analysis using tools that are available outside of xcms (e.g. using the limma package, or plain R functions) - one simply needs the feature matrix, whether the data comes from microarray, RNAseq or metabolomics doesn't really matter in the end. This adds more flexibility, allows for more complex experimental designs etc.

Alternatively, you can coerce the XCMSnExp into an xcmsSet. Assuming your XCMSnExp is called xdata: xset <- as(xdata, "xcmsSet"). This should work.

miriamreverter commented 2 years ago

Hi,

I am trying to process untargeted metabolomics data acquired with a Waters Synapt-G2-Si Q-TOF. The data was acquired using MSe mode, but I was interested in obtaining the feature matrix only for MS1, so I transformed my files using ProteoWizard to MS1 mzml files.

When I try to align the files I encounter the following error in all my files: xdata <- adjustRtime(xdata, param = ObiwarpParam()) Reverting retention times of identified peaks to original values ... OK Sample number 2 used as center sample. Aligning 20211107_QC_P01.mzML against 20211107_QC_P02.mzML ... Error in (function (x) : attempt to apply non-function Found gaps in scan times of the center sample: cut scantime-vector at 1.20900001374 seconds.

print(sessionInfo()) R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19042)

Do you know how could I solve or get around the problem? Thanks in advance,

Miriam

jorainer commented 2 years ago

One thing you could try is to call xdata <- filterEmptySpectra(xdata) before the adjustRtime call. For some data sets that can help.

Alternatively, you might want to try the PeakGroupsParam-based alignment instead? That one should work for sure for any data set.