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-2017.
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: Timo Sachsenberg $
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<double> & incorrect_density, std::vector<double> & correct_density);
94  double computeMaxLikelihood(std::vector<double> & incorrect_density, std::vector<double> & correct_density);
96  double one_minus_sum_post(std::vector<double> & incorrect_density, std::vector<double> & correct_density);
98  double sum_post(std::vector<double> & incorrect_density, std::vector<double> & correct_density);
100  double sum_pos_x0(std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density);
102  double sum_neg_x0(std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density);
104  double sum_pos_sigma(std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density, double positive_mean);
106  double sum_neg_sigma(std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density, double positive_mean);
107 
108 
111  {
112  return correctly_assigned_fit_param_;
113  }
114 
117  {
118  return incorrectly_assigned_fit_param_;
119  }
120 
122  double getNegativePrior() const
123  {
124  return negative_prior_;
125  }
126 
128  double getGauss(double x, const GaussFitter::GaussFitResult & params)
129  {
130  return params.A * exp(-1.0 * pow(x - params.x0, 2) / (2 * pow(params.sigma, 2)));
131  }
132 
134  double getGumbel(double x, const GaussFitter::GaussFitResult & params)
135  {
136  double z = exp((params.x0 - x) / params.sigma);
137  return (z * exp(-1 * z)) / params.sigma;
138  }
139 
144  double computeProbability(double 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 
162  inline double getSmallestScore()
163  {
164  return smallest_score_;
165  }
166 
168  void tryGnuplot(const String& gp_file);
169 
170 private:
188  double (PosteriorErrorProbabilityModel::* calc_incorrect_)(double x, const GaussFitter::GaussFitResult & params);
190  double (PosteriorErrorProbabilityModel::* calc_correct_)(double x, const GaussFitter::GaussFitResult & params);
192  const String (PosteriorErrorProbabilityModel::* getNegativeGnuplotFormula_)(const GaussFitter::GaussFitResult & params) const;
194  const String (PosteriorErrorProbabilityModel::* getPositiveGnuplotFormula_)(const GaussFitter::GaussFitResult & params) const;
195 
196  };
197  }
198 }
199 
200 #endif // OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H
A more convenient string class.
Definition: String.h:57
double max_incorrectly_
peak of the incorrectly assigned sequences distribution
Definition: PosteriorErrorProbabilityModel.h:182
double x0
parameter x0 of Gaussian distribution (center position)
Definition: GaussFitter.h:76
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:47
double sigma
parameter sigma of Gaussian distribution (width)
Definition: GaussFitter.h:79
GaussFitter::GaussFitResult incorrectly_assigned_fit_param_
stores parameters for incorrectly assigned sequences. If gumbel fit was used, A can be ignored...
Definition: PosteriorErrorProbabilityModel.h:176
double A
parameter A of Gaussian distribution (amplitude)
Definition: GaussFitter.h:73
double getNegativePrior() const
returns the estimated negative prior probability.
Definition: PosteriorErrorProbabilityModel.h:122
double getSmallestScore()
returns the smallest score used in the last fit
Definition: PosteriorErrorProbabilityModel.h:162
double max_correctly_
peak of the gauss distribution (correctly assigned sequences)
Definition: PosteriorErrorProbabilityModel.h:184
double getGumbel(double x, const GaussFitter::GaussFitResult &params)
computes the gumbel density at position x with parameters params.
Definition: PosteriorErrorProbabilityModel.h:134
GaussFitter::GaussFitResult getIncorrectlyAssignedFitResult() const
returns estimated parameters for correctly assigned sequences. Fit should be used before...
Definition: PosteriorErrorProbabilityModel.h:116
GaussFitter::GaussFitResult getCorrectlyAssignedFitResult() const
returns estimated parameters for correctly assigned sequences. Fit should be used before...
Definition: PosteriorErrorProbabilityModel.h:110
double getGauss(double 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:178
struct of parameters of a Gaussian distribution
Definition: GaussFitter.h:64
Implements a mixture model of the inverse gumbel and the gauss distribution or a gaussian mixture...
Definition: PosteriorErrorProbabilityModel.h:63
double negative_prior_
stores final prior probability for negative peptides
Definition: PosteriorErrorProbabilityModel.h:180
A base class for all classes handling default parameters.
Definition: DefaultParamHandler.h:92
double smallest_score_
smallest score which was used for fitting the model
Definition: PosteriorErrorProbabilityModel.h:186
This class provides some basic file handling methods for text files.
Definition: TextFile.h:47

OpenMS / TOPP release 2.3.0 Documentation generated on Tue Jan 9 2018 18:22:03 using doxygen 1.8.13