OpenMS  2.7.0
MasstraceCorrelator.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2021.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Hannes Roest $
32 // $Authors: Hannes Roest $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
41 
42 namespace OpenMS
43 {
44 
53  class OPENMS_DLLAPI MasstraceCorrelator :
54  public DefaultParamHandler,
55  public ProgressLogger
56  {
57 
58  public:
59 
61 
63 
64  // a mass trace is a vector of pairs in (RT, Intensity)
65  typedef std::vector<std::pair<double, double> > MasstracePointsType;
66 
80  void createPseudoSpectra(const ConsensusMap& map, MSExperiment& pseudo_spectra,
81  Size min_peak_nr, double min_correlation, int max_lag,
82  double max_rt_apex_difference);
83 
84  /* Score two mass traces against each other
85  *
86  * This function scores two mass traces (vector of <RT,Intensity>) against each other:
87  *
88  * - The algorithm first creates 2 arrays that contain matched intensities
89  * in RT-space (accounting for missing data points and unequal length)
90  * - Next, these arrays are scored using cross-correlation scores and
91  * pearson coefficients.
92  *
93  * @note The pairs need to be sorted by the first entry (RT)
94  *
95  * @param hull_points1 The first input masstrace
96  * @param hull_points2 The second input masstrace
97  * @param lag The computed lag (output coelution score)
98  * @param lag_intensity The computed intensity at the lag (output shape score)
99  * @param pearson_score The computed pearson score (output)
100  * @param min_corr Minimal correlation needed to proceed computing the cross-correlations
101  * @param max_lag Currently unused
102  * @param mindiff Minimal differences for matching up the two mass traces
103  *
104  */
105  void scoreHullpoints(const MasstracePointsType& hull_points1,
106  const MasstracePointsType& hull_points2,
107  int& lag,
108  double& lag_intensity,
109  double& pearson_score,
110  const double min_corr,
111  const int max_lag,
112  const double mindiff = 0.1);
113 
114  /* Create a cache of the features in a consensus map
115  *
116  * This creates a cache of the input consensus map by creating the
117  * following data structures:
118  * - a vector of mass traces (each mass trace is simply a vector of <RT,Intensity>
119  * - a vector of maximal intensities (max_rt, max_int)
120  * - a vector of retention times of the feature
121  *
122  * @param map The input consensus map
123  * @param feature_points The list of all mass traces
124  * @param max_intensities The list of maximal intensities
125  * @param rt_cache The list of retention times of all features
126  */
128  std::vector<MasstracePointsType>& feature_points,
129  std::vector<std::pair<double, double> >& max_intensities,
130  std::vector<double>& rt_cache);
131 
132  protected:
133 
155  void matchMassTraces_(const MasstracePointsType& hull_points1,
156  const MasstracePointsType& hull_points2,
157  std::vector<double>& vec1,
158  std::vector<double>& vec2,
159  double mindiff,
160  double padEnds = true);
161  };
162 }
163 
A container for consensus elements.
Definition: ConsensusMap.h:88
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:93
In-Memory representation of a mass spectrometry experiment.
Definition: MSExperiment.h:80
Correlates individual masstraces found in mass spectrometric maps.
Definition: MasstraceCorrelator.h:56
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:65
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:55
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition: Types.h:127
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47