ipb-halle / MetFragR

R package for MetFrag
24 stars 14 forks source link

Specifying Ionization Mode #14

Closed nalden01 closed 7 years ago

nalden01 commented 8 years ago

Hello, I had a question regarding the run.metfrag function and specifying the ionization mode. On the MetFrag web application, we are allowed to select the Mode ([M+H], [M-H] or [M]) and the charge (pos. or neg).

In the run.metfrag function, I noticed that one of the settings that can be specified is PrecursorIonMode which I learned through trial-and-error can be set to 0, 1 or 2. I assume these integers correspond to the different modes, but I can't find information on which is which. For example, what value corresponds to [M+H]?

I also noticed that in the Java package there is a setting "IsPositiveIonMode", but I can't find if that setting is available in the R package. If not, how do I specify whether the samples were run in positive or negative mode?

Best, Nick

c-ruttkies commented 8 years ago

Hi, you can find a short summary of important parameters in the supplemental material of the latest MetFrag publication: https://static-content.springer.com/esm/art%3A10.1186%2Fs13321-016-0115-9/MediaObjects/13321_2016_115_MOESM1_ESM.xls For PrecursorIonMode you can set 1, -1, 0 ([M+H], [M-H] or [M]). The R package uses the same Java library like the commandline version, so you can also set IsPositiveIonMode. Best regards, Christoph

nalden01 commented 8 years ago

Thanks Christoph, When I attempt to set IsPositiveIonMode, I get the following error:

"Unknown type of parameter IsPositiveIonMode ( logical )"

I've also tried setting the value to an integer (0 or 1) or a string ("True", "False"), but I get the error:

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean

Is there something I'm missing?

nalden01 commented 8 years ago

Looking through the source code, I think the error lies on line 78: else if(class(value) == "logical") {return("boolean")}

On line 108, there is the check: else if(getDatatype(name, settingsObject[[name]]) == "logical") { .jcall(javaSettings, "V", 'set', name, .jnew("java.lang.Boolean", as.logical(settingsObject[[name]]))) }

Since getDataType returns "boolean", none of the cases are met and the condition on line 124 is run:

else { print(paste("Unknown type of parameter", name, "(", class(settingsObject[[name]]), ")")) }

c-ruttkies commented 8 years ago

Hey, thanks for reporting this issue. I have updated the R package (v2.0.2), so this should be fixed now. I ran some tests which worked fine for me. In case you find some more problems, just let me know.

Best regards, Christoph

xiaodfeng commented 3 years ago

This is useful disscussion, thanks.