OpenMS
MasstraceCorrelator.h
Go to the documentation of this file.
1 // Copyright (c) 2002-2023, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Hannes Roest $
6 // $Authors: Hannes Roest $
7 // --------------------------------------------------------------------------
8 
9 #pragma once
10 
15 
16 namespace OpenMS
17 {
18 
27  class OPENMS_DLLAPI MasstraceCorrelator :
28  public DefaultParamHandler,
29  public ProgressLogger
30  {
31 
32  public:
33 
35 
37 
38  // a mass trace is a vector of pairs in (RT, Intensity)
39  typedef std::vector<std::pair<double, double> > MasstracePointsType;
40 
54  void createPseudoSpectra(const ConsensusMap& map, MSExperiment& pseudo_spectra,
55  Size min_peak_nr, double min_correlation, int max_lag,
56  double max_rt_apex_difference);
57 
58  /* Score two mass traces against each other
59  *
60  * This function scores two mass traces (vector of <RT,Intensity>) against each other:
61  *
62  * - The algorithm first creates 2 arrays that contain matched intensities
63  * in RT-space (accounting for missing data points and unequal length)
64  * - Next, these arrays are scored using cross-correlation scores and
65  * pearson coefficients.
66  *
67  * @note The pairs need to be sorted by the first entry (RT)
68  *
69  * @param hull_points1 The first input masstrace
70  * @param hull_points2 The second input masstrace
71  * @param lag The computed lag (output coelution score)
72  * @param lag_intensity The computed intensity at the lag (output shape score)
73  * @param pearson_score The computed pearson score (output)
74  * @param min_corr Minimal correlation needed to proceed computing the cross-correlations
75  * @param max_lag Currently unused
76  * @param mindiff Minimal differences for matching up the two mass traces
77  *
78  */
79  void scoreHullpoints(const MasstracePointsType& hull_points1,
80  const MasstracePointsType& hull_points2,
81  int& lag,
82  double& lag_intensity,
83  double& pearson_score,
84  const double min_corr,
85  const int max_lag,
86  const double mindiff = 0.1);
87 
88  /* Create a cache of the features in a consensus map
89  *
90  * This creates a cache of the input consensus map by creating the
91  * following data structures:
92  * - a vector of mass traces (each mass trace is simply a vector of <RT,Intensity>
93  * - a vector of maximal intensities (max_rt, max_int)
94  * - a vector of retention times of the feature
95  *
96  * @param map The input consensus map
97  * @param feature_points The list of all mass traces
98  * @param max_intensities The list of maximal intensities
99  * @param rt_cache The list of retention times of all features
100  */
102  std::vector<MasstracePointsType>& feature_points,
103  std::vector<std::pair<double, double> >& max_intensities,
104  std::vector<double>& rt_cache);
105 
106  protected:
107 
129  void matchMassTraces_(const MasstracePointsType& hull_points1,
130  const MasstracePointsType& hull_points2,
131  std::vector<double>& vec1,
132  std::vector<double>& vec2,
133  double mindiff,
134  double padEnds = true);
135  };
136 }
137 
A container for consensus elements.
Definition: ConsensusMap.h:66
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:66
In-Memory representation of a mass spectrometry run.
Definition: MSExperiment.h:46
Correlates individual masstraces found in mass spectrometric maps.
Definition: MasstraceCorrelator.h:30
void matchMassTraces_(const MasstracePointsType &hull_points1, const MasstracePointsType &hull_points2, std::vector< double > &vec1, std::vector< double > &vec2, double mindiff, double padEnds=true)
Match up two mass traces with potentially missing values.
void createPseudoSpectra(const ConsensusMap &map, MSExperiment &pseudo_spectra, Size min_peak_nr, double min_correlation, int max_lag, double max_rt_apex_difference)
std::vector< std::pair< double, double > > MasstracePointsType
Definition: MasstraceCorrelator.h:39
void createConsensusMapCache(const ConsensusMap &map, std::vector< MasstracePointsType > &feature_points, std::vector< std::pair< double, double > > &max_intensities, std::vector< double > &rt_cache)
void scoreHullpoints(const MasstracePointsType &hull_points1, const MasstracePointsType &hull_points2, int &lag, double &lag_intensity, double &pearson_score, const double min_corr, const int max_lag, const double mindiff=0.1)
Base class for all classes that want to report their progress.
Definition: ProgressLogger.h:27
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:101
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:22