sneumann / xcms

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

Rare "non-numeric matrix extent" error in obiwarp #6

Closed sneumann closed 6 years ago

sneumann commented 10 years ago

Yashwant Kumar <y.kumar at ncl.res.in>reported:

During obiwrap step, I am getting following error for few samples however others are running well: 

Processing: DVC4_1_1T_POS  Found gaps: cut scantime-vector at  0.558566 seconds 
changing 0 num_internal_anchors to -1 DVC4_1_2T_POS  Found gaps: cut scantime-vector at  0.828551 seconds 
Error in matrix(0, seqlen, dim(obj2@env$profile)[2]) : 
  non-numeric matrix extent

This requires more information and a reproducible example.

ghost commented 9 years ago

Hi Steffen We have been experiencing a similar error after recent upgrade of our Agilent Acquisition software. I can provide you with more information and samples.

Processing: 005-MIX Found gaps: cut scantime-vector at 5.399 seconds Found gaps: cut scantime-vector at 103.227 seconds Error in matrix(0, seqlen, dim(obj1@env$profile)[2]) : non-numeric matrix extent

best Martin

ma-bio21 commented 9 years ago

Also seeing this issue for the first time just recently.

center sample: pbqc_701-72081.mzdata Processing: E-1_701-24723.mzdata Found gaps: cut scantime-vector at 12.66 seconds Found gaps: cut scantime-vector at 9 seconds changing 0 num_internal_anchors to -1 E-2_701-24724.mzdata Found gaps: cut scantime-vector at 12.66 seconds Found gaps: cut scantime-vector at 8.7 seconds changing 0 num_internal_anchors to -1 E-3_701-24725.mzdata Found gaps: cut scantime-vector at 12.66 seconds Found gaps: cut scantime-vector at 5.7 seconds Error in matrix(0, seqlen, dim(obj1@env$profile)[2]) : non-numeric matrix extent

Thought this might be due to the scans with no intensity information, and possibly this is true, but we have data where these gaps appear and no errors were reported.

Call to retcor is: xs_align <- retcor(xset, method= "obiwarp", center= align_ref, plottype= "deviation", profStep= 0.1, distFunc= "cor_opt", response=2, gapInit=1, gapExtend=2.4 )

Thanks, Sean

sneumann commented 9 years ago

Hi, could you provide me with a minimalistic test case ? Can you reproduce with just two files ? Then I'd like to ask for the files and a code snippet. Yours, Steffen

ma-bio21 commented 9 years ago

Hi Steffen,

Playing around with the issue, I get two different errors depending on which files I use in a two file example. Either I get the same issue as the one above, or another one:

center sample: E-2_701-24724.mzdata Processing: E-1_701-24723.mzdata Found gaps: cut scantime-vector at 8.7 seconds Found gaps: cut scantime-vector at 9 seconds terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc Aborted (core dumped)

I can provide three files along with code snippets which can replicate these two errors when used in different combinations. How do you want me to share this with you?

Sean

sneumann commented 9 years ago

Hi, whatever works best for you, we can do google drive, dropbox, or services like wetransfer.com. Yours, Steffen

ma-bio21 commented 9 years ago

Dropbox it is! https://www.dropbox.com/sh/w3nehcomwi2je35/AACcjKKglHLs3e3e-4KFmqima?dl=0

Hopefully you can replicate the error.

Thanks, Sean

carlamerino commented 6 years ago

Hello everyone,

I am having the same problem now. I would like to know if the problem has any solution, because I cannot pass retcor - obiwarp step.

Thanks, Carla

jorainer commented 6 years ago

could you please provide some more information? please post the output of your sessionInfo, the calls that lead to your error and also the error message.

carlamerino commented 6 years ago

Hello,

This is the problem that appears, but sometimes the R session aborted because R encountered a fatal error:

xset2 <- retcor(xset,method="obiwarp",profStep=0.1)#RT alignment center sample: QC Processing: A1 Found gaps: cut scantime-vector at 2.966 seconds Found gaps: cut scantime-vector at 7.987 seconds Error in matrix(0, seqlen, dim(obj1@env$profile)[2]) : non-numeric matrix extent

My sessionInfo is: R version 3.4.4 (2018-03-15) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

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

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

other attached packages: [1] xcms_3.0.2 MSnbase_2.4.2 ProtGenerics_1.10.0 mzR_2.12.0 Rcpp_0.12.13
[6] BiocParallel_1.12.0 Biobase_2.38.0 BiocGenerics_0.24.0

loaded via a namespace (and not attached): [1] pillar_1.2.1 compiler_3.4.4 BiocInstaller_1.28.0 RColorBrewer_1.1-2
[5] plyr_1.8.4 iterators_1.0.9 tools_3.4.4 zlibbioc_1.24.0
[9] MALDIquant_1.17 digest_0.6.15 tibble_1.4.2 preprocessCore_1.40.0 [13] gtable_0.2.0 lattice_0.20-35 rlang_0.2.0 Matrix_1.2-12
[17] foreach_1.4.4 yaml_2.1.18 S4Vectors_0.16.0 IRanges_2.12.0
[21] multtest_2.34.0 stats4_3.4.4 grid_3.4.4 impute_1.52.0
[25] snow_0.4-2 survival_2.41-3 XML_3.98-1.10 RANN_2.5.1
[29] limma_3.34.9 ggplot2_2.2.1 MASS_7.3-49 splines_3.4.4
[33] scales_0.5.0 pcaMethods_1.70.0 codetools_0.2-15 MassSpecWavelet_1.44.0 [37] mzID_1.16.0 colorspace_1.3-2 affy_1.56.0 lazyeval_0.2.1
[41] munsell_0.4.3 doParallel_1.0.11 vsn_3.46.0 affyio_1.48.0

