![]() |
OpenMS
|
Orchestrates calibration workflows for OpenSWATH analysis. More...
#include <OpenMS/ANALYSIS/OPENSWATH/CalibrationWorkflow.h>
Classes | |
| struct | CalibrationResult |
| Results from calibration workflow. More... | |
| struct | IrtExperiments |
| Prepared iRT experiments ready for calibration. More... | |
Public Member Functions | |
| CalibrationWorkflow () | |
| Default constructor. | |
| ~CalibrationWorkflow () override | |
| Destructor | |
| IrtStrategy | determineIrtStrategy (const OpenSwath::LightTargetedExperiment &full_transition_exp, size_t num_runs=1) const |
| Determine the appropriate IRT strategy based on available data. | |
| IrtExperiments | prepareIrtExperiments (IrtStrategy strategy, const OpenSwath::LightTargetedExperiment &full_transition_exp, const std::vector< String > &priority_peptides, size_t run_index=0, const IrtExperiments *cached_irts=nullptr) |
| Prepare iRT experiments based on the determined strategy. | |
| CalibrationResult | performCalibration (std::vector< OpenSwath::SwathMap > &swath_maps, OpenSwath::LightTargetedExperiment &transition_exp, ChromExtractParams &cp, ChromExtractParams &cp_ms1, const IrtExperiments &irt_experiments, const Param &feature_finder_param, const ChromExtractParams &cp_irt, const Param &irt_detection_param, const Param &calibration_param, const Param &mrm_mapping_param, bool pasef=false, bool load_into_memory=false, const String &irt_trafo_out="", const String &irt_mzml_out="", Size debug_level=0) |
| Perform calibration workflow with pre-prepared iRT experiments. | |
| OpenSwath::LightTargetedExperiment | loadIrtExperimentFromFile_ (const String &irt_file_path, const String &label) const |
| Load iRT transition experiment from file. | |
| TransformationDescription | performRTNormalization (const OpenSwath::LightTargetedExperiment &irt_transitions, std::vector< OpenSwath::SwathMap > &swath_maps, TransformationDescription &im_trafo, double min_rsq, double min_coverage, const Param &feature_finder_param, const ChromExtractParams &cp_irt, const Param &irt_detection_param, const Param &calibration_param, const Param &mrm_mapping_param, const String &irt_mzml_out, Size debug_level, bool pasef=false, bool load_into_memory=false) |
| Perform RT and m/z correction of the input data using RT-normalization peptides. | |
| TransformationDescription | doDataNormalization_ (const OpenSwath::LightTargetedExperiment &targeted_exp, const std::vector< OpenMS::MSChromatogram > &chromatograms, TransformationDescription &im_trafo, std::vector< OpenSwath::SwathMap > &swath_maps, double min_rsq, double min_coverage, const Param &default_ffparam, const Param &irt_detection_param, const Param &calibration_param, const bool pasef) |
| Perform retention time and m/z calibration. | |
| double | getEstimatedMzWindow () const |
| Get estimated MS2 m/z extraction window. | |
| double | getEstimatedImWindow () const |
| Get estimated MS2 ion mobility extraction window. | |
| double | getEstimatedMs1MzWindow () const |
| Get estimated MS1 m/z extraction window. | |
| double | getEstimatedMs1ImWindow () const |
| Get estimated MS1 ion mobility extraction window. | |
Public Member Functions inherited from DefaultParamHandler | |
| DefaultParamHandler (const String &name) | |
| Constructor with name that is displayed in error messages. | |
| DefaultParamHandler (const DefaultParamHandler &rhs) | |
| Copy constructor. | |
| virtual | ~DefaultParamHandler () |
| Destructor. | |
| DefaultParamHandler & | operator= (const DefaultParamHandler &rhs) |
| Assignment operator. | |
| virtual bool | operator== (const DefaultParamHandler &rhs) const |
| Equality operator. | |
| void | setParameters (const Param ¶m) |
| Sets the parameters. | |
| const Param & | getParameters () const |
| Non-mutable access to the parameters. | |
| const Param & | getDefaults () const |
| Non-mutable access to the default parameters. | |
| const String & | getName () const |
| Non-mutable access to the name. | |
| void | setName (const String &name) |
| Mutable access to the name. | |
| const std::vector< String > & | getSubsections () const |
| Non-mutable access to the registered subsections. | |
Public Member Functions inherited from ProgressLogger | |
| ProgressLogger () | |
| Constructor. | |
| virtual | ~ProgressLogger () |
| Destructor. | |
| ProgressLogger (const ProgressLogger &other) | |
| Copy constructor. | |
| ProgressLogger & | operator= (const ProgressLogger &other) |
| Assignment Operator. | |
| void | setLogType (LogType type) const |
| Sets the progress log that should be used. The default type is NONE! | |
| LogType | getLogType () const |
| Returns the type of progress log being used. | |
| void | setLogger (ProgressLoggerImpl *logger) |
| Sets the logger to be used for progress logging. | |
| void | startProgress (SignedSize begin, SignedSize end, const String &label) const |
| Initializes the progress display. | |
| void | setProgress (SignedSize value) const |
| Sets the current progress. | |
| void | endProgress (UInt64 bytes_processed=0) const |
| void | nextProgress () const |
| increment progress by 1 (according to range begin-end) | |
Private Member Functions | |
Private implementation methods | |
| CalibrationResult | performLinearCalibration_ (std::vector< OpenSwath::SwathMap > &swath_maps, const IrtExperiments &irt_experiments, const Param &feature_finder_param, const ChromExtractParams &cp_irt, const Param &irt_detection_param, const Param &calibration_param, const Param &mrm_mapping_param, bool pasef, bool load_into_memory, const String &irt_trafo_out, const String &irt_mzml_out, Size debug_level) |
| Perform linear-only calibration workflow. | |
| CalibrationResult | performLinearThenNonlinearCalibration_ (std::vector< OpenSwath::SwathMap > &swath_maps, const IrtExperiments &irt_experiments, const Param &feature_finder_param, const ChromExtractParams &cp_irt, const Param &irt_detection_param, const Param &calibration_param, const Param &mrm_mapping_param, bool pasef, bool load_into_memory, const String &irt_trafo_out, const String &irt_mzml_out, Size debug_level) |
| Perform linear + nonlinear calibration workflow. | |
| void | applyEstimatedWindows_ (const CalibrationResult &result, ChromExtractParams &cp, ChromExtractParams &cp_ms1, bool pasef, bool use_ms1_im) const |
| Apply estimated extraction windows to parameters. | |
| void | applyWindow_ (const char *label, double estimate, double &dst_param, double user_value, bool applicable=true, bool commit=true) const |
| Validate and log an auto-estimated extraction window. | |
| bool | isValidWindow_ (double v, double min_positive=1e-9) const noexcept |
| Check if an estimated extraction window value is valid. | |
Private Attributes | |
Private member variables for parameter caching <br> | |
| String | linear_irt_file_ |
| String | nonlinear_irt_file_ |
| std::vector< String > | linear_irt_files_list_ |
| std::vector< String > | nonlinear_irt_files_list_ |
| bool | auto_irt_enabled_ |
| int | auto_irt_irt_bins_ |
| int | auto_irt_irt_peptides_per_bin_ |
| int | auto_irt_irt_seed_ |
| int | auto_irt_irt_bins_nonlinear_ |
| int | auto_irt_irt_peptides_per_bin_nonlinear_ |
| double | auto_irt_linear_top_fraction_ |
| double | auto_irt_nonlinear_top_fraction_ |
| String | linear_outlier_detection_ |
| String | nonlinear_outlier_detection_ |
| bool | windows_estimate_rt_ |
| bool | windows_estimate_mz_ |
| bool | windows_estimate_im_ |
| double | windows_rt_percentile_ |
| double | rt_estimation_padding_factor_ |
| double | min_rsq_ |
| double | min_coverage_ |
Parameter handling | |
| double | estimated_mz_window_ {-1.0} |
| double | estimated_im_window_ {-1.0} |
| double | estimated_ms1_mz_window_ {-1.0} |
| double | estimated_ms1_im_window_ {-1.0} |
| void | updateMembers_ () override |
| Update member variables from parameters. | |
Additional Inherited Members | |
Public Types inherited from ProgressLogger | |
| enum | LogType { CMD , GUI , NONE } |
| Possible log types. More... | |
Static Public Member Functions inherited from DefaultParamHandler | |
| static void | writeParametersToMetaValues (const Param &write_this, MetaInfoInterface &write_here, const String &key_prefix="") |
| Writes all parameters to meta values. | |
Protected Member Functions inherited from DefaultParamHandler | |
| void | defaultsToParam_ () |
| Updates the parameters after the defaults have been set in the constructor. | |
Protected Attributes inherited from DefaultParamHandler | |
| Param | param_ |
| Container for current parameters. | |
| Param | defaults_ |
| Container for default parameters. This member should be filled in the constructor of derived classes! | |
| std::vector< String > | subsections_ |
| Container for registered subsections. This member should be filled in the constructor of derived classes! | |
| String | error_name_ |
| Name that is displayed in error messages during the parameter checking. | |
| bool | check_defaults_ |
| If this member is set to false no checking if parameters in done;. | |
| bool | warn_empty_defaults_ |
| If this member is set to false no warning is emitted when defaults are empty;. | |
Protected Attributes inherited from ProgressLogger | |
| LogType | type_ |
| time_t | last_invoke_ |
| ProgressLoggerImpl * | current_logger_ |
Static Protected Attributes inherited from ProgressLogger | |
| static int | recursion_depth_ |
Orchestrates calibration workflows for OpenSWATH analysis.
This class provides a unified interface for performing RT, m/z, and ion mobility calibration workflows. It supports both linear-only calibration and linear+nonlinear calibration strategies, making calibration logic reusable across different OpenSWATH tools (DIA/SWATH, SRM/MRM, PRM).
The orchestrator handles:
| struct OpenMS::CalibrationWorkflow::CalibrationResult |
Results from calibration workflow.
| Class Members | ||
|---|---|---|
| double | estimated_rt_window {-1.0} | Estimated RT extraction window (full width, seconds) |
| TransformationDescription | im_trafo | Ion mobility transformation (fitted). May be empty if no IM calibration performed. |
| double | ms1_im_window {-1.0} | MS1 ion mobility extraction window (full width). -1 if not applicable. |
| double | ms1_mz_window_ppm {-1.0} | MS1 m/z extraction window (full width, ppm). -1 if not computed. |
| double | ms2_im_window {-1.0} | MS2 ion mobility extraction window (full width). -1 if not applicable. |
| double | ms2_mz_window_ppm {-1.0} | MS2 m/z extraction window (full width, ppm). -1 if not computed. |
| TransformationDescription | rt_trafo | RT normalization transformation (fitted) |
| struct OpenMS::CalibrationWorkflow::IrtExperiments |
Prepared iRT experiments ready for calibration.
| Class Members | ||
|---|---|---|
| bool | is_prepared {false} | Whether experiments are available and ready for calibration. |
| LightTargetedExperiment | linear_irt | Linear iRT experiment (always required for calibration) |
| LightTargetedExperiment | nonlinear_irt |
Nonlinear iRT experiment (optional, empty if not used) |
| IrtStrategy | strategy {IrtStrategy::STATIC_FILES} | Strategy used to prepare these experiments. |
Default constructor.
|
override |
Destructor
|
private |
Apply estimated extraction windows to parameters.
Updates the provided extraction parameters with auto-estimated windows based on calibration results and user preferences.
| [in] | result | Calibration results containing estimated windows |
| [in,out] | cp | MS2 extraction parameters to update |
| [in,out] | cp_ms1 | MS1 extraction parameters to update |
| [in] | pasef | Whether this is PASEF data (for IM applicability) |
| [in] | use_ms1_im | Whether MS1 uses ion mobility |
|
private |
Validate and log an auto-estimated extraction window.
Behavior:
applicable is false (e.g., no IM data), logs an INFO and leaves dst_param unchanged.dst_param unchanged.commit is true, logs an INFO and assigns dst_param = estimate.commit is false, logs an INFO that reports the estimate and that the user value is kept.Typical usage:
| [in] | label | Human-readable label for logging |
| [in] | estimate | Estimated window value |
| [in,out] | dst_param | Parameter to update |
| [in] | user_value | Current user-specified value |
| [in] | applicable | Whether this window type is applicable |
| [in] | commit | Whether to actually apply the estimate |
| IrtStrategy determineIrtStrategy | ( | const OpenSwath::LightTargetedExperiment & | full_transition_exp, |
| size_t | num_runs = 1 |
||
| ) | const |
Determine the appropriate IRT strategy based on available data.
Analyzes the available iRT data to determine which IRT strategy should be used for calibration. Priority order:
| [in] | full_transition_exp | Full transition experiment for auto-sampling (empty if not available) |
| [in] | num_runs | Total number of runs to process (affects strategy choice) |
| TransformationDescription doDataNormalization_ | ( | const OpenSwath::LightTargetedExperiment & | targeted_exp, |
| const std::vector< OpenMS::MSChromatogram > & | chromatograms, | ||
| TransformationDescription & | im_trafo, | ||
| std::vector< OpenSwath::SwathMap > & | swath_maps, | ||
| double | min_rsq, | ||
| double | min_coverage, | ||
| const Param & | default_ffparam, | ||
| const Param & | irt_detection_param, | ||
| const Param & | calibration_param, | ||
| const bool | pasef | ||
| ) |
Perform retention time and m/z calibration.
Uses MRMRTNormalizer for RT calibration and SwathMapMassCorrection for m/z calibration.
The overall execution flow is as follows:
| [in] | targeted_exp | The transitions for the normalization peptides |
| [out] | chromatograms | The extracted chromatograms |
| [out] | im_trafo | Ion mobility trafo values on the RT-normalization peptides |
| [in] | swath_maps | The raw data (swath maps) |
| [in] | min_rsq | Minimal R^2 value that is expected for the RT regression |
| [in] | min_coverage | Minimal coverage of the chromatographic space that needs to be achieved |
| [in] | default_ffparam | Parameter set for the feature finding in chromatographic dimension |
| [in] | irt_detection_param | Parameter set for the detection of the iRTs (outlier detection, peptides per bin etc) |
| [in] | calibration_param | Parameter for the m/z and im calibration (see SwathMapMassCorrection) |
| [in] | pasef | whether this data is pasef data with potentially overlapping m/z windows (differing by IM) |
|
inline |
Get estimated MS2 ion mobility extraction window.
Returns the MS2 ion mobility extraction window (full width) estimated during calibration. This value is only valid after performCalibration() has been called on PASEF/ion mobility data with window estimation enabled.
|
inline |
Get estimated MS1 ion mobility extraction window.
Returns the MS1 ion mobility extraction window (full width) estimated during calibration. This value is only valid after performCalibration() has been called on PASEF/ion mobility data with MS1 IM window estimation enabled.
|
inline |
Get estimated MS1 m/z extraction window.
Returns the MS1 m/z extraction window (full width, in ppm) estimated during calibration. This value is only valid after performCalibration() has been called and MS1 window estimation was enabled.
|
inline |
Get estimated MS2 m/z extraction window.
Returns the MS2 m/z extraction window (full width, in ppm) estimated during calibration. This value is only valid after performCalibration() has been called and window estimation was enabled.
|
inlineprivatenoexcept |
Check if an estimated extraction window value is valid.
A window is considered valid if it is finite and strictly greater than a small positive threshold. This guards against denormals (e.g., ~1e-310), zeros, negative values, and NaNs/Inf.
| [in] | v | Window value to check |
| [in] | min_positive | Minimum positive threshold |
| OpenSwath::LightTargetedExperiment loadIrtExperimentFromFile_ | ( | const String & | irt_file_path, |
| const String & | label | ||
| ) | const |
Load iRT transition experiment from file.
Helper method to load iRT experiments from configured file paths. Supports TraML, TSV, and PQP formats.
| [in] | irt_file_path | Path to iRT file (empty = skip loading) |
| [in] | label | Label for logging (e.g., "linear", "nonlinear") |
| Exception::FileNotFound | if file doesn't exist |
| Exception::ParseError | if file format is invalid |
| CalibrationResult performCalibration | ( | std::vector< OpenSwath::SwathMap > & | swath_maps, |
| OpenSwath::LightTargetedExperiment & | transition_exp, | ||
| ChromExtractParams & | cp, | ||
| ChromExtractParams & | cp_ms1, | ||
| const IrtExperiments & | irt_experiments, | ||
| const Param & | feature_finder_param, | ||
| const ChromExtractParams & | cp_irt, | ||
| const Param & | irt_detection_param, | ||
| const Param & | calibration_param, | ||
| const Param & | mrm_mapping_param, | ||
| bool | pasef = false, |
||
| bool | load_into_memory = false, |
||
| const String & | irt_trafo_out = "", |
||
| const String & | irt_mzml_out = "", |
||
| Size | debug_level = 0 |
||
| ) |
Perform calibration workflow with pre-prepared iRT experiments.
This is the main calibration entry point that accepts pre-prepared iRT experiments and performs RT, m/z, and ion mobility calibration. It automatically chooses between linear-only or linear+nonlinear calibration based on whether nonlinear iRT experiments are provided.
| [in,out] | swath_maps | Raw SWATH/SRM data maps (modified in-place by calibration) |
| [in,out] | transition_exp | Target transition experiment (IM values may be corrected) |
| [in,out] | cp | Extraction parameters (windows may be updated with estimates) |
| [in,out] | cp_ms1 | MS1 extraction parameters (windows may be updated) |
| [in] | irt_experiments | Pre-prepared iRT experiments for calibration |
| [in] | feature_finder_param | Parameters for MRMFeatureFinderScoring |
| [in] | cp_irt | Extraction parameters for iRT peptides |
| [in] | irt_detection_param | Parameters for iRT detection and outlier removal |
| [in] | calibration_param | Parameters for m/z and IM calibration |
| [in] | mrm_mapping_param | Parameters for MRM chromatogram mapping |
| [in] | pasef | Whether data is PASEF (ion mobility) data |
| [in] | load_into_memory | Whether to load data into memory for processing |
| [in] | irt_trafo_out | Output file for RT transformation (empty = no output) |
| [in] | irt_mzml_out | Output file for iRT chromatograms (empty = no output) |
| [in] | debug_level | Debug level (0 = no debug output, >1 = verbose) |
| Exception::IllegalArgument | If configuration is invalid |
| Exception::MissingInformation | If iRT experiments are not ready |
|
private |
Perform linear-only calibration workflow.
| [in,out] | swath_maps | SWATH data maps |
| [in] | irt_experiments | Prepared iRT experiments |
| [in] | feature_finder_param | Parameters for MRMFeatureFinderScoring |
| [in] | cp_irt | Extraction parameters for iRT peptides |
| [in] | irt_detection_param | Parameters for iRT detection |
| [in] | calibration_param | Parameters for calibration |
| [in] | mrm_mapping_param | Parameters for MRM mapping |
| [in] | pasef | Whether this is PASEF data |
| [in] | load_into_memory | Whether to load data into memory |
| [in] | irt_trafo_out | Output transformation file |
| [in] | irt_mzml_out | Output iRT chromatograms file |
| [in] | debug_level | Debug level (0 = no debug output, >1 = verbose) |
|
private |
Perform linear + nonlinear calibration workflow.
First performs a linear calibration, then applies nonlinear refinement using a separate set of iRT transitions.
| [in,out] | swath_maps | SWATH data maps |
| [in] | irt_experiments | Prepared iRT experiments |
| [in] | feature_finder_param | Parameters for MRMFeatureFinderScoring |
| [in] | cp_irt | Extraction parameters for iRT peptides |
| [in] | irt_detection_param | Parameters for iRT detection |
| [in] | calibration_param | Parameters for calibration |
| [in] | mrm_mapping_param | Parameters for MRM mapping |
| [in] | pasef | Whether this is PASEF data |
| [in] | load_into_memory | Whether to load data into memory |
| [in] | irt_trafo_out | Output transformation file |
| [in] | irt_mzml_out | Output iRT chromatograms file |
| [in] | debug_level | Debug level (0 = no debug output, >1 = verbose) |
| TransformationDescription performRTNormalization | ( | const OpenSwath::LightTargetedExperiment & | irt_transitions, |
| std::vector< OpenSwath::SwathMap > & | swath_maps, | ||
| TransformationDescription & | im_trafo, | ||
| double | min_rsq, | ||
| double | min_coverage, | ||
| const Param & | feature_finder_param, | ||
| const ChromExtractParams & | cp_irt, | ||
| const Param & | irt_detection_param, | ||
| const Param & | calibration_param, | ||
| const Param & | mrm_mapping_param, | ||
| const String & | irt_mzml_out, | ||
| Size | debug_level, | ||
| bool | pasef = false, |
||
| bool | load_into_memory = false |
||
| ) |
Perform RT and m/z correction of the input data using RT-normalization peptides.
This function extracts the RT normalization chromatograms using simpleExtractChromatograms_() and then uses the chromatograms to find features (in doDataNormalization_()). If desired, also m/z correction is performed using the lock masses of the given peptides. The provided raw data (swath_maps) are therefore not constant but may be changed in this function.
| [in] | irt_transitions | A set of transitions used for the RT normalization peptides |
| [in] | swath_maps | The raw data (swath maps) |
| [out] | im_trafo | Ion mobility trafo values on the RT-normalization peptides |
| [in] | min_rsq | Minimal R^2 value that is expected for the RT regression |
| [in] | min_coverage | Minimal coverage of the chromatographic space that needs to be achieved |
| [in] | feature_finder_param | Parameter set for the feature finding in chromatographic dimension |
| [in] | cp_irt | Parameter set for the chromatogram extraction |
| [in] | irt_detection_param | Parameter set for the detection of the iRTs (outlier detection, peptides per bin etc) |
| [in] | calibration_param | Parameter for the m/z and im calibration (see SwathMapMassCorrection) |
| [in] | mrm_mapping_param | Parameter for mapping chromatograms to transitions (MRMMapping) |
| [in] | debug_level | Debug level (writes out the RT normalization chromatograms if larger than 1) |
| [out] | irt_mzml_out | Output Chromatogram mzML containing the iRT peptides (if not empty, iRT chromatograms will be stored in this file) |
| [in] | pasef | whether the data is PASEF data (should match transitions by their IM) |
| [in] | load_into_memory | Whether to cache the current SWATH map in memory |
| IrtExperiments prepareIrtExperiments | ( | IrtStrategy | strategy, |
| const OpenSwath::LightTargetedExperiment & | full_transition_exp, | ||
| const std::vector< String > & | priority_peptides, | ||
| size_t | run_index = 0, |
||
| const IrtExperiments * | cached_irts = nullptr |
||
| ) |
Prepare iRT experiments based on the determined strategy.
This function handles all aspects of iRT experiment preparation:
The prepared experiments are ready for use with performCalibration().
| [in] | strategy | The IRT strategy to use |
| [in] | full_transition_exp | Full transition experiment for auto-sampling (required for sampling strategies) |
| [in] | priority_peptides | Priority peptide sequences for sampling (empty = no priorities) |
| [in] | run_index | Current run index (0-based, for run-specific strategies) |
| [in] | cached_irts | Previously prepared iRT experiments (for reusing sampled iRTs across runs) |
| Exception::MissingInformation | if required data is not available |
| Exception::InvalidParameter | if configuration is invalid |
|
overrideprivatevirtual |
Update member variables from parameters.
This method is called automatically when parameters change. Updates internal member variables from current parameter values.
Reimplemented from DefaultParamHandler.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |