Skip to content

multiplierz.spectral_process

Max Alexander edited this page Oct 12, 2018 · 4 revisions

The first substantiative step of most MS analysis workflows is pre-processing the raw spectral data, for example to optimize results from later peptide identification steps. Noise peaks can substantially decrease the usefulness of spectra; while noise cannot be completely eliminated without actually possessing the corresponding analyte identification(s), heuristic filters can be applied which tend to reduce noise.

Of particular note in this module is the peak picking algorithm, which detects isotopic envelopes produced by peptide precursor peaks. On sufficiently high-mass-accuracy spectrometers, these are a highly reliable determinant between valid MS1 precursor peaks and noise, and also can accompany MS2 fragment peaks in spectra derived from some highly-charged precursors. Peak picking is therefore useful both for MS1 precursor identification as well as MS2 spectral cleaning, and serves as a basis for other functions such as deisotope_reduce_scan() in this module, or the Multiplierz feature detection algorithm.


peak_pick(scan, tolerance = 0.005, max_charge = 8, min_peaks = 3, enforce_isotopic_ratios = True)

peak_pick takes a (centroided) scan and returns a dict of isotopic envelopes and a list of unassigned peaks from the scan. Envelopes are returned dictionary indexed by charge. For example:

envelopes, unassigned_peaks = peak_pick(scan_data, tolerance = 0.01)
envelopes_of_charge_3 = envelopes[3]
first_peak_of_first_charge_3_envelope = envelopes_of_charge_3[0][0]
  • max_charge specifies the highest charge state that is considered for potential envelopes.
  • min_peaks specifies the number of peaks that an isotopic envelope requires to be considered valid; for instance, an isolated pair of peaks at 150.0 and 150.5 would be considered an envelope if min_peaks == 2 but not if it is greater.
  • enforce_isotopic_ratios enables a check against the known range of possible relative intensities between each peak in a peptide's isotopic envelope. For example, we've calculated that the relative intensity between a monoisotopic peak and the 1xC13 peak will always be well within 0.5 and 16.2; thus, if a potential envelope exceeds these bounds, it is concluded that the involved peaks represent separate analytes and they are treated appropriately. In some cases (such as peptides that contain non-CHNOPS elements, or isotopic labels), these calculated ratios may not apply, in which case this feature should be disabled. This can also be set to 'permissive', which uses a wider set of ratio tolerances.

The peak picking algorithm is optimized to run quickly, and heavily commented for users who are curious on how the algorithm works.

deisotope_scan(scan, *args, **kwargs)

Built on peak_pick(), this function returns a scan where all identifiably non-monoisotopic peaks have been removed. args and kwargs are passed directly into peak_pick() (so, consider this function to have the same arguments as peak_pick.)

deisotope_reduce_scan(scan, *args, **kwargs)

Similar to deisotope_scan(), except that it replaces isotopic envelopes with a new peak located at the imputed singly-charged M/Z. This can greatly assist peptide identification in cases where highly charged fragment ions are generated, since the database search application can be configured to search the processed spectrum only for singly-charged ions, avoiding the expectation value penalty of having many potential ion matches.

top_n_peaks(scan, N)

Returns a scan containing the most intense N peaks.

exclusion_radius(scan, exclusion)

For every peak in the spectrum, in order of most-to-least intense, takes that peak into the output while discarding all other peaks within the specified exclusion_radius (in Daltons.) Continues until all peaks have been taken or discarded.

signal_noise(scan, minSN)

Filters the spectrum by a signal-to-noise threshold, by finding the subset of lowest-intensity peaks that match a specified minimum signal-to-noise ratio and discarding those.

intensity_threshold(spectrum, threshold)

Discards all peaks in the spectrum that have an intensity below the specified threshold.

mz_range(spectrum, range)

Discards all peaks in the spectrum that are beyond the specified MZ range. range can either be a string of the form '300-2000' or a tuple of two numbers.

Clone this wiki locally