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

Alignment of experiment containing BLANKS AND QC #521

Closed Adafede closed 1 year ago

Adafede commented 3 years ago

Hi,

I am having trouble to align my experiment containing blk,qc1, sample...,qc2, sample...,qc3, sample...,...qc6,blk.

initial data: Rplot

When aligning without subset,

dda_data <- adjustRtime(object = dda_data, param = ObiwarpParam(binSize = 0.6))

works very well on samples

Rplot01

although looks nasty for blanks

Rplot03

But when using subsets...

pdp_subs <- PeakDensityParam(
  sampleGroups = dda_data$sample_group,
  binSize = 0.6,
  minFraction = 0.8
)

dda_data <- groupChromPeaks(object = dda_data, param = pdp_subs)

pgp_subs <- PeakGroupsParam(
  minFraction = 0.8,
  subset = which(dda_data$sample_group == "qc"),
  subsetAdjust = "average",
  smooth = "loess",
)

loess fails (I did try to play with the span, no worries)

Rplot05

where linear does quite okayish but not really satisfying

pgp_subs <- PeakGroupsParam(
  minFraction = 0.8,
  subset = which(dda_data$sample_group == qc),
  subsetAdjust = "average",
  smooth = "linear",
)

Rplot04 Rplot02

Any idea?

jorainer commented 3 years ago

The problem you have with PeakGroupsParam is really strange. I guess this is independent of the subset-alignment and you get the same problem with the conventional full data set alignment?

Note that also the ObiwarpParam supports subset-based alignment. So you could try to see what you get with that?

Adafede commented 3 years ago

Oh, nice idea!

Indeed works nicely when wrapped in Obiwarp! I selected all samples except blanks :)

I also tried doing it on MS2 but looks like it is not implemented yet, will it be there soon?

Thanks a lot again!

jorainer commented 3 years ago

MS2 spectra get also adjusted along with the MS1 data (i.e. if you do the alignment in MS1, the retention time of the MS2 spectra gets also adjusted, based on the adjusted MS1 retention times).

Do you have a use case for only MS2 data alignment? I didn't implement because I didn't have the data and the use case...

Adafede commented 3 years ago

I have to admit I am very used to MZmine pipeline and some very MS2 oriented steps (chromatogram building for example) and also aligning based also on MS2 similarity. We had data for which taking into account MS2 similarity greatly lowered "false" alignment... this is why I was asking... it would not be MS2 only but the alignment of MS1 and MS2 based on MS2 (and not MS1)

gmhhope commented 3 years ago

I have to admit I am very used to MZmine pipeline and some very MS2 oriented steps (chromatogram building for example) and also aligning based also on MS2 similarity. We had data for which taking into account MS2 similarity greatly lowered "false" alignment... this is why I was asking... it would not be MS2 only but the alignment of MS1 and MS2 based on MS2 (and not MS1)

@Adafede I think it is a very interesting idea. Could you point me to MS2-oriented alignment in MZmine?

If I understand correctly this is something similar to Peakgroup retention time alignment, though it is using MS2 similarity instead of m/z of MS1 to define the peak group. I assumed that It will be perfect for the targeted method. However, given the limited scan rates of MS2, will the MS2 data points be too sparse for alignment in untargeted metabolomics?

Thanks, Minghao Gong

Adafede commented 3 years ago

Hi @gmhhope, it is not really what you wrote, I probably explained it badly. What I mentioned was sort of an additional filter where you compare the associated MS2 spectra to decide whether to align MS1 peaks or not. Below a certain threshod, you simply do not aigne them even if within the mz/RT window because of their MS2 dissimilarity. Hope it is clearer now, if not I'll try another time!

@jorainer Is there, maybe combining multiple mzR packages and functions, a way to align dda-data and chromatograms (related to https://github.com/lgatto/MSnbase/issues/527)? For example, aligning UV signals together, MS1 together, and then UV-MS1?

jorainer commented 3 years ago

@Adafede : you can align chromatographic data with the alignRt function - but that only allows small shifts between chromatograms. For DDA data, xcms performs the alignment on the MS1 data, but adjusts the MS2 spectra measured in between the MS1 data too. For UV-MS1 - no idea - I'm not at all familiar with that data, sorry.

gmhhope commented 3 years ago

@jorainer

Did you have a user case that has both MS1 and DDA-MS2 data in the same run? I would really like to see how you process the data comparing to the one with only MS1.

Thanks in advance!

Best, Minghao Gong

johanne commented 3 years ago

This was a mistag - please tag the correct person.

jorainer commented 3 years ago

@gmhhope no, I don't have a use case or example workflow. But the alignment algorithms in xcms do the alignment by default always only on the MS1 data and MSn spectra are always adjusted separately based on the aligned MS1 data. There is nothing special the user has to do (or settings that have to be specified) for MS1+MS2 data - it's just like aligning MS1 data alone.