Envelope Search¶
The ms_deisotope.deconvolution
module contains algorithms for deisotoping
centroided mass spectra, computing the monoisotopic neutral mass and charge of
each fitted envelope. There are two types of searches that can be used, envelope
search can be targeted, using a list of compositions, or exhaustive using an average
monomer isotopic model or averagine [Senko].
These strategies are implemented as large object hierarchies, but the high level
function deconvolute_peaks()
encapsulates the process for most use cases.
import ms_deisotope
deconvoluted_peaks, targeted = ms_deisotope.deconvolute_peaks(peaks, averagine=ms_deisotope.peptide,
scorer=ms_deisotope.MSDeconVFitter(10.))
Table of Contents
This module defines a collection of isotopic envelope search strategies for
deisotoping and charge state deconvolution. Each strategy is implemented through
a subtype of DeconvoluterBase
and provide a common set of methods for
deconvolving a peak list.
High Level API¶
- ms_deisotope.deconvolution.deconvolute_peaks(peaklist, decon_config=None, charge_range=(1, 8), error_tolerance=2e-05, priority_list=None, left_search_limit=1, right_search_limit=0, left_search_limit_for_priorities=None, right_search_limit_for_priorities=None, verbose_priorities=False, verbose=False, charge_carrier=1.00727646677, truncate_after=0.95, iterations=10, deconvoluter_type=<class 'ms_deisotope.deconvolution.averagine_based.AveraginePeakDependenceGraphDeconvoluter'>, retention_strategy=None, use_quick_charge=False, **kwargs)[source]¶
Deconvolute a centroided mass spectrum.
This function constructs a deconvoluter object using the
deconvoluter_type
argument and deconvolutes the inputpeaklist
by calling itsdeconvolute()
method.If
priority_list
is notNone
, it is expected to be an iterable of either tuples of (FittedPeak
,(min charge, max charge)
) pairs, or instances ofPriorityTarget
. These will be passed totargeted_deconvolution()
of the deconvoluter.
- Parameters
peaklist (
PeakSet
or list of Peak-like objects, seeprepare_peaklist()
) – The centroided mass spectrum to deconvolute.decon_config (dict, optional) – Parameters to use to initialize the deconvoluter instance produced by
deconvoluter_type
charge_range (tuple of integers, optional) – The range of charge states to consider. The range is inclusive.
error_tolerance (float, optional) – PPM error tolerance to use to match experimental to theoretical peaks
priority_list (list, optional) – The set of peaks to target for deconvolution to be able to enforce external constraints on, such as selected precursors for fragmentation.
left_search_limit (int, optional) – The maximum number of neutron shifts to search to the left (decrease) from each query peak
right_search_limit (int, optional) – The maximum number of neutron shifts to search to the right (increase) from each query peak
left_search_limit_for_priorities (int, optional) – The maximum number of neutron shifts to search to the left (decrease) from each query peak for priority targets
right_search_limit_for_priorities (int, optional) – The maximum number of neutron shifts to search to the right (increase) from each query peak for priority targets
verbose_priorities (bool, optional) – Whether to turn on verbose mode for priority targets
verbose (bool, optional) – Passed to the deconvoluter to enable verbose mode globally
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percentage of the isotopic pattern to include. Defaults to 0.95
deconvoluter_type (type or callable, optional) – A callable returning a deconvoluter. Defaults to
AveraginePeakDependenceGraphDeconvoluter
retention_strategy (
PeakRetentionStrategyBase
or callable, optional) – A callable that may compute additional peaks to include in the output deconvoluted peaks.use_quick_charge (
bool
) – Whether or not to use the QuickCharge algorithm to quickly filter theoretical charge states to consider for each peak.**kwargs – Additional keywords included in
decon_config
See also
Notes
If speed is an issue, consider setting use_quick_charge
True
. This will pre-screen charge states that are are missing peaks supporting the monoisotopic peak or the A+1 peak. Alternatively, you may set the charge range upper bound to something reasonable for your data, such as the precursor ion’s charge when considering a product ion spectrum.When you do not expect a complete isotopic pattern for large ions, as is often the case for low abundance FT-MS/MS it may be useful to shrink the truncate_after parameter from the default (0.95) to a slightly smaller value.
- Returns
- Return type
Parameter Recomendations and Commentary¶
Because deconvolution can be a fussy problem to solve when dealing with disparate instrument types and signal qualities, here are some notes when tuning parameters.
Missing High Mass Ions? Understanding how and when to use truncate_after¶
Note
Short Answer: Use 0.95 for MS1 and 0.8 for MSn spectra, or experiment with incremental_truncation
.
Theoretical isotopic patterns can simulate any number of isotopic peaks, though outside of native MS of large
molecules, most of these isotopic peaks are trivially small and undetectable. ms_deisotope
uses a truncation
strategy to stop including isotopic peaks after truncate_after
* 100% of the signal has been observed in an
isotopic pattern. By default truncate_after
is 0.95, which I’ve found works well for MS1 spectra on all instruments.
This is trivial for most biomolecules below 800 Da, but as molecules grow larger, the theoretical pattern starts to
exceed the instrument’s ability to detect all peaks within 95% of the isotopic pattern, especially on highly processed
spectra like FTMS from Orbitraps. For MSn spectra, ions often appear on both sides of this line, making it especially
important to account for. For these spectra, I have found truncate_after
at 0.8 works well.
There is another option, which is to use the experimental incremental_truncation
strategy which takes each isotopic
pattern after truncate_after
and considers variants incrementally dropping trailing peaks until incremental_truncation
* 100% of the signal from the starting pattern remains. Starting with truncate_after
set to 0.999 and incremental_truncation
set to 0.8 will allow you to match both ends of the spectrum, but at the cost of doing a bit more work per peak.
quick_charge To Speed Things Up¶
Use quick_charge
= True
when missing peaks around the monoisotopic peak are not an issue to drastically cut
down on the number of theoretical pattern fits that need to be performed per peak.
Searching Left and Right¶
When using one of the graph-based algorithms for complex spectra (the default), these parameters are superfluous. When using one of the much simpler algorithms suitable for deconvolution of limited complexity data or targeted deconvolution only, these parameters benefit from being set to a value between 1 and 3, depending upon the distance form the base peak of an isotopic pattern to the monoisotopic peak.
When To Use priority_list¶
The priority_list
parameter is really only useful when you need to tie a specific deconvolution result to a specific experimental
peak, as in the case of extracting the deconvoluting a precursor ion while also deconvolving the entire spectrum. Unless you have these
types of scenarios, this argument is not generally necessary. It does get used heavily by ms_deisotope.processor.ScanProcessor
.
Algorithms for Complex Spectra¶
The following algorithms are appropriate for deconvoluting complex, partially
overlapping isotopic envelopes. The default algorithm used by all functions is
AveraginePeakDependenceGraphDeconvoluter
.
- class ms_deisotope.deconvolution.AveraginePeakDependenceGraphDeconvoluter(peaklist, *args, **kwargs)[source]¶
A Deconvoluter which uses an averagine [1] model to generate theoretical isotopic patterns for each peak to consider, using a peak dependence graph to solve complex mass spectra.
Extends
AveragineDeconvoluter
to include features fromPeakDependenceGraphDeconvoluterBase
making it suitable for deconvoluting complex spectra where peak overlaps are common.
- peaklist¶
The centroided mass spectrum to deconvolute
- Type
PeakSet
- scorer¶
The criterion for evaluating individual isotopic pattern fits
- Type
- averagine¶
The averagine model and associated theoretical isotopic pattern cache to use to build theoretical isotopic patterns.
- Type
- max_missed_peaks¶
The maximum number of missing peaks to tolerate in an isotopic fit
- Type
int
- peak_dependency_network¶
The peak dependence graph onto which isotopic fit dependences on peaks are constructed and solved.
- Type
- merge_isobaric_peaks¶
If multiple passes produce peaks with identical mass values, should those peaks be summed
- Type
bool
- minimum_intensity¶
Experimental peaks whose intensity is below this level will be ignored by peak querying methods
- Type
float
- scale_method¶
The name of the method to use to scale theoretical isotopic pattern intensities to match the experimental isotopic pattern. For a description of options, see
scale()
.
- Type
str
- use_subtraction¶
Whether or not to apply a subtraction procedure to experimental peaks after they have been fitted. This is only necessary if the same signal may be examined multiple times as in a multi-pass method or when peak dependence is not considered
- Type
bool
- verbose¶
Produce extra logging information
- Type
bool
References
- [1] Senko, M. W., Beu, S. C., & McLafferty, F. W. (1995). Determination of monoisotopic masses and ion populations
for large biomolecules from resolved isotopic distributions. Journal of the American Society for Mass Spectrometry, 6(4), 229–233. http://doi.org/10.1016/1044-0305(95)00017-8
- charge_state_determination(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)¶
Determine the optimal isotopic fit for peak, extracting it’s charge state and monoisotopic peak.
This method invokes
_fit_all_charge_states()
, and then usesscorer
’s select method to choose the optimal solution.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
The best scoring isotopic fit
- Return type
- deconvolute(error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=1, right_search_limit=0, iterations=10, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, convergence=0.001, **kwargs)¶
Completely deconvolute the spectrum.
For each iteration, clear
peak_depencency_network
, then invokepopulate_graph()
followed byselect_best_disjoint_subgraphs()
to populate the resultingDeconvolutedPeakSet
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
order_chooser (callable, optional:) – A callable used as a key function for sorting peaks into the order they will be visited during deconvolution. Defaults to
operator.attrgetter("index")
left_search_limit (int, optional) – The number of steps to search to the left of
peak
. Defaults to 1right_search_limit (int, optional) – The number of steps to search to the right of
peak
. Defaults to 0charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
ignore_below (float, optional) – The minimum relative abundance to consider a peak in a theoretical isotopic pattern
convergence (float, optional) – The threshold of the below which after the (sum(intensity_before) - sum( intensity_after)) / sum(intensity_after)
- Returns
- Return type
- populate_graph(DeconvoluterBase self, error_tolerance=ERROR_TOLERANCE, charge_range=(1, 8), left_search_limit=1, right_search_limit=0, charge_carrier=PROTON, truncate_after=TRUNCATE_AFTER, ignore_below=IGNORE_BELOW)¶
Visit each experimental peak and execute
_explore_local()
on it with the provided parameters, populating the peak dependence graph with all viable candidates.
- Parameters
peak (
FittedPeak
) –error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 1
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 0
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- targeted_deconvolution(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)¶
Express the intent that this peak’s deconvolution solution will be retrieved at a later point in the process and that it should be deconvoluted, and return a handle to retrieve the results with.
As the operation does not immediately result in a deconvoluted peak but just adds the resulting fits to
peak_dependency_network
, this method constructs an instance ofNetworkedTargetedDeconvolutionResult
which holds all the required information for recovering the best fit containing peak.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
- Returns
- Return type
- class ms_deisotope.deconvolution.CompositionListPeakDependenceGraphDeconvoluter(peaklist, composition_list, scorer, use_subtraction=False, scale_method='sum', verbose=False, use_quick_charge=False, **kwargs)[source]¶
Fit exact isotopic patterns from a list of compositions.
Fits are added to a peak dependence graph, and the best fit is chosen after all fits are calculated at each iteration.
- composition_list¶
A series of objects which represent elemental compositions and support the
Mapping
interface to access their individual elements.
- Type
list of
Mapping
- peaklist¶
The collection of ms_peak_picker.FittedPeak instances and possible associated data to deconvolute.
- Type
PeakSet
- scorer¶
The criterion for evaluating individual isotopic pattern fits
- Type
- max_missed_peaks¶
The maximum number of missing peaks to tolerate in an isotopic fit
- Type
int
- peak_dependency_network¶
The peak dependence graph onto which isotopic fit dependences on peaks are constructed and solved.
- Type
PeakDependenceGraph
- merge_isobaric_peaks¶
If multiple passes produce peaks with identical mass values, should those peaks be summed
- Type
bool
- minimum_intensity¶
Experimental peaks whose intensity is below this level will be ignored by peak querying methods
- Type
float
- scale_method¶
The name of the method to use to scale theoretical isotopic pattern intensities to match the experimental isotopic pattern. For a description of options, see
scale()
.
- Type
str
- use_subtraction¶
Whether or not to apply a subtraction procedure to experimental peaks after they have been fitted. This is only necessary if the same signal may be examined multiple times as in a multi-pass method or when peak dependence is not considered
- Type
bool
- verbose¶
Produce extra logging information
- Type
bool
- deconvolute(error_tolerance=2e-05, charge_range=(1, 8), iterations=10, truncate_after=0.95, charge_carrier=1.00727646677, ignore_below=0.001, mass_shift=None, convergence=0.001, **kwargs)[source]¶
Deconvolute the spectrum, extracting isotopic patterns from the composition list.
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An optional mass shift to apply to each composition
convergence (float, optional) – The threshold of the below which after the (sum(intensity_before) - sum( intensity_after)) / sum(intensity_after)
- Returns
- Return type
- deconvolute_composition(composition, error_tolerance=2e-05, charge_range=(1, 8), charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, mass_shift=None)[source]¶
For each charge state under consideration, fit the theoretical isotopic pattern for this composition, and if the fit is satisfactory, add it to the results set.
- Parameters
composition (
Mapping
) – An object representing an elemental compositionerror_tolerance (float) – The mass accuracy required to for peak matches
charge_range (tuple) – The charge state range to generate the isotopic patterns for
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An arbitrary mass shift to apply to the generated theoretical isotopic pattern, moving all peaks forward by that mass charge ratio transformed mass.
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
- populate_graph(error_tolerance=2e-05, charge_range=(1, 8), truncate_after=0.95, charge_carrier=1.00727646677, ignore_below=0.001, mass_shift=None)[source]¶
For each composition, for each charge state under consideration, fit the theoretical isotopic pattern for this composition, and if the fit is satisfactory, add it to the peak dependence graph for later selecting the optimal solution.
- Parameters
error_tolerance (float) – The mass accuracy required to for peak matches
charge_range (tuple) – The charge state range to generate the isotopic patterns for
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
mass_shift (float, optional) – An arbitrary mass shift to apply to the generated theoretical isotopic pattern, moving all peaks forward by that mass charge ratio transformed mass.
If your data do not conform to a single averagine,
MultipleAveraginePeakDependenceGraphDeconvoluter
can take alist
ofAveragine
objects, selecting the best averagine for each experimental isotopic pattern.
Algorithms for Simple Spectra¶
These algorithms do not take into account the optimal peak assignment across fits and should be used only for spot-checks or for simple spectra where best fit resolution across multiple fits is not required.
- class ms_deisotope.deconvolution.AveragineDeconvoluter(peaklist, averagine=None, scorer=PenalizedMSDeconVFitter((MaximizeFitSelector(minimum_score=10.0), 1.0, 0.02)), use_subtraction=True, scale_method='sum', verbose=False, **kwargs)[source]¶
A Deconvoluter which uses an averagine [1] model to generate theoretical isotopic patterns for each peak to consider. Combines
AveragineDeconvoluterBase
andExhaustivePeakSearchDeconvoluterBase
to create a working Deconvoluter type.
- averagine¶
The averagine model and associated theoretical isotopic pattern cache to use to build theoretical isotopic patterns.
- Type
- peaklist¶
The collection of ms_peak_picker.FittedPeak instances and possible associated data to deconvolute.
- Type
PeakSet
- scorer¶
The criterion for evaluating individual isotopic pattern fits
- Type
- verbose¶
How much diagnostic information to provide
- Type
bool
References
- [1] Senko, M. W., Beu, S. C., & McLafferty, F. W. (1995). Determination of monoisotopic masses and ion populations
for large biomolecules from resolved isotopic distributions. Journal of the American Society for Mass Spectrometry, 6(4), 229–233. http://doi.org/10.1016/1044-0305(95)00017-8
- charge_state_determination(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)¶
Determine the optimal isotopic fit for peak, extracting it’s charge state and monoisotopic peak.
This method invokes
_fit_all_charge_states()
, and then usesscorer
’s select method to choose the optimal solution.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
The best scoring isotopic fit
- Return type
- deconvolute(error_tolerance=2e-05, charge_range=(1, 8), order_chooser=operator.attrgetter('index'), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, **kwargs)¶
Completely deconvolute the spectrum.
Visit each peak in the order chosen by order_chooser, and call
deconvolute_peak()
on it with the provided arguments. This assumes all overlaps in isotopic pattern are captured by the search limits. This is usually not the case. For an alternative seePeakDependenceGraphDeconvoluterBase
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
order_chooser (callable, optional:) – A callable used as a key function for sorting peaks into the order they will be visited during deconvolution. Defaults to
operator.attrgetter("index")
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
- Return type
- targeted_deconvolution(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)¶
Express the intent that this peak’s deconvolution solution will be retrieved at a later point in the process and that it should be deconvoluted, and return a handle to retrieve the results with.
This algorithm’s implementation is simple enough that this is equivalent to just performing the deconvolution now and storing the result in a
TrivialTargetedDeconvolutionResult
instance.Otherwise identical to
deconvolute_peak()
.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
- Return type
TrivialTargetedDeconvolutionResult
- class ms_deisotope.deconvolution.CompositionListDeconvoluter(peaklist, composition_list, scorer, use_subtraction=False, scale_method='sum', verbose=False, use_quick_charge=False, **kwargs)[source]¶
Fit exact isotopic patterns from a list of compositions.
Fits are accepted as they are made, making this algorithm unsuitable for complex spectra where isotopic patterns will share peaks.
- composition_list¶
A series of objects which represent elemental compositions and support the
Mapping
interface to access their individual elements.
- Type
list of
Mapping
- peaklist¶
The collection of
FittedPeak
instances and possible associated data to deconvolute.
- Type
PeakSet
- scorer¶
The criterion for evaluating individual isotopic pattern fits
- Type
- merge_isobaric_peaks¶
If multiple passes produce peaks with identical mass values, should those peaks be summed
- Type
bool
- minimum_intensity¶
Experimental peaks whose intensity is below this level will be ignored by peak querying methods
- Type
float
- scale_method¶
The name of the method to use to scale theoretical isotopic pattern intensities to match the experimental isotopic pattern. For a description of options, see
scale()
.
- Type
str
- use_subtraction¶
Whether or not to apply a subtraction procedure to experimental peaks after they have been fitted. This is only necessary if the same signal may be examined multiple times as in a multi-pass method or when peak dependence is not considered
- Type
bool
- verbose¶
Produce extra logging information
- Type
bool
- deconvolute(error_tolerance=2e-05, charge_range=(1, 8), charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, mass_shift=None, **kwargs)[source]¶
Deconvolute the spectrum, extracting isotopic patterns from the composition list.
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An optional mass shift to apply to each composition
- Returns
- Return type
- deconvolute_composition(composition, error_tolerance=2e-05, charge_range=(1, 8), charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, mass_shift=None)¶
For each charge state under consideration, fit the theoretical isotopic pattern for this composition, and if the fit is satisfactory, add it to the results set.
- Parameters
composition (
Mapping
) – An object representing an elemental compositionerror_tolerance (float) – The mass accuracy required to for peak matches
charge_range (tuple) – The charge state range to generate the isotopic patterns for
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An arbitrary mass shift to apply to the generated theoretical isotopic pattern, moving all peaks forward by that mass charge ratio transformed mass.
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
Base Classes¶
- class ms_deisotope.deconvolution.DeconvoluterBase(use_subtraction=False, scale_method='sum', merge_isobaric_peaks=True, minimum_intensity=5., *args, **kwargs)¶
Base class for all Deconvoluter types. Provides basic configuration for common operations, regardless of implementation. Because these methods form the backbone of all deconvolution algorithms, this class has a C-extension implementation as well.
- peaklist¶
The centroided mass spectrum to deconvolute
- Type
ms_peak_picker.PeakSet
- scorer¶
The criterion for evaluating individual isotopic pattern fits
- Type
- merge_isobaric_peaks¶
If multiple passes produce peaks with identical mass values, should those peaks be summed
- Type
bool
- minimum_intensity¶
Experimental peaks whose intensity is below this level will be ignored by peak querying methods
- Type
float
- scale_method¶
The name of the method to use to scale theoretical isotopic pattern intensities to match the experimental isotopic pattern. For a description of options, see
scale()
.
- Type
str
- use_subtraction¶
Whether or not to apply a subtraction procedure to experimental peaks after they have been fitted. This is only necessary if the same signal may be examined multiple times as in a multi-pass method or when peak dependence is not considered
- Type
bool
- verbose¶
Produce extra logging information
- Type
bool
- between(self, double m1, double m2) PeakSet ¶
- fit_incremental_truncation(self, IsotopicFitRecord seed_fit, double lower_bound) list ¶
Fit incrementally truncated versions of the seed fit to check to see if a narrower theoretical fit matches the data better.
- Parameters
seed_fit (
IsotopicFitRecord
) – The original fit to explore truncations oflower_bound (float) – The percentage of total signal remaining to stop truncating at.
- Returns
- Return type
list
ofIsotopicFitRecord
- has_peak(self, double mz, double error_tolerance) FittedPeak ¶
- match_theoretical_isotopic_distribution(self, list theoretical_distribution, double error_tolerance=2e-5) list ¶
- merge_isobaric_peaks¶
‘bool’
- Type
merge_isobaric_peaks
- minimum_intensity¶
‘double’
- Type
minimum_intensity
- peaklist¶
ms_peak_picker._c.peak_set.PeakSet
- Type
peaklist
- scale_method¶
str
- Type
scale_method
- scale_theoretical_distribution(self, TheoreticalIsotopicPattern theoretical_distribution, list experimental_distribution)¶
- scorer¶
ms_deisotope._c.scoring.IsotopicFitterBase
- Type
scorer
- subtraction(self, TheoreticalIsotopicPattern isotopic_cluster, double error_tolerance=2e-5)¶
- use_subtraction¶
‘bool’
- Type
use_subtraction
- verbose¶
‘bool’
- Type
verbose
- class ms_deisotope.deconvolution.AveragineDeconvoluterBase(bool use_subtraction=False, str scale_method='sum', bool merge_isobaric_peaks=True, double minimum_intensity=5., *args, **kwargs)¶
A base class derived from
DeconvoluterBase
which provides some common methods for fitting isotopic patterns using an Averagine model.
- averagine¶
ms_deisotope._c.averagine.AveragineCache
- Type
averagine
- fit_theoretical_distribution(self, FittedPeak peak, double error_tolerance, int charge, double charge_carrier=PROTON, double truncate_after=0.95, double ignore_below=0) IsotopicFitRecord ¶
- class ms_deisotope.deconvolution.CompositionListDeconvoluterBase(composition_list, *args, **kwargs)[source]¶
A mixin class to provide common features for deconvoluters which process spectra using a list of targeted compositions.
- composition_list¶
A series of objects which represent elemental compositions and support the
Mapping
interface to access their individual elements.
- Type
list of
Mapping
- deconvolute_composition(composition, error_tolerance=2e-05, charge_range=(1, 8), charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, mass_shift=None)[source]¶
For each charge state under consideration, fit the theoretical isotopic pattern for this composition, and if the fit is satisfactory, add it to the results set.
- Parameters
composition (
Mapping
) – An object representing an elemental compositionerror_tolerance (float) – The mass accuracy required to for peak matches
charge_range (tuple) – The charge state range to generate the isotopic patterns for
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An arbitrary mass shift to apply to the generated theoretical isotopic pattern, moving all peaks forward by that mass charge ratio transformed mass.
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
- fit_composition_at_charge(composition, charge, error_tolerance=2e-05, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, mass_shift=None)[source]¶
Produce an isotopic fit for composition at charge against the experimental peak set.
This method requires that the instance also possess a method named match_theoretical_isotopic_distribution such as the one implemented in
DeconvoluterBase
.
- Parameters
composition (
Mapping
) – An object representing an elemental compositioncharge (int) – The charge state to generate the isotopic pattern for
error_tolerance (float) – The mass accuracy required to for peak matches
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An arbitrary mass shift to apply to the generated theoretical isotopic pattern, moving all peaks forward by that mass charge ratio transformed mass.
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
- Returns
- Return type
- generate_theoretical_isotopic_cluster(composition, charge, truncate_after=0.95, mass_shift=None, charge_carrier=1.00727646677, ignore_below=0.001)[source]¶
Generate a theoretical isotopic pattern for
composition
- Parameters
composition (
Mapping
) – An object representing an elemental compositioncharge (int) – The charge state to generate the isotopic pattern for
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
mass_shift (float, optional) – An arbitrary mass shift to apply to the generated theoretical isotopic pattern, moving all peaks forward by that mass charge ratio transformed mass.
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
- Returns
The theoretical isotopic pattern generated
- Return type
- recalibrate_theoretical_mz(theoretical_distribution, experimental_mz)[source]¶
Recalibrate the m/z of the theoretical isotopic pattern to start from the peak matching the experimental monoisotopic m/z
- Parameters
theoretical_distribution (
TheoreticalIsotopicPattern
) – The theoretical isotopic pattern to adjustexperimental_mz (float) – The experimental monoisotopic peak m/z
- Returns
- Return type
- class ms_deisotope.deconvolution.ExhaustivePeakSearchDeconvoluterBase(peaklist, *args, **kwargs)[source]¶
Provides common methods for algorithms which attempt to find a deconvolution for every peak in a spectrum. This assumes no dependence between different peaks, instead it relies on subtraction, breadth of search, and order of encounter to avoid artefactual fits. This is usually not reasonable, so instead please use this class’s extension,
PeakDependenceGraphDeconvoluterBase
which can express dependence of fits on common resources.This class is not meant to be instantiated, but instead used as a mixin for classes that also inherit from
DeconvoluterBase
and provide methods fit_theoretical_distribution and _fit_peaks_at_charges
- use_quick_charge¶
Whether or not to use the QuickCharge algorithm when generating putative charge states.
- Type
bool
- incremental_truncation¶
If not
None
, the isotopic pattern truncation lower bound to contract each fit to incrementally, generating new fits for each dropped peak usingfit_incremental_truncation()
- Type
float or
None
- charge_state_determination(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)[source]¶
Determine the optimal isotopic fit for peak, extracting it’s charge state and monoisotopic peak.
This method invokes
_fit_all_charge_states()
, and then usesscorer
’s select method to choose the optimal solution.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
The best scoring isotopic fit
- Return type
- deconvolute(error_tolerance=2e-05, charge_range=(1, 8), order_chooser=operator.attrgetter('index'), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, **kwargs)[source]¶
Completely deconvolute the spectrum.
Visit each peak in the order chosen by order_chooser, and call
deconvolute_peak()
on it with the provided arguments. This assumes all overlaps in isotopic pattern are captured by the search limits. This is usually not the case. For an alternative seePeakDependenceGraphDeconvoluterBase
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
order_chooser (callable, optional:) – A callable used as a key function for sorting peaks into the order they will be visited during deconvolution. Defaults to
operator.attrgetter("index")
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
- Return type
- deconvolute_peak(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)[source]¶
Perform a deconvolution for peak, generating a new
ms_deisotope.peak_set.DeconvolutedPeak
instance corresponding to the optimal solution.This new peak has an m/z matching the monoisotopic peak of the pattern containing peak, and its intensity is the sum of all the matched peaks in its isotopic pattern. Its charge, isotopic fit, and other qualities are derived from the
ms_deisotope.scoring.IsotopicFitRecord
instance corresponding to its best solution.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier, or more specifically, the moiety which is added for each incremental change in charge state. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
- Return type
- targeted_deconvolution(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)[source]¶
Express the intent that this peak’s deconvolution solution will be retrieved at a later point in the process and that it should be deconvoluted, and return a handle to retrieve the results with.
This algorithm’s implementation is simple enough that this is equivalent to just performing the deconvolution now and storing the result in a
TrivialTargetedDeconvolutionResult
instance.Otherwise identical to
deconvolute_peak()
.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- Returns
- Return type
TrivialTargetedDeconvolutionResult
- class ms_deisotope.deconvolution.PeakDependenceGraphDeconvoluterBase(peaklist, *args, **kwargs)[source]¶
Extends the concept of
ExhaustivePeakSearchDeconvoluterBase
to include a way to handle conflicting solutions which claim the same experimental peak.This lets the Deconvoluter assign a single peak only once, and to the “best” solution to use it. To do this, the Deconvoluter constructs a graph where peaks are nodes, and isotopic fits are hyperedges connecting multiple nodes. Rather than deconvoluting the spectrum step by step, assigning signal as it explores the spectrum, the Deconvoluter instead inserts each considered isotopic fit into the graph. After completely traversing the spectrum, the Deconvoluter solves the dependence graph attempting to maximize some criterion and produce a set of disjoint isotopic fits. These fits are then assigned signal and added to the deconvoluted spectrum as normal.
The criterion used is currently a greedy maximization (or minimization) of each connected component of the peak dependence graph.
- max_missed_peaks¶
The maximum number of missing peaks to tolerate in an isotopic fit
- Type
int
- peak_dependency_network¶
The peak dependence graph onto which isotopic fit dependences on peaks are constructed and solved.
- Type
- deconvolute(error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=1, right_search_limit=0, iterations=10, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001, convergence=0.001, **kwargs)[source]¶
Completely deconvolute the spectrum.
For each iteration, clear
peak_depencency_network
, then invokepopulate_graph()
followed byselect_best_disjoint_subgraphs()
to populate the resultingDeconvolutedPeakSet
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
order_chooser (callable, optional:) – A callable used as a key function for sorting peaks into the order they will be visited during deconvolution. Defaults to
operator.attrgetter("index")
left_search_limit (int, optional) – The number of steps to search to the left of
peak
. Defaults to 1right_search_limit (int, optional) – The number of steps to search to the right of
peak
. Defaults to 0charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
ignore_below (float, optional) – The minimum relative abundance to consider a peak in a theoretical isotopic pattern
convergence (float, optional) – The threshold of the below which after the (sum(intensity_before) - sum( intensity_after)) / sum(intensity_after)
- Returns
- Return type
- property max_missed_peaks¶
The maximum number of missed peaks per isotopic fit record permitted.
This property directly mirrors
PeakDependenceGraph.max_missed_peaks
- Returns
- Return type
int
- populate_graph(DeconvoluterBase self, error_tolerance=ERROR_TOLERANCE, charge_range=(1, 8), left_search_limit=1, right_search_limit=0, charge_carrier=PROTON, truncate_after=TRUNCATE_AFTER, ignore_below=IGNORE_BELOW)¶
Visit each experimental peak and execute
_explore_local()
on it with the provided parameters, populating the peak dependence graph with all viable candidates.
- Parameters
peak (
FittedPeak
) –error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 1
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 0
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
truncate_after (float, optional) – The percent of intensity to ensure is included in a theoretical isotopic pattern starting from the monoisotopic peak. This will cause theoretical isotopic patterns to be truncated, excluding trailing peaks which do not contribute substantially to the overall shape of the isotopic pattern.
- postprocess_fits(error_tolerance=2e-05, charge_range=(1, 8), charge_carrier=1.00727646677, *args, **kwargs)[source]¶
Postprocesses fits before solving the peak dependence graph.
Currently a no-op.
- Parameters
error_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
- select_best_disjoint_subgraphs(error_tolerance=2e-05, charge_carrier=1.00727646677)[source]¶
Construct connected envelope graphs from
peak_dependency_network
and extract the best disjoint isotopic pattern fits in each envelope graph. This in turn produces one or moreDeconvolutedPeak
instances from each disjoint fit, which are processed and added to the results set.
- Parameters
error_tolerance (float, optional) – The error tolerance to use when performing subtraction, if subtraction is being performed.
charge_carrier (float, optional) – The mass of the charge carrier as used for the deconvolution. Required to back-out the neutral mass of the deconvoluted result
- targeted_deconvolution(peak, error_tolerance=2e-05, charge_range=(1, 8), left_search_limit=3, right_search_limit=3, charge_carrier=1.00727646677, truncate_after=0.95, ignore_below=0.001)[source]¶
Express the intent that this peak’s deconvolution solution will be retrieved at a later point in the process and that it should be deconvoluted, and return a handle to retrieve the results with.
As the operation does not immediately result in a deconvoluted peak but just adds the resulting fits to
peak_dependency_network
, this method constructs an instance ofNetworkedTargetedDeconvolutionResult
which holds all the required information for recovering the best fit containing peak.
- Parameters
peak (
FittedPeak
) – The peak to start the search fromerror_tolerance (float, optional) – The parts-per-million error tolerance in m/z to search with. Defaults to 2e-5
charge_range (tuple, optional) – The range of charge states to consider. Defaults to (1, 8)
left_search_limit (int, optional) – The number of steps to search to the left of peak. Defaults to 3
right_search_limit (int, optional) – The number of steps to search to the right of peak. Defaults to 3
charge_carrier (float, optional) – The mass of the charge carrier. Defaults to 1.0072
- Returns
- Return type
Accounting For Lower Quality Data¶
A set of strategies for retaining peaks following deconvolution to recover from low quality spectra. These methods are not recommended for use on spectra where most ions are multiply charged.
These objects are meant to be provided to deconvolut_peaks()
’s
retention_strategy argument, which will take care of calling them with
the appropriate arguments.
- class ms_deisotope.deconvolution.peak_retention_strategy.PeakRetentionStrategyBase[source]¶
A strategy for retaining peaks left behind by the deconvolution procedure.
Deconvolution requires that the isotopic peak structure is present in the peak list, which may not be consistent for all types of data. This type of method is appropriate when the caller expects real peaks may have been left behind, as is the case with smaller peptides and lower quality tandem mass spectra.
- __call__(peaklist, original_peaklist=None, charge_range=None, solutions=None)[source]¶
A wrapper for
retain_peaks()
. Given a list ofFittedPeak
objects left over after deconvolution, produce a list ofDeconvolutedPeak
objects from them according to some criteria.- Parameters
peaklist (
PeakSet
) – The list of peaks that remain after deconvolutionoriginal_peaklist (
PeakSet
, optional) – The list of peaks that were initially presented for deconvolution, which may be used to infer relative thresholds from. If not provided, these thresholds may be learned from the left over peaks, but the parameters may not be as good.charge_range (
tuple
, optional) – The range of charge states considered during deconvolution. Used to infer the minimum charge state to assign to the peaks this method creates. If not provided, the default charge state is :const`1`.solutions (
DeconvolutedPeakSet
, optional) – The accepted solutions which might be used to infer/reject additional peaks.
- Returns
The list of
DeconvolutedPeak
objects.- Return type
list
See also
- create_peak(fitted_peak, charge=1)[source]¶
Create a
DeconvolutedPeak
from a givenFittedPeak
peak
and an optional charge state.- Parameters
fitted_peak (
FittedPeak
) – The peak to treat as the monoisotopic peak of the unfitted deconvoluted peakcharge (int, optional) – The charge state to specify the peak at (the default is 1)
- Returns
- Return type
- infer_minimum_charge(charge_range)[source]¶
Given a charge range
tuple
, return the smallest absolute magnitude charge state possible in that range.This method is polarity aware, and does its reasoning on the absolute magnitude of the charge state range, rather than on its signed value.
- Parameters
charge_range (
tuple
) – The range of charge values that were used during the deconvolution process- Returns
The minimum charge state.
- Return type
int
- abstract retain_peaks(peaklist, original_peaklist=None, charge_range=None, solutions=None)[source]¶
Given a list of
FittedPeak
objects left over after deconvolution, produce a list ofDeconvolutedPeak
objects from them according to some criteria.Deconvolution requires that the isotopic peak structure is present in the peak list, which may not be consistent for all types of data. This type of method is appropriate when the caller expects real peaks may have been left behind, as is the case with smaller peptides and lower quality tandem mass spectra.
- Parameters
peaklist (
PeakSet
) – The list of peaks that remain after deconvolutionoriginal_peaklist (
PeakSet
, optional) – The list of peaks that were initially presented for deconvolution, which may be used to infer relative thresholds from. If not provided, these thresholds may be learned from the left over peaks, but the parameters may not be as good.charge_range (
tuple
, optional) – The range of charge states considered during deconvolution. Used to infer the minimum charge state to assign to the peaks this method creates. If not provided, the default charge state is :const`1`.solutions (
DeconvolutedPeakSet
, optional) – The accepted solutions which might be used to infer/reject additional peaks.
- Returns
The list of
DeconvolutedPeak
objects.- Return type
list
- class ms_deisotope.deconvolution.peak_retention_strategy.TopNRetentionStrategy(n_peaks=50, base_peak_coefficient=0.05, max_mass=850.0)[source]¶
This strategy retains up to at most
n_peaks
peaks from the leftover signal, and requires that any peaks it retains are atleastbase_peak_coefficient
* the base peak of the original peak list.This strategy treats the leftover peak as if it were the monoisotopic peak of an unobserved isotopic distribution. Because the monoisotopic peak ceases to dominate an isotopic distribution above a certain mass (as implied by an averagine isotopic model), any peak selected must have a neutral mass below
max_mass
.- n_peaks¶
The maximum number of peaks to retain.
- Type
int
- base_peak_coefficient¶
The fraction of the base peak intensity to threshold on. Defaults to
0.05
- Type
float
- max_mass¶
The largest neutral mass that a peak may have before it would no longer have a dominant monoisotopic peak and the peak will be discarded.
- Type
float
- retain_peaks(peaklist, original_peaklist=None, charge_range=None, solutions=None)[source]¶
Given a list of
FittedPeak
objects left over after deconvolution, produce a list ofDeconvolutedPeak
objects from them according to some criteria.Deconvolution requires that the isotopic peak structure is present in the peak list, which may not be consistent for all types of data. This type of method is appropriate when the caller expects real peaks may have been left behind, as is the case with smaller peptides and lower quality tandem mass spectra.
- Parameters
peaklist (
PeakSet
) – The list of peaks that remain after deconvolutionoriginal_peaklist (
PeakSet
, optional) – The list of peaks that were initially presented for deconvolution, which may be used to infer relative thresholds from. If not provided, these thresholds may be learned from the left over peaks, but the parameters may not be as good.charge_range (
tuple
, optional) – The range of charge states considered during deconvolution. Used to infer the minimum charge state to assign to the peaks this method creates. If not provided, the default charge state is :const`1`.solutions (
DeconvolutedPeakSet
, optional) – The accepted solutions which might be used to infer/reject additional peaks.
- Returns
The list of
DeconvolutedPeak
objects.- Return type
list
ms_deisotope.deconvolution.peak_retention_strategy.simple_peak_retention
is an instance of
TopNRetentionStrategy
with n_peaks=50, base_peak_coefficient=0.05, max_mass=850.0, the default
values.
Utilities and Implementation Details¶
- ms_deisotope.deconvolution.utils.prepare_peaklist(peaks)[source]¶
Ensure
peaks
is aPeakSet
object, converting from other compatible types as needed. Additionally, make a deep copy of the peaks as signal subtraction methods will modify peaks in place.This function ensures that any of the following common input types are coerced to the appropriate type:
ms_peak_picker.PeakSet
will be copied and indexedms_peak_picker.PeakIndex
will have its peaks extracted and copiedAny other sequence of
PeakLike
objects (objects having an mz and intensity attribute) will be converted into ams_peak_picker.PeakSet
A pair of parallel sequences or NumPy arrays corresponding to m/z and intensity values for a series of peaks.
Any sequence of
tuple
orlist
having at least two entries will be converted into ams_peak_picker.PeakSet
with the m/z value of each peak being the the p[0] of each entry and the intensity p[1]. Any other entries will be ignored.
- Parameters
peaks (Sequence) – Any sequence of
FittedPeak
objects, objects withmz
andintensity
attributes, orlist
/tuple
objects containing paired values formz
andintensity
- Returns
- Return type
PeakSet
- class ms_deisotope.utils.DeconvolutionProcessResult(deconvoluter, peak_set, priorities, errors=None)[source]¶
Hold information from a multi-stage deconvolution process.
Emulates an interface matching a tuple of (
peak_set
,priorities
)- deconvoluter¶
The deconvoluter used.
- Type
- errors¶
A list of
Exception
instances that may have been thrown during any stage of deconvolution.- Type
list, optional
- peak_set¶
The resulting deconvoluted peaks
- Type
- priorities¶
The extracted results from the targeted deconvolution list
- Type
list
- class ms_deisotope.utils.TargetedDeconvolutionResultBase(deconvoluter, *args, **kwargs)[source]¶
Base class to store all of the necessary information to retrieve the optimal solution for a single peak.
- deconvoluter¶
The deconvoluter to use to look up the result
- Type
- class ms_deisotope.peak_dependency_network.NetworkedTargetedDeconvolutionResult(deconvoluter, peak, *args, **kwargs)[source]¶
Stores the necessary information to retrieve the local optimal solution for a single peak for a deconvolution algorithm from the optimal fit containing
query_peak
in the set of disjoint best fits for the enclosing connected component- query_peak¶
The peak queried with
- Type
FittedPeak
- solution_peak¶
The optimal solution peak
- Type
- class ms_deisotope.peak_dependency_network.PeakDependenceGraph(peaklist, nodes=None, dependencies=None, max_missed_peaks=1, use_monoisotopic_superceded_filtering=True, maximize=True)[source]¶
- Senko
Senko, M. W., Beu, S. C., & McLafferty, F. W. (1995). Determination of monoisotopic masses and ion populations for large biomolecules from resolved isotopic distributions. Journal of the American Society for Mass Spectrometry, 6(4), 229–233. http://doi.org/10.1016/1044-0305(95)00017-8