sneumann / Rdisop

This is the git repository matching the Bioconductor package Rdisop: Decomposition of Isotopic Patterns
4 stars 7 forks source link

decomposeMass only supports CHNOPS #5

Open cbielow opened 8 years ago

cbielow commented 8 years ago

decomposition of CHNOPS works

m = getMolecule("H")
decomposeMass(m$exactmass, elements="H", maxElements = "H")

sodium however does not (in two ways) 1)

m = getMolecule("Na")   ## this works
decomposeMass(m$exactmass, elements="Na", maxElements = "Na")

fails with: Error in decomposeIsotopes(c(mass), c(1), ppm = ppm, mzabs = mzabs, elements = elements, : Exception: Na was not found in alphabet!

2) this returns an empty result:

decomposeMass(m$exactmass, elements="Na")

(I guess because maxElements is 0 by default, but a warning would be good)

Same is true for other elements like Cl, Li, which are common adducts Lipidomics.

jalic commented 8 years ago

Hi Chris, the problem is not maxElements but that you need to initialize the allowed elements up front if different from CHNOPS. Try this: m = getMolecule("Na") decomposeMass(m$exactmass, elements=initializeElements(c("C","Na"))) Don't try it without the "C" though. :) Bests [jan]

sneumann commented 5 years ago

Thanks Jan, that's indeed the correct solution. If either one of you could add a PR to add that to the manpage, that would be great. Yours, Steffen

You can compose your own set of elements:
initializeElements(c("C", "H", "N", "O", "P", "S", "Na"))

While at it, you could mention the minElements usage better,

decomposeMass(46.04186) will give you ethanol, 
while decomposeMass(46.04186, minElements="C3") 
gives no results. 

decomposeMass(46.04186, minElements="C1") gives the reult again,
while decomposeMass(46.04186, minElements="C1H7") the expected empty result.