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

adduct type #324

Open
cbroeckl opened this issue May 22, 2024 · 1 comment
Open

adduct type #324

cbroeckl opened this issue May 22, 2024 · 1 comment

Comments

@cbroeckl
Copy link

i am working on storing some MS/MS data in Spectra objects. I was interested in storing the adduct type, so ideally when this is exported to msp or mgf (or other) that adduct type is exported with the MS/MS data. Is there a slot for this that has a defined name? Thanks.
Corey

@jorainer
Copy link
Member

we generally store the information as a spectra variable "adduct". Then, for export to e.g. MGF it depends a bit into which "field" you want the information to be written. We have a parameter mapping that allows to specify the mapping between spectra variables and the fields in the MGF for both data import and export.

The parameter takes a named character, names being the spectra variable names and the values the name of the "field" in the MGF. An example could be:

mms <- c(
    rtime = "RTINSECONDS",
    acquisitionNum = "SCANS",
    precursorMz = "PEPMASS",
    precursorIntensity = "PEPMASSINT",
    precursorCharge = "CHARGE",
    spectrum_id = "TITLE",
    compound_name = "COMPOUND_NAME",
    adduct = "ADDUCT",
    smiles = "SMILES",
    inchi = "INCHI",
    inchikey = "INCHIKEY",
    ms_mass_analyzer = "MS_MASS_ANALYZER",
    ionization = "MS_IONISATION",
    exactmass = "PARENT_MASS",
    collisionEnergy = "COLLISION_ENERGY",
    ms_manufacturer = "MS_MANUFACTURER",
    ms_dissociation_method = "MS_DISSOCIATION_METHOD"
)

This is how I currently load information from the matchms cleaned GNPS MGF files. If your Spectra object has a spectra variable $adduct the information will be written as ADDUCT: with the value of the $adduct variable for that specific spectrum into the MGF. You see that there are also a lot of other mappings and variables. If your Spectra object does not provide these, the data will simply not exported (same for the import), i.e. you can provide mappings also for variables that you don't have.

To use this mms you would call e.g.

s <- Spectra("my-mgf-file.mgf", source = MsBackendMgf(), mapping = mms)

And to write this information to MGF you would call:

export(s, backend = MsBackendMgf(), mapping = mms)

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

2 participants