pyms.IonChromatogram

Classes to model a GC-MS Ion Chromatogram.

Classes:

BasePeakChromatogram(intensity_list, time_list)

Models a base peak chromatogram (BPC).

ExtractedIonChromatogram(intensity_list, …)

Models an extracted ion chromatogram (EIC).

IonChromatogram(intensity_list, time_list[, …])

Models an ion chromatogram.

class BasePeakChromatogram(intensity_list, time_list)[source]

Bases: IonChromatogram

Models a base peak chromatogram (BPC).

An ion chromatogram is a set of intensities as a function of retention time. This can can be either m/z channel intensities (for example, ion chromatograms at m/z = 65), or cumulative intensities over all measured m/z. In the latter case the ion chromatogram is total ion chromatogram (TIC).

Parameters
Authors

Lewis Lee, Vladimir Likic, Dominic Davis-Foster (type assertions and properties)

New in version 2.3.0.

Methods:

__copy__()

Returns a new IonChromatogram containing a copy of the data in this object.

__eq__(other)

Return whether this IonChromatogram object is equal to another object.

__len__()

Returns the length of the IonChromatogram object.

__sub__(other)

Subtracts another IC from the current one (in place).

dump(file_name[, protocol])

Dumps an object to a file through pickle.dump().

get_index_at_time(time)

Returns the nearest index corresponding to the given time.

get_intensity_at_index(ix)

Returns the intensity at the given index.

get_time_at_index(ix)

Returns time at given index.

is_bpc()

Returns whether the ion chromatogram is a base peak chromatogram (BPC).

is_eic()

Returns whether the ion chromatogram is an extracted ion chromatogram (EIC).

is_tic()

Returns whether the ion chromatogram is a total ion chromatogram (TIC) or extracted ion chromatogram (EIC).

write(file_name[, minutes, formatting])

Writes the ion chromatogram to the specified file.

Attributes:

intensity_array

Returns a copy of the intensity array.

intensity_array_list

Returns a copy of the intensity array as a list of lists of floats.

intensity_matrix

Returns a copy of the intensity matrix.

mass

Returns the m/z channel of the IC.

matrix_list

Returns the intensity matrix as a list of lists of floats.

time_list

Returns a copy of the time list.

time_step

Returns the time step.

__copy__()

Returns a new IonChromatogram containing a copy of the data in this object.

Return type

IonChromatogram

__eq__(other)

Return whether this IonChromatogram object is equal to another object.

Parameters

other (Any) – The other object to test equality with.

Return type

bool

__len__()

Returns the length of the IonChromatogram object.

Authors

Lewis Lee, Vladimir Likic

Return type

int

__sub__(other)

Subtracts another IC from the current one (in place).

Parameters

other (IonChromatogram) – Another IC

Return type

IonChromatogram

dump(file_name, protocol=3)

Dumps an object to a file through pickle.dump().

Parameters
  • file_name (Union[str, Path, PathLike]) – Filename to save the dump as.

  • protocol (int) – The pickle protocol to use. Default 3.

Authors

Vladimir Likic, Dominic Davis-Foster (pathlib and pickle protocol support)

get_index_at_time(time)

Returns the nearest index corresponding to the given time.

Parameters

time (float) – Time in seconds

Return type

int

Returns

Nearest index corresponding to given time

Authors

Lewis Lee, Tim Erwin, Vladimir Likic

Changed in version 2.3.0: Now returns -1 if no index is found.

get_intensity_at_index(ix)

Returns the intensity at the given index.

Parameters

ix (int) – An index.

Authors

Lewis Lee, Vladimir Likic

Return type

float

get_time_at_index(ix)

Returns time at given index.

Parameters

ix (int)

Authors

Lewis Lee, Vladimir Likic

Return type

float

property intensity_array

Returns a copy of the intensity array.

Return type

ndarray

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.

Return type

List[List[float]]

Returns

Matrix of intensity values.

Author

Andrew Isaac

property intensity_matrix

Returns a copy of the intensity matrix.

Return type

ndarray

Returns

Matrix of intensity values.

Author

