| OpenMS 2.5.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-2020.
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
43 #include "OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h"
44 #include "OpenMS/OPENSWATHALGO/DATAACCESS/ITransition.h"
45 #include "OpenMS/OPENSWATHALGO/DATAACCESS/TransitionExperiment.h"
46 #include "OpenMS/OPENSWATHALGO/ALGO/StatsHelpers.h"
47 #include "OpenMS/OPENSWATHALGO/ALGO/Scoring.h"
48
49 namespace OpenSwath
50 {
51
73 class OPENSWATHALGO_DLLAPI MRMScoring
74 {
75
76 public:
77
79
80 typedef OpenSwath::Scoring::XCorrArrayType XCorrArrayType;
83 typedef std::vector<std::vector<XCorrArrayType> > XCorrMatrixType;
84
85 typedef std::string String;
86
87 typedef OpenSwath::SpectrumPtr SpectrumType;
88 typedef OpenSwath::LightTransition TransitionType;
89 typedef OpenSwath::LightCompound PeptideType;
90 typedef OpenSwath::LightProtein ProteinType;
91
92 typedef boost::shared_ptr<OpenSwath::IFeature> FeatureType;
94
97 const XCorrMatrixType& getXCorrMatrix() const;
100
102 const XCorrMatrixType& getXCorrContrastMatrix() const;
104
106 const XCorrMatrixType& getXCorrPrecursorContrastMatrix() const;
108
110 const XCorrMatrixType& getXCorrPrecursorCombinedMatrix() const;
112
115 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
136 /*
137 @brief Calculate the cross-correlation coelution score
138
139 The score is a distance where zero indicates perfect coelution.
140 */
141 double calcXcorrCoelutionScore();
142
143 /*
144 @brief Calculate the weighted cross-correlation coelution score
145
146 The score is a distance where zero indicates perfect coelution. The
147 score is weighted by the transition intensities, non-perfect coelution
148 in low-intensity transitions should thus become less important.
149 */
150 double calcXcorrCoelutionWeightedScore(const std::vector<double>& normalized_library_intensity);
151
153 double calcXcorrContrastCoelutionScore();
154
156 std::vector<double> calcSeparateXcorrContrastCoelutionScore();
157
159 double calcXcorrPrecursorCoelutionScore();
160
161 /*
162 @brief Calculate the precursor cross-correlation contrast score against the transitions
163
164 The score is a distance where zero indicates perfect coelution.
165 */
166 double calcXcorrPrecursorContrastCoelutionScore();
167
169 double calcXcorrPrecursorCombinedCoelutionScore();
170
171 /*
172 @brief Calculate the cross-correlation shape score
173
174 The score is a correlation measure where 1 indicates perfect correlation
175 and 0 means no correlation.
176 */
177 double calcXcorrShapeScore();
178
179 /*
180 @brief Calculate the weighted cross-correlation shape score
181
182 The score is a correlation measure where 1 indicates perfect correlation
183 and 0 means no correlation. The score is weighted by the transition
184 intensities, non-perfect coelution in low-intensity transitions should
185 thus become less important.
186 */
187 double calcXcorrShapeWeightedScore(const std::vector<double>& normalized_library_intensity);
188
190 double calcXcorrContrastShapeScore();
191
193 std::vector<double> calcSeparateXcorrContrastShapeScore();
194
196 double calcXcorrPrecursorShapeScore();
197
199 double calcXcorrPrecursorContrastShapeScore();
200
202 double calcXcorrPrecursorCombinedShapeScore();
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);
255 double calcMIPrecursorScore();
256 double calcMIPrecursorContrastScore();
257 double calcMIPrecursorCombinedScore();
258 std::vector<double> calcSeparateMIContrastScore();
259
261
262 private:
263
266 XCorrMatrixType xcorr_matrix_;
268
270 XCorrMatrixType xcorr_contrast_matrix_;
272
274 XCorrMatrixType xcorr_precursor_matrix_;
275
277 XCorrMatrixType xcorr_precursor_contrast_matrix_;
279
281 XCorrMatrixType xcorr_precursor_combined_matrix_;
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
OpenSwath::MRMScoring::XCorrMatrixType
std::vector< std::vector< XCorrArrayType > > XCorrMatrixType
Cross Correlation matrix.
Definition: MRMScoring.h:83
OpenSwath
Definition: MRMScoring.h:49
OpenSwath::IMRMFeature
Definition: ITransition.h:56
Scoring.h
OpenSwath::LightCompound
Definition: TransitionExperiment.h:149
OpenSwath::MRMScoring
This class implements different scores for peaks found in SRM/MRM.
Definition: MRMScoring.h:73
OpenSwath::MRMScoring::TransitionType
OpenSwath::LightTransition TransitionType
Definition: MRMScoring.h:88
OpenSwath::MRMScoring::xcorr_precursor_matrix_
XCorrMatrixType xcorr_precursor_matrix_
the precomputed cross correlation matrix of the MS1 trace
Definition: MRMScoring.h:274
OpenSwath::MRMScoring::mi_precursor_combined_matrix_
std::vector< std::vector< double > > mi_precursor_combined_matrix_
the precomputed contrast mutual information matrix with the MS1 trace
Definition: MRMScoring.h:298
OpenSwath::MRMScoring::xcorr_precursor_contrast_matrix_
XCorrMatrixType xcorr_precursor_contrast_matrix_
the precomputed cross correlation against the MS1 trace
Definition: MRMScoring.h:277
OpenSwath::MRMScoring::ProteinType
OpenSwath::LightProtein ProteinType
Definition: MRMScoring.h:90
OpenSwath::LightProtein
Definition: TransitionExperiment.h:201
OpenSwath::SpectrumPtr
boost::shared_ptr< Spectrum > SpectrumPtr
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/DataStructures.h:292
OpenSwath::MRMScoring::String
std::string String
Definition: MRMScoring.h:85
OpenSwath::MRMScoring::FeatureType
boost::shared_ptr< OpenSwath::IFeature > FeatureType
Definition: MRMScoring.h:92
OpenSwath::Scoring::XCorrArrayType
Definition: Scoring.h:61
OpenSwath::LightTransition
Definition: TransitionExperiment.h:46
OpenSwath::MRMScoring::mi_precursor_contrast_matrix_
std::vector< std::vector< double > > mi_precursor_contrast_matrix_
the precomputed contrast mutual information matrix against the MS1 trace
Definition: MRMScoring.h:294
OpenSwath::MRMScoring::mi_contrast_matrix_
std::vector< std::vector< double > > mi_contrast_matrix_
the precomputed contrast mutual information matrix
Definition: MRMScoring.h:288
TransitionExperiment.h
ISpectrumAccess.h
ITransition.h
OpenSwath::MRMScoring::mi_precursor_matrix_
std::vector< std::vector< double > > mi_precursor_matrix_
the precomputed mutual information matrix of the MS1 trace
Definition: MRMScoring.h:291
OpenSwath::MRMScoring::SpectrumType
OpenSwath::SpectrumPtr SpectrumType
Definition: MRMScoring.h:87
OpenSwath::MRMScoring::xcorr_contrast_matrix_
XCorrMatrixType xcorr_contrast_matrix_
the precomputed contrast cross correlation
Definition: MRMScoring.h:270
StatsHelpers.h
OpenSwath::MRMScoring::PeptideType
OpenSwath::LightCompound PeptideType
Definition: MRMScoring.h:89
OpenSwath::MRMScoring::mi_matrix_
std::vector< std::vector< double > > mi_matrix_
the precomputed mutual information matrix
Definition: MRMScoring.h:285
OpenSwath::MRMScoring::xcorr_precursor_combined_matrix_
XCorrMatrixType xcorr_precursor_combined_matrix_
the precomputed cross correlation with the MS1 trace
Definition: MRMScoring.h:281