Skip to content

Commit

Permalink
Changes to documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Sep 9, 2019
1 parent 1ee7368 commit d319701
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 35 deletions.
37 changes: 24 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,28 @@
PyMassSpec
************

.. image:: https://travis-ci.org/domdfcoding/pymassspec.svg?branch=master
:target: https://travis-ci.org/domdfcoding/pymassspec
:alt: Build Status
.. image:: https://readthedocs.org/projects/pymassspec/badge/?version=latest
:target: https://pymassspec.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://img.shields.io/pypi/v/pymassspec.svg
:target: https://pypi.org/project/pymassspec/
:alt: PyPI
.. image:: https://img.shields.io/pypi/pyversions/pymassspec.svg
:target: https://pypi.org/project/pymassspec/
:alt: PyPI - Python Version
.. image:: https://coveralls.io/repos/github/domdfcoding/pymassspec/badge.svg?branch=master
:target: https://coveralls.io/github/domdfcoding/pymassspec?branch=master
:alt: Coverage


A Python toolkit for processing of chromatography--mass spectrometry data

PyMassSpec is a Python_ package for processing gas chromatography-mass spectrometry data.
PyMassSpec provides a framework and a set of components for rapid development and testing of methods for processing of chromatography--mass spectrometry data.
PyMassSpec can be used interactively through the Python shell, or the functions can be collected into scripts and run non-interactively when it is preferable to perform data processing in the batch mode.

PyMassSpec consists of modules which are loaded when needed,
and different functions are completely decoupled from one another.
If desired, new functions (such as a test or prototype of a new algorithm)
can be implemented efficiently and ensuring that this will not break any
existing functionality.

PyMassSpec can be used interactively through the Python shell, or the functions can be collected into scripts when it is preferable to perform data processing in the batch mode.

|
Expand Down Expand Up @@ -104,8 +114,10 @@ First the raw data is loaded:
>>> jcamp_file = "data/gc01_0812_066.jdx"
>>> data = JCAMP_reader(jcamp_file)
-> Reading JCAMP file 'Data/gc01_0812_066.jdx'
>>> data
<pyms.GCMS.Class.GCMS_data at 0x7f3ec77da0b8>

The intensity matrix object is then built by binning:
The intensity matrix object is then built by binning the data:

>>> from pyms.IntensityMatrix import build_intensity_matrix_i
>>> im = build_intensity_matrix_i(data)
Expand All @@ -126,17 +138,16 @@ and tophat baseline correction:
... ic_base = tophat(ic_smooth, struct="1.5m")
... im.set_ic_at_index(ii, ic_base)

The resulting noise and baseline corrected ion chromatogram is saved
back into the intensity matrix.
The resulting noise and baseline corrected ion chromatogram is saved back into the intensity matrix.

Further examples can be found in the `documentation`_

Contributing
==============

Contributions are very welcome. Tests can be run with `pytest`_. Please
ensure the coverage stays at least the same before you submit a pull
request.
ensure the coverage is at least .. image:: https://coveralls.io/repos/github/domdfcoding/pymassspec/badge.svg?branch=master
before you submit a pull request.

For further information see the section `Contributing to PyMassSpec`_

Expand Down
1 change: 1 addition & 0 deletions UserGuide/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
author = u'PyMassSpec Developers'
copyright = __copyright__
language = 'en'
nitpicky = True

