pyms.IntensityMatrix
Class to model Intensity Matrix.
Classes:
|
Enumeration of supported ASCII filetypes for |
|
Base class for intensity matrices of binned raw data. |
|
Intensity matrix of binned raw data. |
Functions:
|
Sets the full intensity matrix with flexible bins. |
|
Sets the full intensity matrix with integer bins. |
|
Imports data in LECO CSV format. |
-
enum
AsciiFiletypes(value)[source] Bases:
IntEnumEnumeration of supported ASCII filetypes for
export_ascii().New in version 2.3.0.
- Member Type
Valid values are as follows:
-
ASCII_DAT= <AsciiFiletypes.ASCII_DAT: 1> Tab-delimited ASCII file
-
ASCII_CSV= <AsciiFiletypes.ASCII_CSV: 0> Comma-separated values file
-
class
BaseIntensityMatrix(time_list, mass_list, intensity_array)[source] Bases:
pymsBaseClass,TimeListMixin,MassListMixin,IntensityArrayMixin,GetIndexTimeMixinBase class for intensity matrices of binned raw data.
- Parameters
- Authors
Andrew Isaac, Dominic Davis-Foster (type assertions and properties)
Methods:
__eq__(other)Return whether this intensity matrix object is equal to another object.
__len__()Returns the number of scans in the intensity matrix.
crop_mass(mass_min, mass_max)Crops mass spectrum.
dump(file_name[, protocol])Dumps an object to a file through
pickle.dump().get_ic_at_index(ix)Returns the ion chromatogram at the specified index.
get_index_at_time(time)Returns the nearest index corresponding to the given time.
get_index_of_mass(mass)Returns the index of the nearest binned mass to the given mass.
Returns binned mass at index.
get_ms_at_index(ix)Returns a mass spectrum for a given scan index.
Returns the spectral intensities for scan index.
Returns time at given index.
Iterate over column indices.
Iterates over row indices.
null_mass(mass)Ignore given (closest) mass in spectra.
reduce_mass_spectra([n_intensities])Reduces the mass spectra by retaining the top n_intensities, discarding all other intensities.
set_ic_at_index(ix, ic)Sets the intensity of the mass at index
ixin each scan to a new value.Attributes:
Returns a copy of the intensity array.
Returns a copy of the intensity array as a list of lists of floats.
Returns a copy of the intensity matrix.
Returns a list of the masses.
Returns the intensity matrix as a list of lists of floats.
Returns the maximum m/z value in the spectrum.
Returns the minimum m/z value in the spectrum.
Gets the size of intensity matrix.
Returns a copy of the time list.
-
__eq__(other)[source] Return whether this intensity matrix object is equal to another object.
- Parameters
other – The other object to test equality with.
- Return type
-
dump(file_name, protocol=3) Dumps an object to a file through
pickle.dump().
-
get_ic_at_index(ix)[source] Returns the ion chromatogram at the specified index.
- Parameters
ix (
int) – Index of an ion chromatogram in the intensity data matrix.- Return type
- Returns
Ion chromatogram at given index.
- Authors
Qiao Wang, Andrew Isaac, Vladimir Likic
-
get_index_at_time(time) Returns the nearest index corresponding to the given time.
- Parameters
time (
float) – Time in seconds- Return type
- Returns
Nearest index corresponding to given time
- Authors
Lewis Lee, Tim Erwin, Vladimir Likic
Changed in version 2.3.0: Now returns
-1if no index is found.
-
get_ms_at_index(ix)[source] Returns a mass spectrum for a given scan index.
- Parameters
ix (
int) – The index of the scan.- Author
Andrew Isaac
- Return type
-
get_time_at_index(ix) Returns time at given index.
-
property
intensity_array Returns a copy of the intensity array.
- Return type
- Returns
Matrix of intensity values.
- Authors
Andrew Isaac, Lewis Lee
-
property
intensity_array_list Returns a copy of the intensity array as a list of lists of floats.
-
property
intensity_matrix Returns a copy of the intensity matrix.
- Return type
- Returns
Matrix of intensity values.
- Author
Andrew Isaac
-
property
mass_list Returns a list of the masses.
-
property
matrix_list Returns the intensity matrix as a list of lists of floats.
- Return type
- Returns
Matrix of intensity values
- Author
Andrew Isaac
-
property
max_mass Returns the maximum m/z value in the spectrum.
-
property
min_mass Returns the minimum m/z value in the spectrum.
-
null_mass(mass)[source] Ignore given (closest) mass in spectra.
- Parameters
mass (
float) – Mass value to remove- Author
Andrew Isaac
-
reduce_mass_spectra(n_intensities=5)[source] Reduces the mass spectra by retaining the top n_intensities, discarding all other intensities.
- Parameters
n_intensities (
int) – The number of top intensities to keep. Default5.- Author
Vladimir Likic
-
set_ic_at_index(ix, ic)[source] Sets the intensity of the mass at index
ixin each scan to a new value.- Parameters
ix (
int) – Index of an ion chromatogram in the intensity data matrix to be setic (
IonChromatogram) – Ion chromatogram that will be copied at positionixin the data matrix
The length of the ion chromatogram must match the appropriate dimension of the intensity matrix.
- Author
Vladimir Likic
-
property
size Gets the size of intensity matrix.
-
class
IntensityMatrix(time_list, mass_list, intensity_array)[source] Bases:
BaseIntensityMatrixIntensity matrix of binned raw data.
- Parameters
- Authors
Andrew Isaac, Dominic Davis-Foster (type assertions and properties)
Methods:
__eq__(other)Return whether this intensity matrix object is equal to another object.
__len__()Returns the number of scans in the intensity matrix.
crop_mass(mass_min, mass_max)Crops mass spectrum.
dump(file_name[, protocol])Dumps an object to a file through
pickle.dump().export_ascii(root_name[, fmt])Exports the intensity matrix, retention time vector, and m/z vector to the ascii format.
export_leco_csv(file_name)Exports data in LECO CSV format.
get_ic_at_index(ix)Returns the ion chromatogram at the specified index.
get_ic_at_mass([mass])Returns the ion chromatogram for the nearest binned mass to the specified mass.
get_index_at_time(time)Returns the nearest index corresponding to the given time.
get_index_of_mass(mass)Returns the index of the nearest binned mass to the given mass.
Returns binned mass at index.
get_ms_at_index(ix)Returns a mass spectrum for a given scan index.
Returns the spectral intensities for scan index.
Returns time at given index.
Iterate over local column indices.
Iterates over the local row indices.
null_mass(mass)Ignore given (closest) mass in spectra.
reduce_mass_spectra([n_intensities])Reduces the mass spectra by retaining the top n_intensities, discarding all other intensities.
set_ic_at_index(ix, ic)Sets the intensity of the mass at index
ixin each scan to a new value.Attributes:
Constructs a Base Peak Chromatogram from the data.
Returns a copy of the intensity array.
Returns a copy of the intensity array as a list of lists of floats.
Returns a copy of the intensity matrix.
Gets the local size of intensity matrix.
Returns a list of the masses.
Returns the intensity matrix as a list of lists of floats.
Returns the maximum m/z value in the spectrum.
Returns the minimum m/z value in the spectrum.
Gets the size of intensity matrix.
Returns the TIC of the intensity matrix.
Returns a copy of the time list.
-
__eq__(other) Return whether this intensity matrix object is equal to another object.
- Parameters
other – The other object to test equality with.
- Return type
-
property
bpc Constructs a Base Peak Chromatogram from the data.
This represents the most intense ion for each scan.
- Authors
Dominic Davis-Foster
New in version 2.3.0.
- Return type
-
crop_mass(mass_min, mass_max) Crops mass spectrum.
-
dump(file_name, protocol=3) Dumps an object to a file through
pickle.dump().
-
export_ascii(root_name, fmt=AsciiFiletypes.ASCII_DAT)[source] Exports the intensity matrix, retention time vector, and m/z vector to the ascii format.
By default, export_ascii(“NAME”) will create NAME.im.dat, NAME.rt.dat, and NAME.mz.dat where these are the intensity matrix, retention time vector, and m/z vector in tab delimited format.
If
format==<AsciiFiletypes.ASCII_CSV>, the files will be in the CSV format, named NAME.im.csv, NAME.rt.csv, and NAME.mz.csv.- Parameters
root_name (
Union[str,Path,PathLike]) – Root name for the output filesfmt (
AsciiFiletypes) – Format of the output file, either<AsciiFiletypes.ASCII_DAT>or<AsciiFiletypes.ASCII_CSV>. Default<AsciiFiletypes.ASCII_DAT: 1>.
- Authors
Milica Ng, Andrew Isaac, Vladimir Likic, Dominic Davis-Foster (pathlib support)
-
get_ic_at_index(ix) Returns the ion chromatogram at the specified index.
- Parameters
ix (
int) – Index of an ion chromatogram in the intensity data matrix.- Return type
- Returns
Ion chromatogram at given index.
- Authors
Qiao Wang, Andrew Isaac, Vladimir Likic
-
get_ic_at_mass(mass=None)[source] Returns the ion chromatogram for the nearest binned mass to the specified mass.
If no mass value is given, the function returns the total ion chromatogram.
-
get_index_at_time(time) Returns the nearest index corresponding to the given time.
- Parameters
time (
float) – Time in seconds- Return type
- Returns
Nearest index corresponding to given time
- Authors
Lewis Lee, Tim Erwin, Vladimir Likic
Changed in version 2.3.0: Now returns
-1if no index is found.
-
get_index_of_mass(mass) Returns the index of the nearest binned mass to the given mass.
-
get_mass_at_index(ix) Returns binned mass at index.
-
get_ms_at_index(ix) Returns a mass spectrum for a given scan index.
- Parameters
ix (
int) – The index of the scan.- Author
Andrew Isaac
- Return type
-
get_scan_at_index(ix) Returns the spectral intensities for scan index.
-
get_time_at_index(ix) Returns time at given index.
-
property
intensity_array Returns a copy of the intensity array.
- Return type
- Returns
Matrix of intensity values.
- Authors
Andrew Isaac, Lewis Lee
-
property
intensity_array_list Returns a copy of the intensity array as a list of lists of floats.
-
property
intensity_matrix Returns a copy of the intensity matrix.
- Return type
- Returns
Matrix of intensity values.
- Author
Andrew Isaac
-
property
local_size Gets the local size of intensity matrix.
- Returns
Number of rows and cols
- Return type
- Author
Luke Hodkinson
-
property
mass_list Returns a list of the masses.
-
property
matrix_list Returns the intensity matrix as a list of lists of floats.
- Return type
- Returns
Matrix of intensity values
- Author
Andrew Isaac
-
property
max_mass Returns the maximum m/z value in the spectrum.
-
property
min_mass Returns the minimum m/z value in the spectrum.
-
null_mass(mass) Ignore given (closest) mass in spectra.
- Parameters
mass (
float) – Mass value to remove- Author
Andrew Isaac
-
reduce_mass_spectra(n_intensities=5) Reduces the mass spectra by retaining the top n_intensities, discarding all other intensities.
- Parameters
n_intensities (
int) – The number of top intensities to keep. Default5.- Author
Vladimir Likic
-
set_ic_at_index(ix, ic) Sets the intensity of the mass at index
ixin each scan to a new value.- Parameters
ix (
int) – Index of an ion chromatogram in the intensity data matrix to be setic (
IonChromatogram) – Ion chromatogram that will be copied at positionixin the data matrix
The length of the ion chromatogram must match the appropriate dimension of the intensity matrix.
- Author
Vladimir Likic
-
property
size Gets the size of intensity matrix.
-
property
tic Returns the TIC of the intensity matrix.
New in version 2.3.0.
- Return type
-
build_intensity_matrix(data, bin_interval=1, bin_left=0.5, bin_right=0.5, min_mass=None)[source] Sets the full intensity matrix with flexible bins.
The first bin is centered around
min_mass, and subsequent bins are offset bybin_interval.- Parameters
data (
GCMS_data) – Raw GCMS databin_interval (
float) – interval between bin centres. Default1.bin_left (
float) – left bin boundary offset. Default0.5.bin_right (
float) – right bin boundary offset. Default0.5.min_mass (
Optional[float]) – Minimum mass to bin (default minimum mass from data). DefaultNone.
- Return type
- Returns
Binned IntensityMatrix object
- Authors
Qiao Wang, Andrew Isaac, Vladimir Likic