Andrew Isaac

static is_bpc()[source]

Returns whether the ion chromatogram is a base peak chromatogram (BPC).

Return type

bool

static is_eic()

Returns whether the ion chromatogram is an extracted ion chromatogram (EIC).

New in version 2.3.0.

Return type

bool

is_tic()

Returns whether the ion chromatogram is a total ion chromatogram (TIC) or extracted ion chromatogram (EIC).

Authors

Lewis Lee, Vladimir Likic

Return type

bool

property mass

Returns the m/z channel of the IC.

Author

Sean O’Callaghan

Return type

Optional[float]

property matrix_list

Returns the intensity matrix as a list of lists of floats.

Return type

ndarray

Returns

Matrix of intensity values

Author

Andrew Isaac

property time_list

Returns a copy of the time list.

Return type

List[float]

Returns

List of retention times

Authors

Andrew Isaac, Lewis Lee, Vladimir Likic

property time_step

Returns the time step.

Authors

Lewis Lee, Vladimir Likic

Return type

float

write(file_name, minutes=False, formatting=True)

Writes the ion chromatogram to the specified file.

Parameters
  • file_name (Union[str, Path, PathLike]) – The name of the output file

  • minutes (bool) – A boolean value indicating whether to write time in minutes. Default False.

  • formatting (bool) – Whether to format the numbers in the output. Default True.

Authors

Lewis Lee, Vladimir Likic, Dominic Davis-Foster (pathlib support)

class ExtractedIonChromatogram(intensity_list, time_list, masses)[source]

Bases: IonChromatogram

Models an extracted ion chromatogram (EIC).

An ion chromatogram is a set of intensities as a function of retention time. This can can be either m/z channel intensities (for example, ion chromatograms at m/z = 65), or cumulative intensities over all measured m/z. In the latter case the ion chromatogram is total ion chromatogram (TIC).

Parameters
Authors

Lewis Lee, Vladimir Likic, Dominic Davis-Foster (type assertions and properties)

New in version 2.3.0.

Methods:

__copy__()

Returns a new IonChromatogram containing a copy of the data in this object.

__eq__(other)

Return whether this IonChromatogram object is equal to another object.

__len__()

Returns the length of the IonChromatogram object.

__sub__(other)

Subtracts another IC from the current one (in place).

dump(file_name[, protocol])

Dumps an object to a file through pickle.dump().

get_index_at_time(time)

Returns the nearest index corresponding to the given time.

get_intensity_at_index(ix)

Returns the intensity at the given index.

get_time_at_index(ix)

Returns time at given index.

is_bpc()

Returns whether the ion chromatogram is a base peak chromatogram (BPC).

is_eic()

Returns whether the ion chromatogram is an extracted ion chromatogram (EIC).

is_tic()

Returns whether the ion chromatogram is a total ion chromatogram (TIC) or extracted ion chromatogram (EIC).

write(file_name[, minutes, formatting])

Writes the ion chromatogram to the specified file.

Attributes:

intensity_array

Returns a copy of the intensity array.

intensity_array_list

Returns a copy of the intensity array as a list of lists of floats.

intensity_matrix

Returns a copy of the intensity matrix.

mass

Returns the m/z channel of the IC.

masses

List of extracted masses in the EIC.

matrix_list

Returns the intensity matrix as a list of lists of floats.

time_list

Returns a copy of the time list.

time_step

Returns the time step.

__copy__()

Returns a new IonChromatogram containing a copy of the data in this object.

Return type

IonChromatogram

__eq__(other)

Return whether this IonChromatogram object is equal to another object.

Parameters

other (Any) – The other object to test equality with.

Return type

bool

__len__()

Returns the length of the IonChromatogram object.

Authors

Lewis Lee, Vladimir Likic

Return type

int

__sub__(other)

Subtracts another IC from the current one (in place).

Parameters

other (IonChromatogram) – Another IC

Return type

IonChromatogram

dump(file_name, protocol=3)

Dumps an object to a file through pickle.dump().

Parameters
  • file_name (Union[str, Path, PathLike]) – Filename to save the dump as.

  • protocol (int) – The pickle protocol to use. Default 3.

