Skip to content

Commit 1d810ae

Browse files
authored
Merge pull request #419 from axelwalter/adduct-detection-tutorial
Adduct detection tutorial
2 parents 64016e7 + 6e9bba5 commit 1d810ae

File tree

5 files changed

+1354
-1
lines changed

5 files changed

+1354
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Adduct Detection
2+
================
3+
4+
In mass spectrometry it is crucial to ionize analytes prior to detection, because they are accelerated and manipulated in electric fields, allowing their separation based on mass-to-charge ratio.
5+
This happens by addition of protons in positive mode or loss of protons in negative mode. Other ions present in the buffer solution can ionize the analyte as well, e.g. sodium, potassium or formic acid.
6+
Depending on the size and chemical compsition, multiple adducts can bind leading to multiple charges on the analyte. In metabolomics with smaller analytes the number of charges is typically low with one or two, whereas in proteomics the number of charges is much higher.
7+
Furthermore, analytes can loose functional groups during ionization, e.g. a neutral water loss.
8+
Since the ionization happens after liquid chromatography, different adducts for an analyte have similar retention times.
9+
10+
.. image:: img/adduct_detection.png
11+
12+
In pyOpenMS, :py:class:`~.MetaboliteFeatureDeconvolution` takes a :term:`feature map` as input adding adduct information as additional meta values. Features belonging to an adduct group will be stored in a :term:`consensus map`. The most important parameters are explained in the comments.
13+
14+
| **Input file generation:**
15+
| The input :term:`feature map` can be obtained using a `feature finder algorithm <feature_detection.html>`_.
16+
17+
| **Suggested follow up step:**
18+
| The resulting feature map can be exported to a pandas DataFrame with adduct information from the *dc_charge_adducts* feature meta values.
19+
| Multiple feature maps can be `combined using the feature linking algorithms <feature_linking.html>`_. Each consensus feature will get a new meta value *best ion* based on the most common annotated adduct within the consensus feature group.
20+
21+
.. code-block:: python
22+
23+
from urllib.request import urlretrieve
24+
import pyopenms as poms
25+
26+
# get example data file with metabolmics feature map
27+
gh = "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master"
28+
urlretrieve(gh + "/src/data/MetaboliteFeatureDeconvolution_input.featureXML", "example.featureXML")
29+
30+
# open example input feature map
31+
feature_map = poms.FeatureMap()
32+
poms.FeatureXMLFile().load("example.featureXML", feature_map)
33+
34+
# initialize MetaboliteFeatureDeconvolution
35+
mfd = poms.MetaboliteFeatureDeconvolution()
36+
37+
# get default parameters
38+
params = mfd.getDefaults()
39+
# update/explain most important parameters
40+
41+
# adducts to expect: elements, charge and probability separated by colon
42+
# the total probability of all charged adducts needs to be 1
43+
# e.g. positive mode:
44+
# proton dduct "H:+:0.6", sodium adduct "Na:+:0.4" and neutral water loss "H-2O-1:0:0.2"
45+
# e.g. negative mode:
46+
# with neutral formic acid adduct: "H-1:-:1", "CH2O2:0:0.5"
47+
# multiples don't need to be specified separately:
48+
# e.g. [M+H2]2+ and double water loss will be detected as well!
49+
# optionally, retention time shifts caused by adducts can be added
50+
# e.g. a formic acid adduct causes 3 seconds earlier elution "CH2O2:0:0.5:-3"
51+
params.setValue("potential_adducts", ["H:+:0.6", "Na:+:0.4", "H-2O-1:0:0.2"])
52+
53+
# expected charge range
54+
# e.g. for positive mode metabolomics:
55+
# minimum of 1, maximum of 3, maximum charge span for a single feature 3
56+
# for negative mode:
57+
# charge_min = -3, charge_max = -1
58+
params.setValue("charge_min", 1, "Minimal possible charge")
59+
params.setValue("charge_max", 3, "Maximal possible charge")
60+
params.setValue("charge_span_max", 3)
61+
62+
# maximum RT difference between any two features for grouping
63+
# maximum RT difference between between two co-features, after adduct shifts have been accounted for
64+
# (if you do not have any adduct shifts, this value should be equal to "retention_max_diff")
65+
params.setValue("retention_max_diff", 3.0)
66+
params.setValue("retention_max_diff_local", 3.0)
67+
68+
# set updated paramters object
69+
mfd.setParameters(params)
70+
71+
# result feature map: will store features with adduct information
72+
feature_map_MFD = poms.FeatureMap()
73+
# result consensus map: will store grouped features belonging to a charge group
74+
groups = poms.ConsensusMap()
75+
# result consensus map: will store paired features connected by an edge
76+
edges = poms.ConsensusMap()
77+
78+
# compute adducts
79+
mfd.compute(feature_map, feature_map_MFD, groups, edges)
80+
81+
# export feature map as pandas DataFrame and append adduct information
82+
df = feature_map_MFD.get_df(export_peptide_identifications=False)
83+
df["adduct"] = [f.getMetaValue("dc_charge_adducts") for f in feature_map_MFD]
84+
85+
# display data
86+
print(df.head())

docs/source/user_guide/export_files_GNPS.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ With pyOpenMS you can automatically generate all files needed for GNPS Feature-B
55
Ion Identity Molecular Networking (IIMN).
66

77
Pre-requisites are your input :term:`mzML` files and a :py:class:`~.ConsensusMap`, generated by an
8-
`untargeted metabolomics pre-processing workflow <metabolomics_preprocessing.html>`_.
8+
`untargeted metabolomics pre-processing workflow <untargeted_metabolomics_preprocessing.html>`_.
99
Ensure that :term:`MS2` data has been mapped to the :py:class:`~.FeatureMap` objects with :py:class:`~.IDMapper`.
1010
For IIMN adduct detection must have been performed on the :py:class:`~.FeatureMap`
1111
objects during pre-processing with :py:class:`~.MetaboliteFeatureDeconvolution`.
Loading

docs/source/user_guide/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ headings and structure.
4646
charge_isotope_deconvolution
4747
feature_detection
4848
map_alignment
49+
adduct_detection
4950
feature_linking
5051
peptide_search
5152
chromatographic_analysis

0 commit comments

Comments
 (0)