InternalCalibration#

class pyopenms.InternalCalibration#

Bases: object

Cython implementation of _InternalCalibration

Original C++ documentation is available here

– Inherits from [‘ProgressLogger’]

__init__()#

Overload:

__init__(self) None

A mass recalibration method using linear/quadratic interpolation (robust/weighted) of given reference masses

Overload:

__init__(self, in_0: InternalCalibration) None

Methods

__init__

Overload:

applyTransformation

__static_InternalCalibration_applyTransformation(exp: MSExperiment , target_mslvl: List[int] , trafo: MZTrafoModel ) -> None

calibrate(self, in_0, in_1, in_2, rt_chunk, ...)

Apply calibration to data

endProgress(self)

Ends the progress display

fillCalibrants

Overload:

getCalibrationPoints(self)

Get container of calibration points

getLogType(self)

Returns the type of progress log being used

nextProgress(self)

Increment progress by 1 (according to range begin-end)

setLogType(self, in_0)

Sets the progress log that should be used.

setProgress(self, value)

Sets the current progress

startProgress(self, begin, end, label)

applyTransformation()#

__static_InternalCalibration_applyTransformation(exp: MSExperiment , target_mslvl: List[int] , trafo: MZTrafoModel ) -> None

calibrate(self, in_0: MSExperiment, in_1: List[int], in_2: int, rt_chunk: float, use_RANSAC: bool, post_ppm_median: float, post_ppm_MAD: float, file_models: bytes | str | String, file_models_plot: bytes | str | String, file_residuals: bytes | str | String, file_residuals_plot: bytes | str | String, rscript_executable: bytes | str | String) bool#

Apply calibration to data

For each spectrum, a calibration model will be computed and applied. Make sure to call fillCalibrants() before, so a model can be created.

The MSExperiment will be sorted by RT and m/z if unsorted.

Parameters:
  • exp – MSExperiment holding the Raw data to calibrate

  • target_mslvl – MS-levels where calibration should be applied to

  • model_type – Linear or quadratic model; select based on your instrument

  • rt_chunk – RT-window size (one-sided) of calibration points to collect around each spectrum. Set to negative values, to build one global model instead.

  • use_RANSAC – Remove outliers before fitting a model?!

  • post_ppm_median – The median ppm error of the calibrants must be at least this good after calibration; otherwise this method returns false(fail)

  • post_ppm_MAD – The median absolute deviation of the calibrants must be at least this good after calibration; otherwise this method returns false(fail)

  • file_models – Output CSV filename, where model parameters are written to (pass empty string to skip)

  • file_models_plot – Output PNG image model parameters (pass empty string to skip)

  • file_residuals – Output CSV filename, where ppm errors of calibrants before and after model fitting parameters are written to (pass empty string to skip)

  • file_residuals_plot – Output PNG image of the ppm errors of calibrants (pass empty string to skip)

  • rscript_executable – Full path to the Rscript executable

Returns:

true upon successful calibration

endProgress(self) None#

Ends the progress display

fillCalibrants()#

Overload:

fillCalibrants(self, in_0: MSExperiment, in_1: List[InternalCalibration_LockMass], tol_ppm: float, lock_require_mono: bool, lock_require_iso: bool, failed_lock_masses: CalibrationData, verbose: bool) int

Extract calibrants from Raw data (mzML)

Lock masses are searched in each spectrum and added to the internal calibrant database

Filters can be used to exclude spurious peaks, i.e. require the calibrant peak to be monoisotopic or to have a +1 isotope (should not be used for very low abundant calibrants) If a calibrant is not found, it is added to a ‘failed_lock_masses’ database which is returned and not stored internally. The intensity of the peaks describe the reason for failed detection: 0.0 - peak not found with the given ppm tolerance; 1.0 - peak is not monoisotopic (can only occur if ‘lock_require_mono’ is true) 2.0 - peak has no +1 isotope (can only occur if ‘lock_require_iso’ is true)

Parameters:
  • exp – Peak map containing the lock masses

  • ref_masses – List of lock masses

  • tol_ppm – Search window for lock masses in ‘exp’

  • lock_require_mono – Require that a lock mass is the monoisotopic peak (i.e. not an isotope peak) – lock mass is rejected otherwise

  • lock_require_iso – Require that a lock mass has isotope peaks to its right – lock mass is rejected otherwise

  • failed_lock_masses – Set of calibration masses which were not found, i.e. their expected m/z and RT positions

  • verbose – Print information on ‘lock_require_XXX’ matches during search

Returns:

Number of calibration masses found

Overload:

fillCalibrants(self, in_0: FeatureMap, in_1: float) int

Extract calibrants from identifications

Extracts only the first hit from the first peptide identification of each feature Hits are sorted beforehand Ambiguities should be resolved before, e.g. using IDFilter RT and m/z are taken from the features, not from the identifications (for an exception see below)!

Unassigned peptide identifications are also taken into account! RT and m/z are naturally taken from the IDs, since to feature is assigned If you do not want these IDs, remove them from the feature map before calling this function

A filtering step is done in the m/z dimension using ‘tol_ppm’ Since precursor masses could be annotated wrongly (e.g. isotope peak instead of mono), larger outliers are removed before accepting an ID as calibrant

Parameters:
  • fm – FeatureMap with peptide identifications

  • tol_ppm – Only accept ID’s whose theoretical mass deviates at most this much from annotated

Returns:

Number of calibration masses found

Overload:

fillCalibrants(self, in_0: List[PeptideIdentification], in_1: float) int

Extract calibrants from identifications

Extracts only the first hit from each peptide identification Hits are sorted beforehand Ambiguities should be resolved before, e.g. using IDFilter

Unassigned peptide identifications are also taken into account! RT and m/z are naturally taken from the IDs, since to feature is assigned If you do not want these IDs, remove them from the feature map before calling this function

A filtering step is done in the m/z dimension using ‘tol_ppm’ Since precursor masses could be annotated wrongly (e.g. isotope peak instead of mono), larger outliers are removed before accepting an ID as calibrant

Parameters:
  • pep_ids – Peptide ids (e.g. from an idXML file)

  • tol_ppm – Only accept ID’s whose theoretical mass deviates at most this much from annotated

Returns:

Number of calibration masses found

getCalibrationPoints(self) CalibrationData#

Get container of calibration points

Filled using fillCalibrants() methods

Returns:

Container of calibration points

getLogType(self) int#

Returns the type of progress log being used

nextProgress(self) None#

Increment progress by 1 (according to range begin-end)

setLogType(self, in_0: int) None#

Sets the progress log that should be used. The default type is NONE!

setProgress(self, value: int) None#

Sets the current progress

startProgress(self, begin: int, end: int, label: bytes | str | String) None#