Authors

Vladimir Likic, Dominic Davis-Foster (pathlib and pickle protocol support)

get_index_at_time(time)

Returns the nearest index corresponding to the given time.

Parameters

time (float) – Time in seconds

Return type

int

Returns

Nearest index corresponding to given time

Authors

Lewis Lee, Tim Erwin, Vladimir Likic

Changed in version 2.3.0: Now returns -1 if no index is found.

get_intensity_at_index(ix)

Returns the intensity at the given index.

Parameters

ix (int) – An index.

Authors

Lewis Lee, Vladimir Likic

Return type

float

get_time_at_index(ix)

Returns time at given index.

Parameters

ix (int)

Authors

Lewis Lee, Vladimir Likic

Return type

float

property intensity_array

Returns a copy of the intensity array.

Return type

ndarray

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.

Return type

List[List[float]]

Returns

Matrix of intensity values.

Author

Andrew Isaac

property intensity_matrix

Returns a copy of the intensity matrix.

Return type

ndarray

Returns

Matrix of intensity values.

Author

Andrew Isaac

static is_bpc()

Returns whether the ion chromatogram is a base peak chromatogram (BPC).

New in version 2.3.0.

Return type

bool

static is_eic()[source]

Returns whether the ion chromatogram is an extracted ion chromatogram (EIC).

Return type

bool

is_tic()

Returns whether the ion chromatogram is a total ion chromatogram (TIC) or extracted ion chromatogram (EIC).

Authors

Lewis Lee, Vladimir Likic

Return type

bool

property mass

Returns the m/z channel of the IC.

Author

Sean O’Callaghan

Return type

Optional[float]

property masses

List of extracted masses in the EIC.

Return type

Tuple[float, …]

property matrix_list

Returns the intensity matrix as a list of lists of floats.

Return type

ndarray

Returns

Matrix of intensity values

Author

Andrew Isaac

property time_list

Returns a copy of the time list.

Return type

List[float]

Returns

List of retention times

Authors

Andrew Isaac, Lewis Lee, Vladimir Likic

property time_step

Returns the time step.

Authors

Lewis Lee, Vladimir Likic

Return type

float

write(file_name, minutes=False, formatting=True)

Writes the ion chromatogram to the specified file.

Parameters
  • file_name (Union[str, Path, PathLike]) – The name of the output file

  • minutes (bool) – A boolean value indicating whether to write time in minutes. Default False.

  • formatting (bool) – Whether to format the numbers in the output. Default True.

Authors

Lewis Lee, Vladimir Likic, Dominic Davis-Foster (pathlib support)

class IonChromatogram(intensity_list, time_list, mass=None)[source]

Bases: pymsBaseClass, TimeListMixin, IntensityArrayMixin, GetIndexTimeMixin

Models an ion chromatogram.

An ion chromatogram is a set of intensities as a function of retention time. This can can be either m/z channel intensities (for example, ion chromatograms at m/z = 65), or cumulative intensities over all measured m/z. In the latter case the ion chromatogram is total ion chromatogram (TIC).

The nature of an IonChromatogram object can be revealed by inspecting the value of the attribute ‘mass’. This is set to the m/z value of the ion chromatogram, or to None for TIC.

Parameters
Authors

Lewis Lee, Vladimir Likic, Dominic Davis-Foster (type assertions and properties)

Changed in version 2.3.0: The ia parameter was renamed to intensity_list.

Methods:

__copy__()

Returns a new IonChromatogram containing a copy of the data in this object.

__eq__(other)

Return whether this IonChromatogram object is equal to another object.

__len__()

Returns the length of the IonChromatogram object.

__sub__(other)

Subtracts another IC from the current one (in place).

dump(file_name[, protocol])

Dumps an object to a file through pickle.dump().

get_index_at_time(time)

Returns the nearest index corresponding to the given time.

get_intensity_at_index(ix)

Returns the intensity at the given index.

get_time_at_index(ix)

Returns time at given index.

is_bpc()

Returns whether the ion chromatogram is a base peak chromatogram (BPC).

is_eic()

Returns whether the ion chromatogram is an extracted ion chromatogram (EIC).

is_tic()

Returns whether the ion chromatogram is a total ion chromatogram (TIC) or extracted ion chromatogram (EIC).

write(file_name[, minutes, formatting])

Writes the ion chromatogram to the specified file.

Attributes:

intensity_array

Returns a copy of the intensity array.

intensity_array_list

Returns a copy of the intensity array as a list of lists of floats.

intensity_matrix

Returns a copy of the intensity matrix.

mass

Returns the m/z channel of the IC.

matrix_list

Returns the intensity matrix as a list of lists of floats.

time_list

Returns a copy of the time list.

time_step

Returns the time step.

__copy__()[source]

Returns a new IonChromatogram containing a copy of the data in this object.

Return type

IonChromatogram

__eq__(other)[source]

Return whether this IonChromatogram object is equal to another object.

Parameters

other (Any) – The other object to test equality with.

Return type

bool

__len__()[source]

Returns the length of the IonChromatogram object.

Authors

Lewis Lee, Vladimir Likic

Return type

int

__sub__(other)[source]

Subtracts another IC from the current one (in place).

Parameters

other (IonChromatogram) – Another IC

Return type

IonChromatogram

dump(file_name, protocol=3)

Dumps an object to a file through pickle.dump().

Parameters
  • file_name (Union[str, Path, PathLike]) – Filename to save the dump as.

  • protocol (int) – The pickle protocol to use. Default 3.

Authors

Vladimir Likic, Dominic Davis-Foster (pathlib and pickle protocol support)

get_index_at_time(time)

Returns the nearest index corresponding to the given time.

Parameters

time (float) – Time in seconds

Return type

int

Returns

Nearest index corresponding to given time

Authors

Lewis Lee, Tim Erwin, Vladimir Likic

Changed in version 2.3.0: Now returns -1 if no index is found.

get_intensity_at_index(ix)[source]

Returns the intensity at the given index.

Parameters

ix (int) – An index.

Authors

Lewis Lee, Vladimir Likic

Return type

float

get_time_at_index(ix)

Returns time at given index.

Parameters

ix (int)

Authors

Lewis Lee, Vladimir Likic

Return type

float

property intensity_array

Returns a copy of the intensity array.

Return type

ndarray

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.

Return type

List[List[float]]

Returns

Matrix of intensity values.

Author

Andrew Isaac

property intensity_matrix

Returns a copy of the intensity matrix.

Return type

ndarray

Returns

Matrix of intensity values.

Author

Andrew Isaac

static is_bpc()[source]

Returns whether the ion chromatogram is a base peak chromatogram (BPC).

New in version 2.3.0.

Return type

bool

static is_eic()[source]

Returns whether the ion chromatogram is an extracted ion chromatogram (EIC).

New in version 2.3.0.

Return type

bool

is_tic()[source]

Returns whether the ion chromatogram is a total ion chromatogram (TIC) or extracted ion chromatogram (EIC).

Authors

Lewis Lee, Vladimir Likic

Return type

bool

property mass

Returns the m/z channel of the IC.

Author

Sean O’Callaghan

Return type

Optional[float]

property matrix_list

Returns the intensity matrix as a list of lists of floats.

Return type

ndarray

Returns

Matrix of intensity values

Author

Andrew Isaac

property time_list

Returns a copy of the time list.

Return type

List[float]

Returns

List of retention times

Authors

Andrew Isaac, Lewis Lee, Vladimir Likic

property time_step

Returns the time step.

Authors

Lewis Lee, Vladimir Likic

Return type

float

write(file_name, minutes=False, formatting=True)[source]

Writes the ion chromatogram to the specified file.

Parameters
  • file_name (Union[str, Path, PathLike]) – The name of the output file

  • minutes (bool) – A boolean value indicating whether to write time in minutes. Default False.

  • formatting (bool) – Whether to format the numbers in the output. Default True.

Authors

Lewis Lee, Vladimir Likic, Dominic Davis-Foster (pathlib support)