Skip to content

Commit

Permalink
fix many glossary terms (#331)
Browse files Browse the repository at this point in the history
* Update .github/workflows/flakeheaven.yml

* added packages

* fix many glossary terms

* added blacken-docs

* testing blacken-docs

* testing blacken-docs

* testing blacken-docs

* testing action suggester

* testing action suggester

* testing action suggester

* remove additional file commits

* added run step for blacken-docs

* testing action-suggester with flakeheaven

* updated glossary

* updated glossary references

* added :chem: role

* changed chem_role setup

* merge from master branch

* removed m/z & peak from glossary

* removed additional lower level glossary terms

* merged master branch

* added missinge linenos

* changed indentation

* merge with master

* chagend tsv separator to t

* use other suggestion action

* Update code-blocks-linting.yaml

---------

Co-authored-by: matteopilz <[email protected]>
  • Loading branch information
jpfeuffer and matteopilz authored Feb 24, 2023
1 parent 4d9551d commit 0068b5c
Show file tree
Hide file tree
Showing 48 changed files with 858 additions and 787 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/code-blocks-linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ jobs:
exit 1
fi
- name: Run action-suggester
- name: Run action-suggester (only works on lines that were changes in this PR)
uses: reviewdog/action-suggester@v1
with:
tool_name: blacken-docs

- name: Display diff and fail if there was anything changed by blacken-docs
run: |
git diff --diff-algorithm histogram --exit-code
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
docs/source/_autosummary/
docs/source/_build/
docs/build/
docs/source/_autosummary
15 changes: 15 additions & 0 deletions docs/source/_ext/chemrole.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from docutils.nodes import math


def chem_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
latex = rf'\ce{{{text}}}'
node = math(rawtext, latex, **options)
return [node], []


def setup(app):
"""Install the plugin.
:param app: Sphinx application context.
"""
app.add_role('chem', chem_role)
return {'parallel_read_safe': True}
3 changes: 2 additions & 1 deletion docs/source/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ pattern are :py:class:`~.GaussFilter`, :py:class:`~.SavitzkyGolayFilter` as well
:py:class:`~.ParentPeakMower`, :py:class:`~.Scaler`, :py:class:`~.SpectraMerger`, :py:class:`~.SqrtMower`,
:py:class:`~.ThresholdMower`, :py:class:`~.WindowMower`.

Using the same example file as before, we can execute a GaussFilter on our test data as follows:
Using the same example file as before, we can execute a :py:class:`~.GaussFilter` on our test data as follows:

.. code-block:: python
:linenos:
from pyopenms import *
from urllib.request import urlretrieve
Expand Down
246 changes: 143 additions & 103 deletions docs/source/background.rst

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/source/build_from_source.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Build from source
Build from Source
==================

To install pyOpenMS from :index:`source`, you will first have to compile OpenMS
Expand All @@ -12,7 +12,7 @@ following software packages
On Microsoft Windows: you need the 64 bit C++ compiler from Visual Studio 2015
to compile the newest pyOpenMS for Python 3.5, 3.6 or 3.7. This is important,
else you get a clib that is different than the one used for building the Python
executable, and pyOpenMS will crash on import. The OpenMS wiki has `detailed information
executable, and pyOpenMS will crash on import. The OpenMS wiki has `detailed information
<https://github.com/OpenMS/OpenMS/wiki/Build-pyOpenMS-on-Windows>`_
on building pyOpenMS on Windows.

Expand Down Expand Up @@ -43,7 +43,7 @@ that the correct Python executable is used. Compiling pyOpenMS can use a lot of
memory and take some time, however you can reduce the memory consumption by
breaking up the compilation into multiple units and compiling in parallel, for
example ``-DPY_NUM_THREADS=2 -DPY_NUM_MODULES=4`` will build 4 modules with 2
threads. You can then configure pyOpenMS:
threads. You can then configure pyOpenMS:

.. code-block:: bash
Expand All @@ -59,7 +59,7 @@ Afterwards, test that all went well by running the tests:
Which should execute all the tests and return with all tests passing.

Further questions
Further Questions
*****************

In case the above instructions did not work, please refer to the `Wiki Page
Expand Down
20 changes: 10 additions & 10 deletions docs/source/centroiding.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Centroiding
===========

MS instruments typically allow storing spectra in profile mode (several data points per m/z peak)
or in the more codensed centroid mode (one data point per m/z peak). The process of converting
a profile spectrum into a centroided one is called peak centroiding or peak picking.
or in the more condensed centroid mode (one data point per m/z peak). The process of converting
a profile mass spectrum into a centroided one is called peak centroiding or peak picking.

Note: The term peak picking is ambiguous as it is also used for feature detection (i.e. 3D "peak" finding).
Note: The term peak picking is ambiguous as it is also used for features detection (i.e. 3D peak finding).

First, we load some profile data:

.. code-block:: python
:linenos:
from urllib.request import urlretrieve
from pyopenms import *
import matplotlib.pyplot as plt
Expand All @@ -24,21 +24,21 @@ First, we load some profile data:
Let's zoom in on an isotopic pattern in profile mode and plot it.

.. code-block:: python
:linenos:
plt.xlim(771.8, 774) # zoom into isotopic pattern
plt.plot(
profile_spectra[0].get_peaks()[0], profile_spectra[0].get_peaks()[1]
) # plot the first spectrum
.. image:: img/profile_data.png

Because of the limited resolution of MS instruments m/z measurements are not of unlimited precision.
Consequently, peak shapes spreads in the m/z dimension and resemble a gaussian distribution.
Using the PeakPickerHiRes algorithm, we can convert data from profile to centroided mode. Usually, not much information is lost
Because of the limited resolution of MS instruments m/z measurements are not of unlimited precision.
Consequently, peak shapes spreads in the m/z dimension and resemble a gaussian distribution.
Using the :py:class:`~.PeakPickerHiRes` algorithm, we can convert data from profile to centroided mode. Usually, not much information is lost
by storing only centroided data. Thus, many algorithms and tools assume that centroided data is provided.

.. code-block:: python
:linenos:
centroided_spectra = MSExperiment()
# input, output, chec_spectrum_type (if set, checks spectrum type and throws an exception if a centroided spectrum is passed)
Expand All @@ -52,6 +52,6 @@ by storing only centroided data. Thus, many algorithms and tools assume that cen
) # plot as vertical lines
.. image:: img/centroided_data.png

After centroding, a single m/z value for every isotopic peak is retained. By plotting the centroided data as stem plot
After centroiding, a single m/z value for every isotopic peak is retained. By plotting the centroided data as stem plot
we discover that (in addition to the isotopic peaks) some low intensity peaks (intensity at approx. 4k) were present in the profile data.

Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,28 @@ Charge and Isotope Deconvolution

A single mass spectrum contains measurements of one or more analytes and the
m/z values recorded for these analytes. Most analytes produce multiple signals
in the mass spectrometer, due to the natural abundance of carbon 13 (naturally
occurring at ca. 1% frequency) and the large amount of carbon atoms in most
in the mass spectrometer, due to the natural abundance of carbon :math:`13` (naturally
occurring at ca. :math:`1%` frequency) and the large amount of carbon atoms in most
organic molecules, most analytes produce a so-called isotopic pattern with a
monoisotopic peak (all carbon are C12) and a first isotopic peak (exactly one
carbon atom is a C13), a second isotopic peak (exactly two atoms are C13) etc.
monoisotopic peak (all carbon are :chem:`^{12}C`) and a first isotopic peak (exactly one
carbon atom is a :chem:`^{13}C`), a second isotopic peak (exactly two atoms are :chem:`^{13}C`) etc.
Note that also other elements can contribute to the isotope pattern, see the
`Chemistry section <chemistry.html>`_ for further details.
`chemistry section <chemistry.html>`_ for further details.

In addition, each analyte may appear in more than one charge state and adduct
state, a singly charge analyte ``[M+H]+`` may be accompanied by a doubly
charged analyte ``[M+2H]++`` or a sodium adduct ``[M+Na]+``. In the case of a
state, a singly charge analyte :chem:`[M +H]+` may be accompanied by a doubly
charged analyte :chem:`[M +2H]++` or a sodium adduct :chem:`[M +Na]+`. In the case of a
multiply charged peptide, the isotopic traces are spaced by ``PROTON_MASS /
charge_state`` which is often close to 0.5 m/z for doubly charged analytes,
0.33 m/z for triply charged analytes etc. Note: tryptic peptides often appear
charge_state`` which is often close to :math:`0.5\ m/z` for doubly charged analytes,
:math:`0.33\ m/z` for triply charged analytes etc. Note: tryptic peptides often appear
at least doubly charged, while small molecules often carry a single charge but
can have adducts other than hydrogen.

Single peak example
*******************
Single Peak Example
*********************************

.. code-block:: python
:linenos:
from pyopenms import *
Expand All @@ -50,10 +51,11 @@ Note that the algorithm presented here as some heuristics built into it, such
as assuming that the isotopic peaks will decrease after the first isotopic
peak. This heuristic can be tuned by changing the parameter
``use_decreasing_model`` and ``start_intensity_check``. In this case, the
second isotopic peak is the highest in intensity and the
second isotopic peak is the highest in intensity and the
``start_intensity_check`` parameter needs to be set to 3.

.. code-block:: python
:linenos:
charge = 4
seq = AASequence.fromString("DFPIANGERDFPIANGERDFPIANGERDFPIANGER")
Expand Down Expand Up @@ -93,7 +95,7 @@ second isotopic peak is the highest in intensity and the
print(p.getMZ(), p.getIntensity())
Full spectral de-isotoping
Full Spectral De-Isotoping
**************************

In the following code segment, we will use a sample measurement of BSA (Bovine
Expand All @@ -102,6 +104,7 @@ mass spectrum, which means grouping peaks of the same isotopic pattern charge
state:

.. code-block:: python
:linenos:
from urllib.request import urlretrieve
Expand Down Expand Up @@ -155,35 +158,35 @@ which produces the following output
974.4572680576728 6200571.5
974.4589691256419 3215808.75
As we can see, the algorithm has reduced 140 peaks to 41 deisotoped peaks. It
also has identified a molecule at 974.45 m/z as the most intense peak in the
data (basepeak).
As we can see, the algorithm has reduced :math:`140` peaks to :math:`41` deisotoped peaks. It
also has identified a molecule at :math:`974.45\ m/z` as the most intense peak in the
data (base peak).

Visualization
*************

The reason we see two peaks very close together becomes apparent
once we look at the data in TOPPView which indicates that the 974.4572680576728
peak is derived from a 2+ peak at m/z 487.73 and the peak at 974.4589691256419
is derived from a 3+ peak at m/z 325.49: the algorithm has identified a single
once we look at the data in :term:`TOPPView` which indicates that the :math:`974.4572680576728`
peak is derived from a :chem:`2+` peak at m/z :math:`487.73` and the peak at :math:`974.4589691256419`
is derived from a :chem:`3+` peak at m/z :math:`325.49`: the algorithm has identified a single
analyte in two charge states and deconvoluted the peaks to their nominal mass
of a ``[M+H]+`` ion, which produces two peaks very close together (2+ and 3+
of a :chem:`[M +H]+` ion, which produces two peaks very close together (:chem:`2+` and :chem:`3+`
peak):

.. image:: img/deisotoped_zoom.png

Looking at the full spectrum and comparing it to the original spectrum, we can see the
original (centroided) spectrum on the top and the deisotoped spectrum on the
bottom in blue. Note how hovering over a peak in the deisotoped spectrum
Looking at the full mass spectrum and comparing it to the original mass spectrum, we can see the
original (centroided) mass spectrum on the top and the deisotoped mass spectrum on the
bottom in blue. Note how hovering over a peak in the deisotoped mass spectrum
indicates the charge state:

.. image:: img/deisotoped.png

In the next section, we will look at 2-dimensional deisotoping where instead of
a single spectrum, multiple spectra from a :term:`LC-MS` experiments are analyzed
In the next section (`Feature Detection <feature_detection.html>`_), we will look at 2-dimensional deisotoping where instead of
a single mass spectrum, multiple mass spectra from a :term:`LC-MS` experiment are analyzed
together. There algorithms analyze the full 2-dimensional (m/z and RT) signal
and are generally more powerful than the 1-dimensional algorithm discussed
here. However, not all data is 2 dimensional and the algorithm discussed here
has many application in practice (e.g. single mass spectra, fragment ion
spectra in DDA etc.).
mass spectra in DDA etc.).

Loading

0 comments on commit 0068b5c

Please sign in to comment.