I have tried with several PC, and the error appeared in all of them.

Thanks, Carla

jorainer commented 6 years ago

Would you mind trying the new interface and methods? I've fixed the new obiwarp functions but was not able to fix the original one. So eventually this problem might have been fixed.

What you would have to do is:

## Read the data; fls should be the names (including path) of the input files
raw_data <- readMSData(fls, mode = "onDisk")

## Just convert the object so that you can immediately call obiwarp
raw_data <- as(raw_data, "XCMSnExp")

## Perform the obiwarp alignment with your settings (profstep/binSize = 0.1
obi_data <- adjustRtime(raw_data, param = ObiwarpParam(binSize = 0.1))
carlamerino commented 6 years ago

Hello,

Thank you for your answer. I was reading about the new version and I would like to know if I use what you replied me I have to change all the scrip in order to finish the data processing with the new version of xcms. I found the steps to execute it here: https://bioconductor.org/packages/3.7/bioc/vignettes/xcms/inst/doc/xcms.html#7_further_data_processing_and_analysis.

Thanks, Carla

jorainer commented 6 years ago

You are using R-3.4.4, so you should use https://bioconductor.org/packages/release/bioc/vignettes/xcms/inst/doc/xcms.html (there are some minor differences to the newest developmental version you have linked above).

If you are sticking with the new interface, you should do the chromatographic peak detection after reading the data (and before the adjustRtime call above, also, then you don't need the as(raw_data, "XCMSnExp") call). For the chromatographic peak detection use the findChromPeaks method on the raw_data object with the corresponding parameter class and your settings.

Note that you can switch to the old classes/functions at any stage by simply calling

xset <- as(new_data, "xcmsSet")

where new_data is the new object you get with e.g. findChromPeaks, and xset the old xcmsSet object.

carlamerino commented 6 years ago

Hello again,

Thank you for your recommendations. I decided to try the new version of xcms. I was following the steps of the new version without any problem ... until alignment step. After execute the next function, a problem appears:

xdata <- adjustRtime(xdata, param = ObiwarpParam(binSize = 0.6))

Sample number 13 used as center sample. Error in binYonX(mz, int, breaks = brks, fromIdx = fromIdx, toIdx = toIdx, : 'fromIdx' and 'toIdx' have to be >= 0!

However, there is no problem when I try with the data from the faahKO package.

Please, do you have any idea of what could be happening?

Thank you, Carla

jorainer commented 6 years ago

Dear Carla,

could be that there is some problem with one of your files. Could you please subset the data to pairs of files and retry on those in order to see for which files it fails? One of the files should always be the file number 13 because obiwarp aligned against that one.

raw_data <- readMSData(fls, mode = "onDisk")

## Subset the object to e.g. files 1 and 13
xdata <- filterFile(raw_data, c(1, 13))

## Just convert the object so that you can immediately call obiwarp
xdata <- as(xdata, "XCMSnExp")

## Perform the obiwarp alignment with your settings (profstep/binSize = 0.6 and 
## specify centerSample 2 to use the file number 13 from the original object.
obi_data <- adjustRtime(xdata, param = ObiwarpParam(binSize = 0.6, centerSample = 2))
carlamerino commented 6 years ago

Dear Johannes,

Thank you for your answer, but It didn't work. Do you thing that the problem could be with the method that I used for data storage, which is both centroid and profile? I converted the file in ProteoWizard and xcms online with the same converted files worked perfectly, but not with xcms in R. I don't know what else the problem may be.

Best, Carla

jorainer commented 6 years ago

Using the centroided files should be OK, don't use the profile-mode file with xcms. Ideally I would need hands on your data, but that is obviously difficult - especially if it is a large data set. That's also why I wanted you above to try pairwise obiwarp on two files only to see if you could nail it down to 2 files. From there it would be much easier to go on and try to debug.

carlamerino commented 6 years ago

Even trying by pairs it didn't work. The same error came up: Error in binYonX(mz, int, breaks = brks, fromIdx = fromIdx, toIdx = toIdx, : 'fromIdx' and 'toIdx' have to be >= 0!

Thank you

carlamerino commented 6 years ago

Hello,

I might know what is happening with my data, but I do not have any solution yet. We started the masa acquisition from 60 seconds till the end. During the first 60 seconds I do not have any m/z data. That might be the problem in the adjustRtime step. I would like to know how I could not take into account the first 60 seconds for data analysis.

Thank you. Best, Carla

jmbadia commented 6 years ago

It seems that the reason is because during the first 60 secons the measurements have a 0 value with 0 m/z values associated. When the alignment function findChromPeaks() tries to do binning, it cannot understand 0 as a minimum & maximum m/z value to be used for binning. I guess that's the reason. You can test the findChromPeaks() function with the same rawdata with its first 70 seconds remved (using the filterRt() function)

jorainer commented 6 years ago

@jmbadia is right, you can simply remove the first 60 seconds from your measurements with the filterRt function. Assuming xdata is your MS data you read with readMSData:

xdata <- filterRt(xdata, rt = c(60, max(rtime(xdata))))

Eventually you might have to increase the lower retention time range if the problem still persists.

carlamerino commented 6 years ago

Thank you both of you. I decided to start at 64 seconds and it works.

jorainer commented 6 years ago

Closing the issue now - feel free to reopen if necessary