OpenMS  2.7.0
MRMScoring.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 
37 #include <string>
38 #include <boost/math/special_functions/fpclassify.hpp> // for isnan
39 #include <boost/numeric/conversion/cast.hpp>
40 
41 #include <OpenMS/OPENSWATHALGO/OpenSwathAlgoConfig.h>
42 
48 
49 namespace OpenSwath
50 {
51 
73  class OPENSWATHALGO_DLLAPI MRMScoring
74  {
75 
76 public:
77 
79 
83  typedef std::vector<std::vector<XCorrArrayType> > XCorrMatrixType;
84 
85  typedef std::string String;
86 
91 
92  typedef boost::shared_ptr<OpenSwath::IFeature> FeatureType;
94 
100 
104 
108 
112 
116  void initializeXCorrMatrix(const std::vector< std::vector< double > >& data);
117 
119  void initializeXCorrMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& native_ids);
120 
122  void initializeXCorrContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& native_ids_set1, const std::vector<String>& native_ids_set2);
123 
125  void initializeXCorrPrecursorMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids);
126 
128  void initializeXCorrPrecursorContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
129 
131  void initializeXCorrPrecursorContrastMatrix(const std::vector< std::vector< double > >& data_precursor, const std::vector< std::vector< double > >& data_fragments);
132 
134  void initializeXCorrPrecursorCombinedMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
135 
142 
150  double calcXcorrCoelutionWeightedScore(const std::vector<double>& normalized_library_intensity);
151 
154 
157 
160 
167 
170 
178 
187  double calcXcorrShapeWeightedScore(const std::vector<double>& normalized_library_intensity);
188 
191 
193  std::vector<double> calcSeparateXcorrContrastShapeScore();
194 
197 
200 
203 
205  static void calcLibraryScore(OpenSwath::IMRMFeature* mrmfeature,
206  const std::vector<TransitionType>& transitions, double& correlation,
207  double& norm_manhattan, double& manhattan, double& dotprod,
208  double& spectral_angle, double& rmsd);
209 
211  static double calcRTScore(const PeptideType& peptide, double normalized_experimental_rt);
212 
214  // using a vector of SignalToNoiseEstimatorMedian that were calculated for
215  // each chromatogram of the transition_group.
216  static double calcSNScore(OpenSwath::IMRMFeature* mrmfeature,
217  std::vector<OpenSwath::ISignalToNoisePtr>& signal_noise_estimators);
218 
219  static std::vector<double> calcSeparateSNScore(OpenSwath::IMRMFeature* mrmfeature,
220  std::vector<OpenSwath::ISignalToNoisePtr>& signal_noise_estimators);
221 
223  const std::vector< std::vector<double> > & getMIMatrix() const;
225 
227  const std::vector< std::vector<double> > & getMIContrastMatrix() const;
229 
231  const std::vector< std::vector<double> > & getMIPrecursorContrastMatrix() const;
233 
235  const std::vector< std::vector<double> > & getMIPrecursorCombinedMatrix() const;
237 
239  void initializeMIMatrix(OpenSwath::IMRMFeature* mrmfeature, std::vector<String> native_ids);
240 
242  void initializeMIContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, std::vector<String> native_ids_set1, std::vector<String> native_ids_set2);
243 
245  void initializeMIPrecursorMatrix(OpenSwath::IMRMFeature* mrmfeature, std::vector<String> precursor_ids);
246 
248  void initializeMIPrecursorContrastMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
249 
251  void initializeMIPrecursorCombinedMatrix(OpenSwath::IMRMFeature* mrmfeature, const std::vector<String>& precursor_ids, const std::vector<String>& native_ids);
252 
253  double calcMIScore();
254  double calcMIWeightedScore(const std::vector<double>& normalized_library_intensity);
258  std::vector<double> calcSeparateMIContrastScore();
259 
261 
262 private:
263 
268 
272 
275 
279 
283 
285  std::vector< std::vector<double> > mi_matrix_;
286 
288  std::vector< std::vector<double> > mi_contrast_matrix_;
289 
291  std::vector< std::vector<double> > mi_precursor_matrix_;
292 
294  std::vector< std::vector<double> > mi_precursor_contrast_matrix_;
296 
298  std::vector< std::vector<double> > mi_precursor_combined_matrix_;
300 
301  };
302 }
303 
Definition: ITransition.h:57
This class implements different scores for peaks found in SRM/MRM.
Definition: MRMScoring.h:74
const XCorrMatrixType & getXCorrContrastMatrix() const
non-mutable access to the cross-correlation contrast matrix
double calcMIPrecursorCombinedScore()
void initializeMIPrecursorMatrix(OpenSwath::IMRMFeature *mrmfeature, std::vector< String > precursor_ids)
Initialize the scoring object and building the MI matrix.
std::vector< std::vector< XCorrArrayType > > XCorrMatrixType
Cross Correlation matrix.
Definition: MRMScoring.h:83
double calcXcorrCoelutionWeightedScore(const std::vector< double > &normalized_library_intensity)
Calculate the weighted cross-correlation coelution score.
XCorrMatrixType xcorr_precursor_combined_matrix_
the precomputed cross correlation with the MS1 trace
Definition: MRMScoring.h:281
OpenSwath::LightProtein ProteinType
Definition: MRMScoring.h:90
void initializeMIContrastMatrix(OpenSwath::IMRMFeature *mrmfeature, std::vector< String > native_ids_set1, std::vector< String > native_ids_set2)
Initialize the scoring object and building the MI matrix of chromatograms of set1 (e....
double calcMIPrecursorContrastScore()
void initializeMIPrecursorContrastMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &precursor_ids, const std::vector< String > &native_ids)
Initialize the mutual information vector against the MS1 trace.
const XCorrMatrixType & getXCorrMatrix() const
non-mutable access to the cross-correlation matrix
void initializeXCorrMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &native_ids)
Initialize the scoring object and building the cross-correlation matrix.
std::vector< double > calcSeparateMIContrastScore()
void initializeXCorrPrecursorContrastMatrix(const std::vector< std::vector< double > > &data_precursor, const std::vector< std::vector< double > > &data_fragments)
Initialize the scoring object and building the cross-correlation matrix of chromatograms of precursor...
XCorrMatrixType xcorr_matrix_
the precomputed cross correlation matrix
Definition: MRMScoring.h:267
static std::vector< double > calcSeparateSNScore(OpenSwath::IMRMFeature *mrmfeature, std::vector< OpenSwath::ISignalToNoisePtr > &signal_noise_estimators)
boost::shared_ptr< OpenSwath::IFeature > FeatureType
Definition: MRMScoring.h:92
double calcMIWeightedScore(const std::vector< double > &normalized_library_intensity)
double calcXcorrContrastShapeScore()
calculate the cross-correlation contrast shape score
std::vector< std::vector< double > > mi_precursor_matrix_
the precomputed mutual information matrix of the MS1 trace
Definition: MRMScoring.h:291
std::vector< double > calcSeparateXcorrContrastCoelutionScore()
calculate the separate cross-correlation contrast score
OpenSwath::LightCompound PeptideType
Definition: MRMScoring.h:89
void initializeMIMatrix(OpenSwath::IMRMFeature *mrmfeature, std::vector< String > native_ids)
Initialize the scoring object and building the MI matrix.
const std::vector< std::vector< double > > & getMIMatrix() const
non-mutable access to the MI matrix
double calcXcorrPrecursorShapeScore()
calculate the precursor cross-correlation shape score
double calcXcorrShapeWeightedScore(const std::vector< double > &normalized_library_intensity)
Calculate the weighted cross-correlation shape score.
double calcXcorrCoelutionScore()
Calculate the cross-correlation coelution score.
void initializeXCorrPrecursorCombinedMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &precursor_ids, const std::vector< String > &native_ids)
Initialize the scoring object and building the cross-correlation matrix of chromatograms of precursor...
double calcXcorrPrecursorCombinedCoelutionScore()
calculate the precursor cross-correlation coelution score including the transitions
std::vector< double > calcSeparateXcorrContrastShapeScore()
calculate the separate cross-correlation contrast shape score
OpenSwath::LightTransition TransitionType
Definition: MRMScoring.h:88
XCorrMatrixType xcorr_precursor_contrast_matrix_
the precomputed cross correlation against the MS1 trace
Definition: MRMScoring.h:277
void initializeXCorrContrastMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &native_ids_set1, const std::vector< String > &native_ids_set2)
Initialize the scoring object and building the cross-correlation matrix of chromatograms of set1 (e....
OpenSwath::SpectrumPtr SpectrumType
Definition: MRMScoring.h:87
XCorrMatrixType xcorr_precursor_matrix_
the precomputed cross correlation matrix of the MS1 trace
Definition: MRMScoring.h:274
std::vector< std::vector< double > > mi_precursor_contrast_matrix_
the precomputed contrast mutual information matrix against the MS1 trace
Definition: MRMScoring.h:294
double calcXcorrPrecursorCoelutionScore()
calculate the precursor cross-correlation contrast score
double calcMIPrecursorScore()
double calcXcorrPrecursorContrastShapeScore()
calculate the precursor cross-correlation shape score against the transitions
void initializeMIPrecursorCombinedMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &precursor_ids, const std::vector< String > &native_ids)
Initialize the mutual information vector with the MS1 trace.
double calcXcorrShapeScore()
Calculate the cross-correlation shape score.
double calcXcorrPrecursorCombinedShapeScore()
calculate the precursor cross-correlation shape score including the transitions
std::vector< std::vector< double > > mi_matrix_
the precomputed mutual information matrix
Definition: MRMScoring.h:285
std::vector< std::vector< double > > mi_precursor_combined_matrix_
the precomputed contrast mutual information matrix with the MS1 trace
Definition: MRMScoring.h:298
void initializeXCorrMatrix(const std::vector< std::vector< double > > &data)
Initialize the scoring object and building the cross-correlation matrix.
const XCorrMatrixType & getXCorrPrecursorCombinedMatrix() const
non-mutable access to the cross-correlation precursor contrast matrix
const std::vector< std::vector< double > > & getMIPrecursorCombinedMatrix() const
non-mutable access to the MI precursor combined matrix
static double calcSNScore(OpenSwath::IMRMFeature *mrmfeature, std::vector< OpenSwath::ISignalToNoisePtr > &signal_noise_estimators)
calculate the Signal to Noise ratio
void initializeXCorrPrecursorContrastMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &precursor_ids, const std::vector< String > &native_ids)
Initialize the scoring object and building the cross-correlation matrix of chromatograms of precursor...
XCorrMatrixType xcorr_contrast_matrix_
the precomputed contrast cross correlation
Definition: MRMScoring.h:270
const std::vector< std::vector< double > > & getMIPrecursorContrastMatrix() const
non-mutable access to the MI precursor contrast matrix
std::vector< std::vector< double > > mi_contrast_matrix_
the precomputed contrast mutual information matrix
Definition: MRMScoring.h:288
double calcXcorrContrastCoelutionScore()
calculate the cross-correlation contrast score
static double calcRTScore(const PeptideType &peptide, double normalized_experimental_rt)
calculate the retention time correlation score
static void calcLibraryScore(OpenSwath::IMRMFeature *mrmfeature, const std::vector< TransitionType > &transitions, double &correlation, double &norm_manhattan, double &manhattan, double &dotprod, double &spectral_angle, double &rmsd)
calculate the library correlation score
double calcXcorrPrecursorContrastCoelutionScore()
Calculate the precursor cross-correlation contrast score against the transitions.
const std::vector< std::vector< double > > & getMIContrastMatrix() const
non-mutable access to the MI contrast matrix
const XCorrMatrixType & getXCorrPrecursorContrastMatrix() const
non-mutable access to the cross-correlation precursor contrast matrix
std::string String
Definition: MRMScoring.h:85
void initializeXCorrPrecursorMatrix(OpenSwath::IMRMFeature *mrmfeature, const std::vector< String > &precursor_ids)
Initialize the scoring object and building the cross-correlation matrix.
Definition: MRMScoring.h:50
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:291
Definition: TransitionExperiment.h:201
Definition: TransitionExperiment.h:149
Definition: TransitionExperiment.h:46
Definition: Scoring.h:62