extensions = [
'sphinx.ext.intersphinx',
Expand Down
38 changes: 24 additions & 14 deletions UserGuide/gcms_data_derived_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ The default intensity matrix can be built as follows:

>>> from pyms.IntensityMatrix import build_intensity_matrix
>>> im = build_intensity_matrix(data)
>>> im
<pyms.IntensityMatrix.IntensityMatrix at 0x7f999eedabe0>

The size as the number of scans and the number of bins is returned by:

Expand Down Expand Up @@ -135,8 +137,7 @@ the binned mass closest to the desired mass. For example, the index of the
closest binned mass to a mass of 73.3 :math:`m/z` can be found by using the
methods :meth:`im.get_index_of_mass() <pyms.IntensityMatrix.get_index_of_mass>`:

>>> index = im.get_index_of_mass(73.3)
>>> print(index)
>>> im.get_index_of_mass(73.3)
23

The value of the closest mass can be returned by the method
Expand Down Expand Up @@ -170,8 +171,7 @@ different binning.

>>> index = im.get_index_of_mass(73.3)
>>> im.get_mass_at_index(index)

A mass of 73.5 is returned in this example.
73.5

Build integer mass intensity matrix
------------------------------------
Expand All @@ -188,9 +188,8 @@ units. The function is imported from :mod:`pyms.IntensityMatrix`:
The masses are now integers.

>>> index = im.get_index_of_mass(73.3)
>>> print(im.get_mass_at_index(index))

A mass of 73 is returned in this example.
>>> im.get_mass_at_index(index)
73

The lower and upper bounds can be adjusted by
:meth:`build_intensity_matrix_i(data, lower, upper) <pyms.IntensityMatrix.build_intensity_matrix_i>`
Expand All @@ -211,9 +210,13 @@ For example, the properties of the first MassSpectrum object of an
:class:`~pyms.IntensityMatrix.IntensityMatrix`, ``im``, can be obtained with;

>>> ms = im.get_ms_at_index(0)
<pyms.Spectrum.MassSpectrum at 0x7f999d210940>
>>> len(ms)
1101
>>> len(ms.mass_list)
1101
>>> len(ms.mass_spec)
1101

The length of all attributes should be the same.

Expand All @@ -232,8 +235,11 @@ An :class:`~pyms.IonChromatogram.IonChromatogram` for the
TIC and a given mass or index can be obtained as follows:

>>> data.tic
<pyms.IonChromatogram.IonChromatogram at 0x7f99a27bd320>
>>> im.get_ic_at_index(0)
<pyms.IonChromatogram.IonChromatogram at 0x7f999d220400>
>>> im.get_ic_at_mass(73)
<pyms.IonChromatogram.IonChromatogram at 0x7f999d246fd0>

This will return, respectively: the TIC; the ion chromatogram of the first
mass; and the ion chromatogram of the mass closest to 73.
Expand All @@ -242,10 +248,10 @@ An ion chromatogram object has a method
:meth:`is_tic() <pyms.IonChromatogram.IonChromatogram.is_tic>`
which returns ``True`` if the ion chromatogram is a TIC, ``False`` otherwise:

>>> print("'tic' is a TIC:", tic.is_tic())
'tic' is a TIC: True
>>> print("'ic' is a TIC:",ic.is_tic())
'ic' is a TIC: False
>>> tic.is_tic()
True
>>> ic.is_tic()
False

Writing IonChromatogram object to a file
--------------------------------------------
Expand Down Expand Up @@ -294,6 +300,13 @@ For example,

>>> from pyms.Utils.IO import save_data
>>> mat = im.intensity_array
array([[22128., 0., 10221., ..., 0., 470., 0.],
[22040., 0., 10335., ..., 408., 0., 404.],
[21320., 0., 10133., ..., 492., 0., 422.],
...,
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.],
[ 0., 0., 0., ..., 0., 0., 0.]])
>>> save_data("output/im.dat", mat)

It is also possible to save the list of masses (from
Expand Down Expand Up @@ -340,11 +353,8 @@ The LECO CSV format data can be imported directly into an `~pyms.IntensityMatrix
.. code-block:: python
>>> from pyms.IntensityMatrix import IntensityMatrix
>>>
>>> iim = IntensityMatrix([0],[0],[[0]])
>>>
>>> iim.import_leco_csv("output/data_leco.csv")
>>>
>>> im.size
>>> iim.size
Expand Down
23 changes: 15 additions & 8 deletions UserGuide/gcms_raw_data_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ Methods
The object ``data`` (from the two previous examples) stores the raw data as a
:class:`~pyms.GCMS.Class.GCMS_data` object. Within the
:class:`~pyms.GCMS.Class.GCMS_data` object, raw data are stored as a list
of :class:`~pyms.Scan.Scan` objects and a list of retention times.
of :class:`~pyms.Spectrum.Scan` objects and a list of retention times.
There are several methods available to access data and attributes of the
:class:`~pyms.GCMS.Class.GCMS_data` and
:class:`~pyms.Scan.Scan` objects.
:class:`~pyms.Spectrum.Scan` objects.

The :class:`~pyms.GCMS.Class.GCMS_data` object's methods relate to the raw data. The main properties
relate to the masses, retention times and scans. For example, the
Expand All @@ -101,6 +101,7 @@ following:
A list of all retention times can be returned by:

>>> data.time_list
[305.582, 305.958, 306.333, 306.70799999999997, 307.084, ...]

The index of a specific retention time (in seconds) can be returned by:

Expand All @@ -115,36 +116,42 @@ returns a total ion chromatogram (TIC) of the data
as an :class:`~pyms.IonChromatogram.IonChromatogram` object:


>>> tic = data.tic
>>> data.tic
<pyms.IonChromatogram.IonChromatogram at 0x7f99a27bd320>

The :class:`~pyms.IonChromatogram.IonChromatogram`
object is explained in a later chapter.

A Scan data object
----------------------

A :class:`~pyms.Scan.Scan`object contains a list of masses and a corresponding list of intensity values from a single mass-spectrum scan in the raw data. Typically only non-zero (or non-threshold) intensities and corresponding masses are stored in the raw data.
A :class:`~pyms.Spectrum.Scan`object contains a list of masses and a corresponding list of intensity values from a single mass-spectrum scan in the raw data. Typically only non-zero (or non-threshold) intensities and corresponding masses are stored in the raw data.
.. note:: The following examples are the same in :ref:`pyms-demo/20a <demo-20a>` and :ref:`pyms-demo/20b <demo-20b>`

A list of all the raw :class:`~pyms.Scan.Scan` objects can be returned with:
A list of all the raw :class:`~pyms.Spectrum.Scan` objects can be returned with:

>>> scans = data.scan_list
>>> scans
[<pyms.Spectrum.Scan at 0x7f999d2209b0>, <pyms.Spectrum.Scan at 0x7f999d220828>, <pyms.Spectrum.Scan at 0x7f999d220390>, ...]

A list of all masses in a scan (e.g. the 1st scan) is returned with:

>>> scans[0].mass_list
[50.099998474121094, 51.099998474121094, 53.099998474121094, ...]

A list of all corresponding intensities in a scan is returned with:

>>> scans[0].intensity_list
[22128.0, 10221.0, 31400.0, 27352.0, 65688.0, ...]

The minimum and maximum mass in an individual scan (e.g. the 1st scan) are
returned with:

>>> scans[0].min_mass
50.099998474121094
>>> scans[0].max_mass
599.4000244140625

Exporting data and obtaining information about a data set
----------------------------------------------------------
Expand Down Expand Up @@ -219,7 +226,7 @@ To compare the two data sets:
.. code-block:: python
>>> from pyms.GCMS.Function import diff
>>> diff(data1,data2)
>>> diff(data1, data2)
Data sets have the same number of time points.
Time RMSD: 1.80e-13
Checking for consistency in scan lengths ... OK
Expand All @@ -234,9 +241,9 @@ will report the difference. For example:
.. code-block:: python
>>> data2.trim(begin=1000,end=2000)
>>> data2.trim(begin=1000, end=2000)
Trimming data to between 1000 and 2000 scans
>>> diff(data1,data2)
>>> diff(data1, data2)
-> The number of retention time points different.
First data set: 9865 time points
Second data set: 1001 time points
Expand Down

0 comments on commit d319701

Please sign in to comment.