Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
PosteriorErrorProbabilityModel.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-2013.
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: David Wojnar $
32 // $Authors: David Wojnar $
33 // --------------------------------------------------------------------------
34 
35 #ifndef OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H
36 #define OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H
37 
42 #include <vector>
43 
44 namespace OpenMS
45 {
46  class String;
47  class TextFile;
48  namespace Math
49  {
50 
51 
63  class OPENMS_DLLAPI PosteriorErrorProbabilityModel :
64  public DefaultParamHandler
65  {
66 public:
67 
70 
73 
80  bool fit(std::vector<double> & search_engine_scores);
81 
89  bool fit(std::vector<double> & search_engine_scores, std::vector<double> & probabilities);
90 
92  void fillDensities(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
94  DoubleReal computeMaxLikelihood(std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
96  DoubleReal one_minus_sum_post(std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
98  DoubleReal sum_post(std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
100  DoubleReal sum_pos_x0(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
102  DoubleReal sum_neg_x0(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
104  DoubleReal sum_pos_sigma(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density, DoubleReal positive_mean);
106  DoubleReal sum_neg_sigma(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density, DoubleReal positive_mean);
107 
108 
111  {
112  return correctly_assigned_fit_param_;
113  }
114 
117  {
118  return incorrectly_assigned_fit_param_;
119  }
120 
123  {
124  return negative_prior_;
125  }
126 
129  {
130  return params.A * exp(-1.0 * pow(x - params.x0, 2) / (2 * pow(params.sigma, 2)));
131  }
132 
135  {
136  DoubleReal z = exp((params.x0 - x) / params.sigma);
137  return (z * exp(-1 * z)) / params.sigma;
138  }
139 
144  DoubleReal computeProbability(DoubleReal score);
145 
147  TextFile * InitPlots(std::vector<double> & x_scores);
148 
150  const String getGumbelGnuplotFormula(const GaussFitter::GaussFitResult & params) const;
151 
153  const String getGaussGnuplotFormula(const GaussFitter::GaussFitResult & params) const;
154 
156  const String getBothGnuplotFormula(const GaussFitter::GaussFitResult & incorrect, const GaussFitter::GaussFitResult & correct) const;
157 
159  void plotTargetDecoyEstimation(std::vector<double> & target, std::vector<double> & decoy);
160 
163  {
164  return smallest_score_;
165  }
166 
167 private:
189  const String (PosteriorErrorProbabilityModel::* getNegativeGnuplotFormula_)(const GaussFitter::GaussFitResult & params) const;
191  const String (PosteriorErrorProbabilityModel::* getPositiveGnuplotFormula_)(const GaussFitter::GaussFitResult & params) const;
192 
193  };
194  }
195 }
196 
197 #endif // OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H
A more convenient string class.
Definition: String.h:56
DoubleReal getNegativePrior() const
returns the estimated negative prior probability.
Definition: PosteriorErrorProbabilityModel.h:122
DoubleReal smallest_score_
smallest score which was used for fitting the model
Definition: PosteriorErrorProbabilityModel.h:183
DoubleReal getGumbel(DoubleReal x, const GaussFitter::GaussFitResult &params)
computes the gumbel density at position x with parameters params.
Definition: PosteriorErrorProbabilityModel.h:134
double x0
parameter x0 of gaussian distribution (left/right shift)
Definition: GaussFitter.h:79
double sigma
parameter sigma of gaussian distribution (width)
Definition: GaussFitter.h:82
GaussFitter::GaussFitResult incorrectly_assigned_fit_param_
stores parameters for incorrectly assigned sequences. If gumbel fit was used, A can be ignored...
Definition: PosteriorErrorProbabilityModel.h:173
double A
parameter A of gaussian distribution (amplitude)
Definition: GaussFitter.h:76
DoubleReal getSmallestScore()
returns the smallest score used in the last fit
Definition: PosteriorErrorProbabilityModel.h:162
GaussFitter::GaussFitResult getCorrectlyAssignedFitResult() const
returns estimated parameters for correctly assigned sequences. Fit should be used before...
Definition: PosteriorErrorProbabilityModel.h:110
DoubleReal getGauss(DoubleReal x, const GaussFitter::GaussFitResult &params)
computes the gaussian density at position x with parameters params.
Definition: PosteriorErrorProbabilityModel.h:128
GaussFitter::GaussFitResult correctly_assigned_fit_param_
stores gauss parameters
Definition: PosteriorErrorProbabilityModel.h:175
DoubleReal negative_prior_
stores final prior probability for negative peptides
Definition: PosteriorErrorProbabilityModel.h:177
struct of parameters of a gaussian distribution
Definition: GaussFitter.h:71
Implements a mixture model of the inverse gumbel and the gauss distribution or a gaussian mixture...
Definition: PosteriorErrorProbabilityModel.h:63
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:90
GaussFitter::GaussFitResult getIncorrectlyAssignedFitResult() const
returns estimated parameters for correctly assigned sequences. Fit should be used before...
Definition: PosteriorErrorProbabilityModel.h:116
This class provides some basic file handling methods for text files.
Definition: TextFile.h:47
DoubleReal max_correctly_
peak of the gauss distribution (correctly assigned sequences)
Definition: PosteriorErrorProbabilityModel.h:181
double DoubleReal
Double-precision real type.
Definition: Types.h:118
DoubleReal max_incorrectly_
peak of the incorrectly assigned sequences distribution
Definition: PosteriorErrorProbabilityModel.h:179

OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:19 using doxygen 1.8.5