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

Regarding the steps of operating FillChromPeaksParam #754

Open v-v1150n opened 3 months ago

v-v1150n commented 3 months ago

The following are the steps I took to analyze GC-MS. When it comes to FillChromPeaksParam, this function requires the use of XCMSnExp objects. The objects I use in the fifth step will be XcmsExperiment objects. I don’t know if there is any way to handle the conversion of objects, or Are there any suggestions for optimization steps?

# 1.Mass detection
raw_path <- "/Users/v_v1150n/Desktop/EBC/DISEASE_cdf/20140327_B-169_S041_1.cdf"
raw_data <- readMsExperiment(spectraFiles = raw_path)
cwp <- CentWaveParam(peakwidth = c(5, 20), 
                     noise = 500,
                     prefilter = c(3, 100),
                     snthresh = 10,
                     mzCenterFun = "wMean",
                     integrate = 1,
                     fitgauss = FALSE,
                     )
xdata <- findChromPeaks(raw_data, param = cwp)

# 2.ADAP Chromatogram Builder (GC-MS)
adap_param <- CentWaveParam(
  peakwidth = c(5, 20),
  noise = 1000,
  prefilter = c(3, 1000),
  snthresh = 10,
  mzCenterFun = "wMean",
  integrate = 1,
  fitgauss = FALSE,
  mzdiff = 0.001,
  ppm = 30
)
xdata <- findChromPeaks(raw_data, param = adap_param)

# 3.ADAP Feature Resolver
cwt_param <- CentWaveParam(
  peakwidth = c(5, 40),
  noise = 500,
  snthresh = 4,
  mzdiff = 0.001,
  integrate = 1,
  fitgauss = FALSE,
  mzCenterFun = "wMean",
  prefilter = c(3, 1000),
  ppm = 30
)
xdata <- findChromPeaks(raw_data, param = cwt_param)

# 4.Multivariate Curve Resolution
mcr_param <- PeakDensityParam(
  sampleGroups = c(1),
  minFraction = 0.5,
  bw = 0.2,
  minSamples = 1,
  binSize = 0.05
)
xdata <- groupChromPeaks(xdata, param = mcr_param)

# 5.ADAP Alignment
align_param <- ObiwarpParam(
  binSize = 0.3,
  response = 1,
  distFun = "cor_opt",
  gapInit = 0.3,
  gapExtend = 2.4,
  factorDiag = 2,
  factorGap = 1,
  localAlignment = FALSE
)
xdata <- adjustRtime(xdata, param = align_param)

# 6.Gap filling
fill_param <- FillChromPeaksParam(ppm = 5)
xdata <- fillChromPeaks(xdata, param = fill_param)
jorainer commented 2 months ago

Which versions of the packages are you using? could be that you use an old version of xcms.

v-v1150n commented 2 months ago

My xcms package version is:

packageVersion("xcms") [1] ‘4.3.1’

jorainer commented 2 months ago

I see, no, indeed, you are right. The use of FillChromPeaksParam is no longer supported with XcmsExperiment. This method notoriously underestimated the gap-filled data, thus it is highly suggested to use the ChromPeakAreaParam instead, that integrates the data from the m/z-rt ranges of the actually identified chromatographic peaks.

But note that I have also just recently implemented the possibility to change from a XcmsExperiment to XCMSnExp object - if you really want to apply the old method. This can be done with xdata <- as(xdata, "XCMSnExp") after installing the current xcms version from my branch (i.e. using BiocManager::install("sneumann/xcms", ref = "jomain").