MassBank / RMassBank

Playground for experiments on the official http://bioconductor.org/packages/devel/bioc/html/RMassBank.html
Other
12 stars 15 forks source link

[M-2H]2- Adduct bug #284

Open lauperbe opened 3 years ago

lauperbe commented 3 years ago

I came across a bug for Spectra of Adducts [M-2H]2-. MWE is attached.

The compound with ID 4339 has the formula: C8H4Cl2N2O7S2 The [M-2H]2- ion has a monoisotopic mass of 185.934572, which can be clearly seen in the raw file.

The error occurs during the msmsRead() function. The based on the list here: https://github.com/MassBank/RMassBank/blob/1d078a8f9d5625e1a4000329d78ddb1c9c4445b6/R/leCsvAccess.R#L359 mode="m2H_c2" should be what is needed for the [M-2H]2- Adduct.

during the msmsRead() function the error "assignment of an object of class “NULL” is not valid for @‘polarity’ in an object of class “Spectrum1”; is(value, "integer") is not TRUE" occurs.

Additionally the warning "In findMsMsHR.mass(msRaw, mz, mzCoarse, limit.fine, rtLimits, confirmMode + : No precursor was detected for compound, 4339 with m/z 371.869144923819. Please check the mass and retention time window." appears. The m/z 371.8691 is the m/z of the [M-2H]- ion, indicating that due to the error above it assumes a charge state of 1.

Thank you in advance Benedikt

MWE including .mzXML files can be found here since they are too big for upload: https://polybox.ethz.ch/index.php/s/VTpjPDD43KAjbHU MWE_M2H.zip

sneumann commented 3 years ago

Kudos for providing the MWE! The ZIP is missing 202101_023_4339_ChlorothalonilTPR419492.mzXML, could you upload that as well somewhere ? Yours, Steffen

lauperbe commented 3 years ago

The mzXML file are in the polyboxlink since they are to big to be directly uploaded. https://polybox.ethz.ch/index.php/s/VTpjPDD43KAjbHU

sneumann commented 3 years ago

Darn, hadn't realised that was two separate links and hit the wrong one :-( I can confirm the error class “NULL” is not valid for @‘polarity’ and the warning No precursor was detected for compound ... on RMassBank_2.99.4 and 3.1.0. Yours, Steffen

meowcat commented 3 years ago

I have a parser that builds all data required for mz calculation directly from arbitrary adduct strings, and handles multiple charges correctly.

https://gist.github.com/meowcat/1df7c1b10002029d39bc2b8fd70e0b18

Should we eventually move to this? The only thing we still would need are a map from mode to adductString. We could think about dropping the "mode" and only using adductstrings directly, but having a non-special-character descriptor is not so bad for e.g. building filenames. Perhaps the "mode" could also be derived automatically? Or it can have a few standard values and the other are user-defined?

Note that this requires tidyverse packages. This would add a few dependencies but also allow to rewrite some code in leMsMs.R that currently awkwardly does what dplyr would easily do.

Note: doubly-charged fragments are not handled correctly by analyzeFormula for now, I think!