Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decomposeMass only supports CHNOPS #5

Open
cbielow opened this issue Mar 3, 2016 · 3 comments
Open

decomposeMass only supports CHNOPS #5

cbielow opened this issue Mar 3, 2016 · 3 comments

Comments

@cbielow
Copy link

cbielow commented Mar 3, 2016

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
Copy link

jalic commented Apr 25, 2016

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
Copy link
Owner

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.

@janlisec
Copy link
Contributor

Issue solved in PR #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants