libgunshotmatch.method

Methods for GunShotMatch analysis.

Classes:

MethodBase()

Base class for methods.

Method([intensity_matrix, peak_detection, …])

Overall GunShotMatch method.

IntensityMatrixMethod([crop_mass_range, …])

Method used for constructing an intensity matrix from a datafile.

PeakDetectionMethod([points, scans])

Method used for Biller-Biemann peak detection.

PeakFilterMethod([noise_filter, …])

Method used for peak filtering.

AlignmentMethod([rt_modulation, …])

Method used for peak alignment.

ConsolidateMethod([name_filter, …])

Method used for consolidation (finding most likely identity for aligned peaks).

SavitzkyGolayMethod([enable, window, degree])

Method parameters for the Savitzky-Golay filter.

class MethodBase[source]

Base class for methods.

Methods:

from_dict(method)

Construct a MethodBase from a dictionary.

to_dict()

Convert a MethodBase to a dictionary.

classmethod from_dict(method)[source]

Construct a MethodBase from a dictionary.

Parameters

method (Mapping[str, Any])

Return type

MethodBase

to_dict()[source]

Convert a MethodBase to a dictionary.

Return type

Dict[str, Any]

class Method(intensity_matrix=IntensityMatrixMethod(), peak_detection=PeakDetectionMethod(), peak_filter=PeakFilterMethod(), alignment=AlignmentMethod(), consolidate=ConsolidateMethod())[source]

Bases: libgunshotmatch.method.MethodBase

Overall GunShotMatch method.

Parameters
  • intensity_matrix (IntensityMatrixMethod) – Method used for constructing an intensity matrix from a datafile. Default IntensityMatrixMethod(crop_mass_range=(50, 500), savitzky_golay=SavitzkyGolayMethod(enable=True, window=7, degree=2), tophat=True, tophat_structure_size='1.5m').

  • peak_detection (PeakDetectionMethod) – Method used for Biller-Biemann peak detection. Default PeakDetectionMethod(points=10, scans=1).

  • peak_filter (PeakFilterMethod) – Method used for peak filtering. Default PeakFilterMethod(noise_filter=True, noise_threshold=2, base_peak_filter={73, 147}, rt_range=None).

  • alignment (AlignmentMethod) – Method used for peak alignment. Default AlignmentMethod(rt_modulation=2.5, gap_penalty=0.3, min_peaks=1, top_n_peaks=80, min_peak_area=0.0).

  • consolidate (ConsolidateMethod) – Method used for consolidation (finding most likely identity for aligned peaks). Default ConsolidateMethod(name_filter=[], min_match_factor=600, min_appearances=-1).

Attributes:

alignment

Method used for peak alignment.

consolidate

Method used for consolidation (finding most likely identity for aligned peaks).

intensity_matrix

Method used for constructing an intensity matrix from a datafile.

peak_detection

Method used for Biller-Biemann peak detection.

peak_filter

Method used for peak filtering.

Methods:

from_json(json_string)

Parse a Method from a JSON string.

from_toml(toml_string)

Parse a Method from a TOML string.

to_toml()

Convert a Method to a TOML string.

alignment

Type:    AlignmentMethod

Method used for peak alignment.

consolidate

Type:    ConsolidateMethod

Method used for consolidation (finding most likely identity for aligned peaks).

classmethod from_json(json_string)[source]

Parse a Method from a JSON string.

Parameters

json_string (str)

Return type

Method

classmethod from_toml(toml_string)[source]

Parse a Method from a TOML string.

Parameters

toml_string (str)

Return type

Method

intensity_matrix

Type:    IntensityMatrixMethod

Method used for constructing an intensity matrix from a datafile.

peak_detection

Type:    PeakDetectionMethod

Method used for Biller-Biemann peak detection.

peak_filter

Type:    PeakFilterMethod

Method used for peak filtering.

to_toml()[source]

Convert a Method to a TOML string.

Return type

str

class IntensityMatrixMethod(crop_mass_range=(50, 500), savitzky_golay=SavitzkyGolayMethod(enable=True, window=7, degree=2), tophat=True, tophat_structure_size='1.5m')[source]

Bases: libgunshotmatch.method.MethodBase

Method used for constructing an intensity matrix from a datafile.

Parameters
  • crop_mass_range (Optional[Iterable]) – The range of masses to which the GC-MS data should be limited to. Default (50, 500).

  • savitzky_golay (Union[bool, SavitzkyGolayMethod, Dict[str, Any]]) – Settings for Savitzky-Golay smoothing. Default SavitzkyGolayMethod(enable=True, window=7, degree=2).

  • tophat (bool) – Whether to perform Tophat baseline correction. Default True.

  • tophat_structure_size (str) – The structure size for Tophat baseline correction. Default '1.5m'.

Attributes:

crop_mass_range

The range of masses to which the GC-MS data should be limited to.

savitzky_golay

Settings for Savitzky-Golay smoothing.

tophat

Whether to perform Tophat baseline correction.

tophat_structure_size

The structure size for Tophat baseline correction.

crop_mass_range

Type:    Optional[Tuple[int, int]]

The range of masses to which the GC-MS data should be limited to.

savitzky_golay

Type:    SavitzkyGolayMethod

Settings for Savitzky-Golay smoothing.

tophat

Type:    bool

Whether to perform Tophat baseline correction.

tophat_structure_size

Type:    str

The structure size for Tophat baseline correction.

class PeakDetectionMethod(points=10, scans=1)[source]

Bases: libgunshotmatch.method.MethodBase

Method used for Biller-Biemann peak detection.

Parameters
  • points (int) – Number of scans over which to consider a maxima to be a peak. Default 10.

  • scans (int) – Number of scans to combine in a single peak from to compensate for spectra skewing. Default 1.

Attributes:

points

Number of scans over which to consider a maxima to be a peak.

scans

Number of scans to combine in a single peak from to compensate for spectra skewing.

points

Type:    int

Number of scans over which to consider a maxima to be a peak.

scans

Type:    int

Number of scans to combine in a single peak from to compensate for spectra skewing.

class PeakFilterMethod(noise_filter=True, noise_threshold=2, base_peak_filter={73, 147}, rt_range=None)[source]

Bases: libgunshotmatch.method.MethodBase

Method used for peak filtering.

Parameters
  • noise_filter (bool) – Whether to perform automatic noise filtering of the peak list. Default True.

  • noise_threshold (int) – The minimum number of ions that must have intensities above the noise floor, otherwise the peak is excluded. Default 2.

  • base_peak_filter (Set[int]) – Peaks whose base peak is at one of the listed masses (m/z) are excluded. Default {73, 147}.

  • rt_range (Optional[Iterable]) – Optional retention time range (in minutes) to filter the peak list to. Default None.

Attributes:

base_peak_filter

Peaks whose base peak is at one of the listed masses (m/z) are excluded.

noise_filter

Whether to perform automatic noise filtering of the peak list.

noise_threshold

The minimum number of ions that must have intensities above the noise floor, otherwise the peak is excluded.

rt_range

Optional retention time range (in minutes) to filter the peak list to.

base_peak_filter

Type:    Set[int]

Peaks whose base peak is at one of the listed masses (m/z) are excluded.

noise_filter

Type:    bool

Whether to perform automatic noise filtering of the peak list.

noise_threshold

Type:    int

The minimum number of ions that must have intensities above the noise floor, otherwise the peak is excluded.

rt_range

Type:    Optional[Tuple[float, float]]

Optional retention time range (in minutes) to filter the peak list to.

class AlignmentMethod(rt_modulation=2.5, gap_penalty=0.3, min_peaks=1, top_n_peaks=80, min_peak_area=0.0)[source]

Bases: libgunshotmatch.method.MethodBase

Method used for peak alignment.

Parameters
  • rt_modulation (float) – Retention time tolerance parameter for pairwise alignments. Default 2.5.

  • gap_penalty (float) – Gap parameter for pairwise alignments. Default 0.3.

  • min_peaks (int) – Minimum number of peaks required for the alignment position to survive filtering. If set to -1 the number of repeats in the project are used. Default 1.

  • top_n_peaks (int) – Number of peaks (starting with the largest) to include in the output. Default 80.

  • min_peak_area (float) – Minimum area of peaks to include in the output. Default 0.0.

Attributes:

gap_penalty

Gap parameter for pairwise alignments.

min_peak_area

Minimum area of peaks to include in the output.

min_peaks

Minimum number of peaks required for the alignment position to survive filtering.

rt_modulation

Retention time tolerance parameter for pairwise alignments.

top_n_peaks

Number of peaks (starting with the largest) to include in the output.

gap_penalty

Type:    float

Gap parameter for pairwise alignments.

min_peak_area

Type:    float

Minimum area of peaks to include in the output.

min_peaks

Type:    int

Minimum number of peaks required for the alignment position to survive filtering.

If set to -1 the number of repeats in the project are used.

rt_modulation

Type:    float

Retention time tolerance parameter for pairwise alignments.

top_n_peaks

Type:    int

Number of peaks (starting with the largest) to include in the output.

class ConsolidateMethod(name_filter=[], min_match_factor=600, min_appearances=- 1)[source]

Bases: libgunshotmatch.method.MethodBase

Method used for consolidation (finding most likely identity for aligned peaks).

Parameters
  • name_filter (Iterable[str]) – List of glob-style matches for compound names. Consolidated peaks matching any of these will be excluded. Default [].

  • min_match_factor (int) – Minimum average match factor. Consolidated peaks with an average match factor below this will be excluded. Default 600.

  • min_appearances (int) – Number of times the hit must appear across the individual aligned peaks. Consolidated peaks where the most common hit appears fewer times than this will be excluded. If set to -1 the number of instances of the peak in the project are used. Default -1.

Changed in version 0.2.0: Added the min_appearances argument.

Attributes:

min_appearances

Number of times the hit must appear across the individual aligned peaks.

min_match_factor

Minimum average match factor.

name_filter

List of glob-style matches for compound names.

min_appearances

Type:    int

Number of times the hit must appear across the individual aligned peaks.

Consolidated peaks where the most common hit appears fewer times than this will be excluded.

If set to -1 the number of instances of the peak in the project are used.

New in version 0.2.0.

min_match_factor

Type:    int

Minimum average match factor.

Consolidated peaks with an average match factor below this will be excluded.

name_filter

Type:    List[str]

List of glob-style matches for compound names.

Consolidated peaks matching any of these will be excluded.

class SavitzkyGolayMethod(enable=True, window=7, degree=2)[source]

Bases: libgunshotmatch.method.MethodBase

Method parameters for the Savitzky-Golay filter.

New in version 0.3.0.

Parameters
  • enable (bool) – Whether to perform Savitzky-Golay smoothing. Default True.

  • window (Union[str, int]) – The window size for the Savitzky-Golay filter. Either a number of scans or a must be the form '<NUMBER>s' or '<NUMBER>m', specifying a time in seconds or minutes, respectively. Default 7.

  • degree (int) – The degree of the fitting polynomial for the Savitzky-Golay filter. Default 2.

Attributes:

degree

The degree of the fitting polynomial for the Savitzky-Golay filter.

enable

Whether to perform Savitzky-Golay smoothing.

window

The window size for the Savitzky-Golay filter.

degree

Type:    int

The degree of the fitting polynomial for the Savitzky-Golay filter.

enable

Type:    bool

Whether to perform Savitzky-Golay smoothing.

window

Type:    Union[str, int]

The window size for the Savitzky-Golay filter.

Either a number of scans or a must be the form '<NUMBER>s' or '<NUMBER>m', specifying a time in seconds or minutes, respectively.