pyms.Peak
¶
Functions for modelling signal peaks.
pyms.Peak.Class
¶
Provides a class to model signal peak.
Classes:
|
Models a signal peak. |
|
Subclass of |
|
Subclass of |
-
class
AbstractPeak
(rt=0.0, minutes=False, outlier=False)[source]¶ Bases:
pymsBaseClass
Models a signal peak.
- Parameters:
- Authors:
Vladimir Likic, Andrew Isaac, Dominic Davis-Foster (type assertions and properties), David Kainer (outlier flag)
New in version 2.3.0.
Attributes:
Return the unique peak ID (UID), either:
The area under the peak.
The peak boundaries in points.
Returns a copy of the ion areas dict.
The retention time of the peak, in seconds.
Methods:
__eq__
(other)Return whether this Peak object is equal to another object.
dump
(file_name[, protocol])Dumps an object to a file through
pickle.dump()
.get_ion_area
(ion)Returns the area of a single ion chromatogram under the peak.
make_UID
()Create a unique peak ID (UID).
set_bounds
(left, apex, right)Sets peak boundaries in points.
set_ion_area
(ion, area)Sets the area for a single ion.
-
property
UID
¶ Return the unique peak ID (UID), either:
Integer masses of top two intensities and their ratio (as
Mass1-Mass2-Ratio*100
); orthe single mass as an integer and the retention time.
- Return type:
- Returns:
UID string
- Author:
Andrew Isaac
-
__eq__
(other)[source]¶ Return whether this Peak object is equal to another object.
- Parameters:
other – The other object to test equality with.
- Return type:
-
property
bounds
¶ The peak boundaries in points.
-
dump
(file_name, protocol=3)¶ Dumps an object to a file through
pickle.dump()
.
-
property
ion_areas
¶ Returns a copy of the ion areas dict.
- Return type:
- Returns:
The dictionary of
ion: ion area
pairs
-
make_UID
()[source]¶ Create a unique peak ID (UID).
The UID comprises the retention time of the peak to two decimal places. Subclasses may define a more unique ID.
- Author:
Andrew Isaac
-
class
ICPeak
(rt=0.0, mass=None, minutes=False, outlier=False)[source]¶ Bases:
AbstractPeak
Subclass of
Peak
representing a peak in an ion chromatogram for a single mass.- Parameters:
- Authors:
Vladimir Likic, Andrew Isaac, Dominic Davis-Foster (type assertions and properties), David Kainer (outlier flag)
New in version 2.3.0.
Attributes:
Return the unique peak ID (UID), either:
The area under the peak.
The peak boundaries in points.
The mass for a single ion chromatogram peak.
Returns a copy of the ion areas dict.
The retention time of the peak, in seconds.
Methods:
__eq__
(other)Return whether this Peak object is equal to another object.
dump
(file_name[, protocol])Dumps an object to a file through
pickle.dump()
.get_ion_area
(ion)Returns the area of a single ion chromatogram under the peak.
make_UID
()Create a unique peak ID (UID):
set_bounds
(left, apex, right)Sets peak boundaries in points.
set_ion_area
(ion, area)Sets the area for a single ion.
-
property
UID
¶ Return the unique peak ID (UID), either:
Integer masses of top two intensities and their ratio (as
Mass1-Mass2-Ratio*100
); orthe single mass as an integer and the retention time.
- Return type:
- Returns:
UID string
- Author:
Andrew Isaac
-
__eq__
(other)[source]¶ Return whether this Peak object is equal to another object.
- Parameters:
other – The other object to test equality with.
- Return type:
-
property
bounds
¶ The peak boundaries in points.
-
dump
(file_name, protocol=3)¶ Dumps an object to a file through
pickle.dump()
.
-
get_ion_area
(ion)¶ Returns the area of a single ion chromatogram under the peak.
-
property
ic_mass
¶ The mass for a single ion chromatogram peak.
-
property
ion_areas
¶ Returns a copy of the ion areas dict.
- Return type:
- Returns:
The dictionary of
ion: ion area
pairs
-
make_UID
()[source]¶ Create a unique peak ID (UID):
the single mass as an integer and the retention time.
- Author:
Andrew Isaac
-
set_bounds
(left, apex, right)¶ Sets peak boundaries in points.
-
class
Peak
(rt: float, ms: MassSpectrum | None, minutes: bool = ..., outlier: bool = ...)[source]¶ -
class
Peak
(rt: float, ms: float, minutes: bool = ..., outlier: bool = ...) Bases:
AbstractPeak
Subclass of
Peak
representing a peak in a mass spectrum.- Parameters:
- Authors:
Vladimir Likic, Andrew Isaac, Dominic Davis-Foster (type assertions and properties), David Kainer (outlier flag)
Changed in version 2.3.0: Functionality related to single ion peaks has moved to the
ICPeak
class. The two classes share a common base class,AbstractPeak
, which can be used in type checks for functions that accept either type of peak.Changed in version 2.3.0: If the
ms
argument is unset an empty mass spectrum is used, rather thanNone
in previous versions.Attributes:
Return the unique peak ID (UID), either:
The area under the peak.
The peak boundaries in points.
Returns a copy of the ion areas dict.
The mass spectrum at the apex of the peak.
The retention time of the peak, in seconds.
Methods:
__eq__
(other)Return whether this Peak object is equal to another object.
crop_mass
(mass_min, mass_max)Crops mass spectrum.
dump
(file_name[, protocol])Dumps an object to a file through
pickle.dump()
.find_mass_spectrum
(data[, from_bounds])get_int_of_ion
(ion)Returns the intensity of a given ion in this peak.
get_ion_area
(ion)Returns the area of a single ion chromatogram under the peak.
Returns the m/z value with the third highest intensity.
make_UID
()Create a unique peak ID (UID):
null_mass
(mass)Ignore given mass in spectra.
set_bounds
(left, apex, right)Sets peak boundaries in points.
set_ion_area
(ion, area)Sets the area for a single ion.
top_ions
([num_ions])Computes the highest #num_ions intensity ions.
-
property
UID
¶ Return the unique peak ID (UID), either:
Integer masses of top two intensities and their ratio (as
Mass1-Mass2-Ratio*100
); orthe single mass as an integer and the retention time.
- Return type:
- Returns:
UID string
- Author:
Andrew Isaac
-
__eq__
(other)[source]¶ Return whether this Peak object is equal to another object.
- Parameters:
other – The other object to test equality with.
- Return type:
-
property
bounds
¶ The peak boundaries in points.
-
dump
(file_name, protocol=3)¶ Dumps an object to a file through
pickle.dump()
.
-
find_mass_spectrum
(data, from_bounds=False)[source]¶ Sets the peak’s mass spectrum from the data.
Clears the single ion chromatogram mass.
- Parameters:
data (
BaseIntensityMatrix
)from_bounds (
float
) – Whether to use the attributepyms.Peak.Class.Peak.pt_bounds
or to find the peak apex from the peak retention time. DefaultFalse
.
-
get_ion_area
(ion)¶ Returns the area of a single ion chromatogram under the peak.
-
get_third_highest_mz
()[source]¶ Returns the m/z value with the third highest intensity.
- Return type:
-
property
ion_areas
¶ Returns a copy of the ion areas dict.
- Return type:
- Returns:
The dictionary of
ion: ion area
pairs
-
make_UID
()[source]¶ Create a unique peak ID (UID):
Integer masses of top two intensities and their ratio (as
Mass1-Mass2-Ratio*100
); or
- Author:
Andrew Isaac
-
property
mass_spectrum
¶ The mass spectrum at the apex of the peak.
- Return type:
-
null_mass
(mass)[source]¶ Ignore given mass in spectra.
- Parameters:
mass (
float
) – Mass value to remove- Author:
Andrew Isaac
-
set_bounds
(left, apex, right)¶ Sets peak boundaries in points.
-
set_ion_area
(ion, area)¶ Sets the area for a single ion.
pyms.Peak.Function
¶
Functions related to Peak modification.
Functions:
|
Find bound of peak by summing intensities until change in sum is less than |
|
Find bounds of peak by summing intensities until change in sum is less than |
|
Calculates the median of the left and right bounds found for each apexing peak mass. |
|
Approximate the peak bounds (left and right offsets from apex). |
|
Calculate the sum of the raw ion areas based on detected boundaries. |
|
Calculate and return the ion areas of the five most abundant ions in the peak. |
|
Computes the highest 5 intensity ions. |
|
Computes the highest #num_ions intensity ions. |
-
half_area
(ia, max_bound=0, tol=0.5)[source]¶ Find bound of peak by summing intensities until change in sum is less than
tol
percent of the current area.- Parameters:
- Return type:
- Returns:
Half peak area, boundary offset, shared (True if shared ion).
- Authors:
Andrew Isaac, Dominic Davis-Foster (type assertions)
-
ion_area
(ia, apex, max_bound=0, tol=0.5)[source]¶ Find bounds of peak by summing intensities until change in sum is less than
tol
percent of the current area.- Parameters:
- Return type:
- Returns:
Area, left and right boundary offset, shared left, shared right.
- Authors:
Andrew Isaac, Dominic Davis-Foster (type assertions)
-
median_bounds
(im, peak, shared=True)[source]¶ Calculates the median of the left and right bounds found for each apexing peak mass.
- Parameters:
im (
BaseIntensityMatrix
) – The originating IntensityMatrix object.peak (
Peak
)shared (
bool
) – Include shared ions shared with neighbouring peak. DefaultTrue
.
- Return type:
- Returns:
Median left and right boundary offset in points.
- Authors:
Andrew Isaac, Dominic Davis-Foster
-
peak_pt_bounds
(im, peak)[source]¶ Approximate the peak bounds (left and right offsets from apex).
- Parameters:
im (
BaseIntensityMatrix
) – The originating IntensityMatrix objectpeak (
Peak
)
- Return type:
- Returns:
Sum of peak apex ions in detected bounds
- Authors:
Andrew Isaac, Sean O’Callaghan, Dominic Davis-Foster
-
peak_sum_area
(im, peak, single_ion=False, max_bound=0)[source]¶ Calculate the sum of the raw ion areas based on detected boundaries.
- Parameters:
im (
BaseIntensityMatrix
) – The originating IntensityMatrix object.peak (
Peak
)single_ion (
bool
) – whether single ion areas should be returned. DefaultFalse
.max_bound (
int
) – Optional value to limit size of detected bound. Default0
.
- Return type:
- Returns:
Sum of peak apex ions in detected bounds.
- Overloads:
- Authors:
Andrew Isaac, Dominic Davis-Foster (type assertions)
-
peak_top_ion_areas
(im, peak, n_top_ions=5, max_bound=0)[source]¶ Calculate and return the ion areas of the five most abundant ions in the peak.
- Parameters:
im (
IntensityMatrix
) – The originating IntensityMatrix object.peak (
Peak
)n_top_ions (
int
) – Number of top ions to return areas for. Default5
.max_bound (
int
) – Optional value to limit size of detected bound. Default0
.
- Return type:
- Returns:
Dictionary of
ion : ion_area pairs
.- Authors:
Sean O’Callaghan, Dominic Davis-Foster (type assertions)
-
top_ions_v1
(peak, num_ions=5)[source]¶ Computes the highest 5 intensity ions.
- Parameters:
- Return type:
- Returns:
A list of the top 5 highest intensity ions
- Authors:
Sean O’Callaghan, Dominic Davis-Foster (type assertions)
Deprecated since version 2.0.0: This will be removed in 2.4.0. Use
pyms.Peak.Function.top_ions_v2()
instead
-
top_ions_v2
(peak, num_ions=5)[source]¶ Computes the highest #num_ions intensity ions.
- Parameters:
- Return type:
- Returns:
A list of the num_ions highest intensity ions
- Authors:
Sean O’Callaghan, Dominic Davis-Foster (type assertions)
Deprecated since version 2.1.2: This will be removed in 2.5.0. Use
pyms.Peak.Class.Peak.top_ions()
instead
pyms.Peak.List
¶
Functions for modelling peak lists.
pyms.Peak.List.Function
¶
Functions related to Peak modification.
Functions:
|
Create a peak that consists of a composite spectrum from all spectra in the list of peaks. |
|
Gets the best matching Retention Time and spectra from 'data' for each peak in the peak list. |
|
Returns whether |
|
Selects peaks from a retention time range. |
-
composite_peak
(peak_list, ignore_outliers=False)[source]¶ Create a peak that consists of a composite spectrum from all spectra in the list of peaks.
-
fill_peaks
(data, peak_list, D, minutes=False)[source]¶ Gets the best matching Retention Time and spectra from ‘data’ for each peak in the peak list.
- Parameters:
data (
BaseIntensityMatrix
) – A data IntensityMatrix that has the same mass range as the peaks in the peak listD (
float
) – Peak width standard deviation in seconds. Determines search window width.minutes (
bool
) – Return retention time as minutes. DefaultFalse
.
- Return type:
- Returns:
List of Peak Objects
- Authors:
Andrew Isaac, Dominic Davis-Foster (type assertions)
-
is_peak_list
(peaks)[source]¶ Returns whether
peaks
is a valid peak list.- Author:
Dominic Davis-Foster
- Return type:
pyms.Peak.List.IO
¶
Functions related to storing and loading a list of Peak objects.
Functions:
|
Loads the peak_list stored with |
|
Store the list of peak objects. |
-
load_peaks
(file_name)[source]¶ Loads the peak_list stored with
store_peaks()
.