rickhelmus / patRoon

Workflow solutions for mass-spectrometry based non-target analysis.
https://rickhelmus.github.io/patRoon/
GNU General Public License v3.0
58 stars 17 forks source link

Swath acquisition #109

Open Boris-Droz opened 2 months ago

Boris-Droz commented 2 months ago

Hi Rick, I am wonder if patroon as a tool for swath acquisition deconvolution? If not do yo plan to integrate one tool? If not again do you have any strategy or thing that I can try to implement one.

Thank you very much

Boris

rickhelmus commented 2 months ago

Hi Boris,

This and DIA in general is on the 'long-term TODO list', so at the moment not really supported. We mainly use DDA data here, but I have gotten quite some DIA requests lately. OpenMS has OpenSWATH, which might make sense to integrate at some moment perhaps, but I didn't really study it deeply so far. There are more tools out there to align DIA data, but again I don't have experience with these yet.

I am always open to PRs though ;-)

Boris-Droz commented 2 months ago

Hi Rick,

That will be great to have such king of DIA Swath tools in the package are they are existing for OpenMS (a you say) and XCMS (we are more XCMS user here).

We are already looking forward to see the next version of the package.

Best

Boris

Boris-Droz commented 2 months ago

Hi Rick, Sorry for this re-openning. I just discussed with some colleagues about a project where I am involved and where we have swath data. So, do you think that it will be potentially an option to implement a XCMS reconstruction for MS2 into patRoon or outside PatRoon and then re-injecting the result in the workflow? Or should I look for a completely separate worflow?

Thank you for the answer

rickhelmus commented 1 month ago

Hi Boris,

Sorry from my late reply, just came back from holidays!

I gave it some more thoughts, and perhaps we can find a way to make use of the XCMS DIA data handling.

In principle, patRoon should be able to load all the MS/MS data, it's just not able (yet) to correlate the fragments to the right features. So I was thinking of the following approach:

  1. Perform a patRoon workflow and get the features as usual through XCMS.
  2. Convert the patRoon objects to XCMS objects with getXCMSnExp()
  3. Let XCMS do its magic for SWATH
  4. Get the peak lists with patRoon. I think you can just set precursorMzWindow to the SWATH window size. If this for some reason fails (please let me know), then you could also set it to NULL.
  5. Use the delete() function to remove any mass peaks not present in the XCMS spectra data.
  6. Continue with patRoon as usual.

The tricky part is step 5: here somehow we need to find the right spectral data for each feature group from patRoon, e.g. in pseudocode:

mslists <- delete(mslists, j = function(pl, grp, ana, type) {
    # pl is a single peak list (data.table with mz, intensity, ...)
    # grp is the name of the feature group
    # ana is the analysis (NULL if the peak lists is for the whole feature group)
    # type is MS or MSMS

    if (type != "MSMS")
        return(TRUE) # don't delete any peaks in MS data

    # some function that needs to be implemented, and will return a table from the XCMS DIA spectrum
    plXCMS <- getXCMSSpec(grp, ana)

    pl <- data.table::copy(pl)
    # mark all mass peaks that are within the XCMS spectrum as well (5 mDa tolerance)
    pl[, inXCMS := any(abs(mz - plXCMS$mz) <= 0.005)]

    return(pl$inXCMS == FALSE) # and remove all others
})

So what we need is to somehow cookup the getXCMSSpec() function from the example above. I have zero experience with XCMS/SWATH (thanks for letting me know it exists ;-), so perhaps you could give this an initial go?

Thanks, Rick