Skip to content

Commit

Permalink
Update spectrum_normalization.rst (#424)
Browse files Browse the repository at this point in the history
This commit enhances the 'Spectrum Normalization' section of the documentation. The changes include:
-Images depicting raw and normalized spectra have been added to provide a clearer understanding of the normalization process.
-The text has been extended with explanations of the normalization techniques and their importance in mass spectrometry data analysis.
-The images have been added to the 'img' directory and are referenced in the documentation using relative paths.
Please review the updates for technical accuracy and clarity.
  • Loading branch information
Ayesha-Feroz authored Nov 22, 2023
1 parent cae748a commit 5fc3503
Showing 1 changed file with 39 additions and 20 deletions.
59 changes: 39 additions & 20 deletions docs/source/user_guide/spectrum_normalization.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
Spectrum Normalization
======================

Another very basic mass spectrum processing step is normalization by base peak intensity (the maximum intensity of a mass spectrum).
Normalization by base peak intensity is a fundamental processing step in mass spectrometry. This method scales the peak intensities in a spectrum such that the highest peak reaches a maximum value, typically set to one. This approach facilitates the comparison of different spectra by standardizing the intensity scale.

Let's first load the raw data.
Loading the Raw Data
--------------------

To begin, we need to load the mass spectrometry data. The following Python code demonstrates how to load a spectrum from an mzML file using the pyOpenMS library.

.. code-block:: python
:linenos:
Expand All @@ -13,20 +16,22 @@ Let's first load the raw data.
import matplotlib.pyplot as plt
gh = "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master"
urlretrieve(
gh + "/src/data/peakpicker_tutorial_1_baseline_filtered.mzML",
"tutorial.mzML",
)
urlretrieve(gh + "/src/data/peakpicker_tutorial_1_baseline_filtered.mzML", "tutorial.mzML")
exp = oms.MSExperiment()
oms.MzMLFile().load("tutorial.mzML", exp)
plt.bar(
exp.getSpectrum(0).get_peaks()[0],
exp.getSpectrum(0).get_peaks()[1],
snap=False,
)
plt.bar(exp.getSpectrum(0).get_peaks()[0], exp.getSpectrum(0).get_peaks()[1], snap=False)
plt.show()
.. image:: img/before_normalization.png
:align: center
:alt: Raw spectrum before normalization

Now we apply the normalization.
Normalization Procedure
-----------------------

After loading the data, the next step is to apply normalization.

.. code-block:: python
:linenos:
Expand All @@ -37,13 +42,27 @@ Now we apply the normalization.
normalizer.setParameters(param)
normalizer.filterPeakMap(exp)
plt.bar(
exp.getSpectrum(0).get_peaks()[0],
exp.getSpectrum(0).get_peaks()[1],
snap=False,
)
plt.bar(exp.getSpectrum(0).get_peaks()[0], exp.getSpectrum(0).get_peaks()[1], snap=False)
plt.show()
.. image:: img/after_normalization.png
:align: center
:alt: Spectrum after normalization

TIC Normalization
-----------------

Another approach to normalization is using the Total Ion Count (TIC). This method adjusts the intensities so that their total sum equals 1.0 in each mass spectrum.

.. code-block:: python
:linenos:
param.setValue("method", "to_TIC")
normalizer.setParameters(param)
normalizer.filterPeakMap(exp)
plt.bar(exp.getSpectrum(0).get_peaks()[0], exp.getSpectrum(0).get_peaks()[1], snap=False)
plt.show()
Another way of normalizing is by TIC (total ion count) of the mass spectrum, which scales intensities
so they add up to :math:`1.0` in each mass spectrum.
Try it out for yourself by setting: ``param.setValue("method", "to_TIC")``.
.. image:: img/after_normalization_TIC.png
:align: center
:alt: Spectrum after TIC normalization

0 comments on commit 5fc3503

Please sign in to comment.