Spectrum utilities
This function is to create a consensus spectrum from a list of spectrums of the same compound all the other components of the generated spectrum such as the charge, . |
|
This function is used to refine a spectrum based on the consensus of the other spectrums any peak that is not in the consensus of the other spectrums is removed. |
|
This function is used to remove the adduct mass from the spectrum |
|
This function is used to add the adduct mass to the spectrum |
- modifinder.utilities.spectrum_utils.add_adduct(spectrum, adduct)[source]
This function is used to add the adduct mass to the spectrum
- Parameters:
spectrum (Spectrum object) – The spectrum to add the adduct mass to
adduct (str) – The adduct to add to the spectrum, should be in the supported adducts list.
Returns: result: Spectrum object
The spectrum with the adduct mass
- modifinder.utilities.spectrum_utils.aggregate_spectrums(spectrums, ppm_tolerance=10, mz_tolerance=0.1, consensus_majority_ratio=0, **kwargs)[source]
This function is to create a consensus spectrum from a list of spectrums of the same compound all the other components of the generated spectrum such as the charge, … are taken from the first spectrum.
if the spectrums have different adducts, the adduct mass is removed from the spectrums before aggregation. The final result is reported with no adduct mass. :param spectrums: The spectrums to be aggregated :type spectrums: list of Spectrum objects :param ppm_tolerance: The tolerance in ppm :type ppm_tolerance: float :param mz_tolerance: The tolerance in mz :type mz_tolerance: float :param consensus_majority_ratio: The ratio of the spectrums that should have the peak to be considered in the consensus
if is 1, all the spectrums should have the peak to be considered in the consensus if is 0, only one spectrum should have the peak to be considered in the consensus
Returns: result: Spectrum object
The aggregated spectrum
- modifinder.utilities.spectrum_utils.refine_consensus(spectrum, spectrums, ppm_tolerance=10, mz_tolerance=0.1, consensus_majority_ratio=0)[source]
This function is used to refine a spectrum based on the consensus of the other spectrums any peak that is not in the consensus of the other spectrums is removed.
If the spectrums are with different adducts, the spectrums are adjusted to remove the adduct mass. The final spectrum is adjusted to have the correct adduct mass.
- Parameters:
spectrum (Spectrum object) – The spectrum to be refined
spectrums (list of Spectrum objects) – The spectrums to be used to refine the spectrum
ppm_tolerance (float) – The tolerance in ppm
mz_tolerance (float) – The tolerance in mz
consensus_majority_ratio (float (0-1) [default: 0]) – The ratio of the spectrums that should have the peak in order to keep it, 0 means none of the spectrums need to have it 1 means all of the spectrums need to have it.
- Return type:
A tuple of two elements
- result: Spectrum object
The refined spectrum
- appearances: tuple of lists
The first list contains the number of spectrums that have the peak after refining The second list contains the number of spectrums that have the peak before refining
- modifinder.utilities.spectrum_utils.remove_adduct(spectrum)[source]
This function is used to remove the adduct mass from the spectrum
- Parameters:
spectrum (Spectrum object) – The spectrum to remove the adduct mass from its mz values
Returns: result: Spectrum object
The spectrum without the adduct mass