sneumann / xcms

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

Backward compatibility issue 3.0.0 -> 3.4.1 #347

Closed lecorguille closed 5 years ago

lecorguille commented 5 years ago

Issue

Ok! I found enough time to have a look at this error message with fillChromPeaks

> xdata <- fillChromPeaks(xdata)
Defining peak areas for filling-in .... OK
Start integrating peak areas from original files
Requesting 4252 missing peaks from ko15.CDF ... got 1558.
Requesting 4140 missing peaks from ko16.CDF ... got 1435.
Requesting 4251 missing peaks from wt15.CDF ... got 1436.
Requesting 4218 missing peaks from wt16.CDF ... got 1538.
Error in sprintf(paste0("CP", "%0", ceiling(log10(toId + 1L)), "d"), (maxId +  :
  negative length vectors are not allowed
In addition: Warning messages:
1: In max(as.numeric(sub("^CP", "", rownames(chromPeaks(object))))) :
  no non-missing arguments to max; returning -Inf
2: In paste0("CP", "%0", ceiling(log10(toId + 1L)), "d") : NaNs produced

I suspect a problem of retrocompatibility

The test script

library(xcms)
cdfs <- dir(system.file("cdf", package = "faahKO"), full.names = TRUE,
        recursive = TRUE)
cdfs <- cdfs[c(1,2,7,8)]
pd <- data.frame(
        sample_name = sub(basename(cdfs), pattern = ".CDF",
        replacement = "", fixed = TRUE),
        sample_group = c(rep("KO", 2), rep("WT", 2)),
        stringsAsFactors = FALSE)
raw_data <- readMSData(files = cdfs, pdata = new("NAnnotatedDataFrame", pd),
        mode = "onDisk")
cwp <- CentWaveParam()
xdata <- findChromPeaks(raw_data, param = cwp)

xcms_3.4.2

> head(rownames(chromPeaks(xdata)))
[1] "CP0001" "CP0002" "CP0003" "CP0004" "CP0005" "CP0006"

xcms_3.0.0

> head(rownames(chromPeaks(xdata)))
NULL

Start of explanation of my error message

I used to launch tool individually for my functional test. No problemo until fillChromPeaks. But when I fed the fillChromPeaks.3.4.2 with an output from groupChromPeaks.3.0.0, it fails.

jorainer commented 5 years ago

Should be fixed now in RELEASE_3_8 version. To install you would have to call devtools::install_github("sneumann/xcms", ref = "RELEASE_3_8").

lecorguille commented 5 years ago

To get the update, I create a temporary conda package : https://anaconda.org/workflow4metabolomics/bioconductor-xcms You will agree that it's better than the copy/paste hack :)

But:

> xdata <- fillChromPeaks(xdata, param=fillChromPeaksParam)
Defining peak areas for filling-in .
... OK
Start integrating peak areas from original files
Requesting 4252 missing peaks from ko15.CDF ... got 1558.
Requesting 4140 missing peaks from ko16.CDF ... got 1435.
Requesting 4251 missing peaks from wt15.CDF ... got 1436.
Requesting 4218 missing peaks from wt16.CDF ... got 1538.
Warning message:
In if (idx_rt_adj > idx_pk_det) { :
  the condition has length > 1 and only the first element will be used

and

> print(xdata)
MSn experiment data ("XCMSnExp")
Object size in memory: 1.36 Mb
- - - Spectra data - - -
 MS level(s): 1
 Number of spectra: 5112
 MSn retention times: 41:33 - 75:0 minutes
- - - Processing information - - -
Concatenated [Thu Feb  8 15:36:09 2018]
 MSnbase version: 2.4.2
- - - Meta data  - - -
phenoData
  rowNames: ./ko15.CDF ./ko16.CDF ./wt15.CDF ./wt16.CDF
  varLabels: sample_name sample_group
  varMetadata: labelDescription
Loaded from:
  [1] ko15.CDF...  [4] wt16.CDF
  Use 'fileNames(.)' to see all files.
protocolData: none
featureData
  featureNames: F1.S0001 F1.S0002 ... F4.S1278 (5112 total)
  fvarLabels: fileIdx spIdx ... spectrum (27 total)
  fvarMetadata: labelDescription
experimentData: use 'experimentData(object)'
- - - xcms preprocessing - - -
Chromatographic peak detection:
Error in ph[[1]] : subscript out of bounds
jorainer commented 5 years ago

Aaaaah. Well, I have to check again into the code...

jorainer commented 5 years ago

So, the xdata is still an XCMSnExp object from an older xcms release, right?

lecorguille commented 5 years ago

Yes, from a 3.0.0++ version

jorainer commented 5 years ago

As always - by adding the fix I created a new bug. I propose an alternative solution: I've now added a function updateObject that can be used to update/upgrade objects created with a previous version. You would have to call:

xdata <- updateObject(xdata)

after loading your original, old, object. Could you please report back if that worked (just get the xcms from the RELEASE_3_8 branch).

lecorguille commented 5 years ago

It did the trick! Thanks a lot.