sneumann / xcms

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

troubles with groupChromPeaks on CentWave MS2 peak detection & creating diffreport once everything ok #512

Closed CLechaplais closed 3 years ago

CLechaplais commented 3 years ago

Hello, I would like to use quite my usual xcms pipeline in order to get a diffreport for the ms2 data. I get 2 different problems.

--First one I can't use the groupChromPeaks function after using centWave on MS2 level. I get a message error :
"Error in peaks[1, "mz"] : indice hors limites De plus : Warning messages: 1: In max(peaks[, "sample"]) : aucun argument pour max ; -Inf est renvoyé 2: In min(x) : aucun argument trouvé pour min ; Inf est renvoyé 3: In max(x) : aucun argument pour max ; -Inf est renvoyé"

Here what I do, it is my usual xcms pipeline set with modified values to be sure to get my ms2 signal :

setwd("/env/cns/proj/spectro/XCMS-Tof/AcAc-MS2/") datapath <- getwd() datafiles<-list.files(datapath, pattern=".mzXML", recursive=TRUE, full.names=TRUE) datafiles [1] "/env/export/spectro/XCMS-Tof/AcAc-MS2/AcAc-0microM.mzXML" [2] "/env/export/spectro/XCMS-Tof/AcAc-MS2/AcAC-100microM.mzXML" [3] "/env/export/spectro/XCMS-Tof/AcAc-MS2/AcAC-10microM.mzXML" [4] "/env/export/spectro/XCMS-Tof/AcAc-MS2/AcAC-25microM.mzXML" [5] "/env/export/spectro/XCMS-Tof/AcAc-MS2/AcAC-50microM.mzXML" [6] "/env/export/spectro/XCMS-Tof/AcAc-MS2/AcAC-75microM.mzXML" pd <- data.frame(sample_name = sub(basename(datafiles), pattern = ".mzXML",replacement = "", fixed = TRUE), sample_group = c(rep("serie1",3), rep("serie2", 3)), stringsA> pd sample_name sample_group 1 AcAc-0microM serie1 2 AcAC-100microM serie1 3 AcAC-10microM serie1 4 AcAC-25microM serie2 5 AcAC-50microM serie2 6 AcAC-75microM serie2 raw_data <- readMSData(files = datafiles, pdata = new("NAnnotatedDataFrame", pd),mode = "onDisk") cwp <- CentWaveParam(ppm=5000, peakwidth=c(5,60), snthresh=1, prefilter=c(3,1), mzdiff=1, fitgauss=FALSE, noise=1) resultsCW <- findChromPeaks(raw_data, param=cwp,msLevel=2L, BPPARAM=bpparam()) Detecting mass traces at 5000 ppm ... OK Detecting chromatographic peaks in 19567 regions of interest ... OK: 57 found. Detecting mass traces at 5000 ppm ... OK Detecting chromatographic peaks in 18907 regions of interest ... OK: 66 found. Detecting mass traces at 5000 ppm ... OK Detecting chromatographic peaks in 19033 regions of interest ... OK: 82 found. Detecting mass traces at 5000 ppm ... OK Detecting chromatographic peaks in 18836 regions of interest ... OK: 82 found. Detecting mass traces at 5000 ppm ... OK Detecting chromatographic peaks in 19007 regions of interest ... OK: 77 found. Detecting mass traces at 5000 ppm ... OK Detecting chromatographic peaks in 19018 regions of interest ... OK: 76 found. chromPeakSpectra(resultsCW) Spectra with 29 spectra and 1 metadata column(s): msLevel rtime peaksCount | peak_id

| CP003.F1.S0447 2 201.674 98 | CP003 CP003.F1.S0452 2 203.924 95 | CP003 CP003.F1.S0453 2 204.316 101 | CP003 CP003.F1.S0457 2 206.115 62 | CP003 CP003.F1.S0458 2 206.634 77 | CP003 ... ... ... ... . ... CP372.F6.S0523 2 236.618 116 | CP372 CP372.F6.S0527 2 238.428 77 | CP372 CP372.F6.S0528 2 238.821 119 | CP372 CP372.F6.S0532 2 240.688 99 | CP372 CP372.F6.S0533 2 241.148 128 | CP372

Then I'm sure I've got my ms2 detection for the mz I'm looking for :

EIC_ms2 <- chromatogram(filterMsLevel(resultsCW, 2), mz = c(200.1,200.2), rt = c(680, 720), msLevel = 2) plot(EIC_ms2) image

But when I try to follow my usual xcms pipeline with peakgrouping :

pdp<- PeakDensityParam(sampleGroups=resultsCW$sample_group, bw=30, minFraction=0, minSamples=1, binSize=1, maxFeatures=50) resultsCW_group1 <- groupChromPeaks(resultsCW, param=pdp) Error in peaks[1, "mz"] : indice hors limites De plus : Warning messages: 1: In max(peaks[, "sample"]) : aucun argument pour max ; -Inf est renvoyé 2: In min(x) : aucun argument trouvé pour min ; Inf est renvoyé 3: In max(x) : aucun argument pour max ; -Inf est renvoyé

I've tried this pipeline with the "TripleTOF-SWATH/PestMix1_DDA.mzML" data and it works well, so I guess I'm doing something wrong with my own data.

--Second problem (using the "TripleTOF-SWATH/PestMix1_DDA.mzML" data this time in order to check if my pipeline works) I can't convert my XCMSnExp object into a xcmsSet one in order to create a diffreport.

pd <- data.frame(sample_name = sub(basename(datafiles), pattern = ".mzXML",replacement = "", fixed = TRUE), sample_group = c(rep("serie1",1)), stringsAsFactors = FALSE) > pd sample_name sample_group 1 PestMix1_DDA.mzML serie1 raw_data <- readMSData(files = datafiles, pdata = new("NAnnotatedDataFrame", pd),mode = "onDisk") resultsCW <- findChromPeaks(raw_data, param = cwp) Detecting mass traces at 10 ppm ... OK Detecting chromatographic peaks in 101 regions of interest ... OK: 99 found. pdp<- PeakDensityParam(sampleGroups=resultsCW$sample_group, bw=30, minFraction=0, minSamples=1, binSize=1, maxFeatures=50) resultsCW_group1 <- groupChromPeaks(resultsCW, param=pdp) Processing 996 mz slices ... OK xset <- as(resultsCW_group1,"xcmsSet") Error in asMethod(object) : Coercing an XCMSnExp with MS level > 1 is not yet supported!

Are there some solutions to my both problems please?

Thanks

Christophe

jorainer commented 3 years ago

Just to be sure that I understand: you want to do a chromatographic peak detection on MS2 data and then perform a correspondence analysis grouping these MS2 chromatographic peaks? I'm just confused, because for the second example you perform the chromatographic peak detection on MS1 data.

I have actually never tried that before, but if you want to do a correspondence analysis of MS2 chromatographic peaks you should also specify msLevel = 2L in the groupChromPeaks call.

For the second problem: the xcmsSet has only very limited support for MS > 1 data, thus it is at present not possible to convert a XCMSnExp with MS1 and MS2 data to a xcmsSet.

CLechaplais commented 3 years ago

Oh, yes I did a mistake concerning the 2nd example, I did MS1 peak detection. I just quickly tried to do centWave msLevel=2 on these and can't detect peaks.

In fact, I want to integrate MS2 peaks for few mz across many samples. We've got isomeres coeluting exactly at the same time but giving different MS2 EICs. So, if we want to be able to measure the quantity of the one we're interested with we need to get the area for the MS2 fragment peaks. That's why since many days, studying xcms pdf, MSnbase pdf and different topics I try to find a way to do that. I thought about doing quite my usual xcms pipeline for that in order to finally get a diffreport with the integrated area values for the MS2 chromatographic peaks for all our samples.

I already have tried to specify msLevel = 2L in the groupChromPeaks but I get an error message :

resultsCW_group1 <- groupChromPeaks(resultsCW, param=pdp, msLevel=2L) Error in .local(object, param, ...) : Currently only peak grouping on MS level 1 is supported

CLechaplais commented 3 years ago

I asked to our system team to install a more recent R version on our servers, now I got r/4.0.2 and it solved my issue with msLevel=2L while calling groupChromPeaks.

jorainer commented 3 years ago

Closing this issue now - feel free to re-open if needed @CLechaplais