Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

PosteriorErrorProbabilityModel.h

Go to the documentation of this file.
00001 // --------------------------------------------------------------------------
00002 //                   OpenMS -- Open-Source Mass Spectrometry
00003 // --------------------------------------------------------------------------
00004 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
00005 // ETH Zurich, and Freie Universitaet Berlin 2002-2012.
00006 //
00007 // This software is released under a three-clause BSD license:
00008 //  * Redistributions of source code must retain the above copyright
00009 //    notice, this list of conditions and the following disclaimer.
00010 //  * Redistributions in binary form must reproduce the above copyright
00011 //    notice, this list of conditions and the following disclaimer in the
00012 //    documentation and/or other materials provided with the distribution.
00013 //  * Neither the name of any author or any participating institution
00014 //    may be used to endorse or promote products derived from this software
00015 //    without specific prior written permission.
00016 // For a full list of authors, refer to the file AUTHORS.
00017 // --------------------------------------------------------------------------
00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00019 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00020 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00021 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
00022 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00023 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00024 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00025 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00026 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00027 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00028 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 //
00030 // --------------------------------------------------------------------------
00031 // $Maintainer: David Wojnar $
00032 // $Authors: David Wojnar $
00033 // --------------------------------------------------------------------------
00034 
00035 #ifndef OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H
00036 #define OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H
00037 
00038 #include <OpenMS/DATASTRUCTURES/DPosition.h>
00039 #include <OpenMS/MATH/STATISTICS/GumbelDistributionFitter.h>
00040 #include <OpenMS/MATH/STATISTICS/GaussFitter.h>
00041 #include <OpenMS/DATASTRUCTURES/DefaultParamHandler.h>
00042 #include <vector>
00043 
00044 namespace OpenMS
00045 {
00046   class String;
00047   class TextFile;
00048   namespace Math
00049   {
00050 
00051 
00063     class OPENMS_DLLAPI PosteriorErrorProbabilityModel :
00064       public DefaultParamHandler
00065     {
00066 public:
00067 
00069       PosteriorErrorProbabilityModel();
00070 
00072       virtual ~PosteriorErrorProbabilityModel();
00073 
00080       bool fit(std::vector<double> & search_engine_scores);
00081 
00089       bool fit(std::vector<double> & search_engine_scores, std::vector<double> & probabilities);
00090 
00092       void fillDensities(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
00094       DoubleReal computeMaxLikelihood(std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
00096       DoubleReal one_minus_sum_post(std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
00098       DoubleReal sum_post(std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
00100       DoubleReal sum_pos_x0(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
00102       DoubleReal sum_neg_x0(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density);
00104       DoubleReal sum_pos_sigma(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density, DoubleReal positive_mean);
00106       DoubleReal sum_neg_sigma(std::vector<double> & x_scores, std::vector<DoubleReal> & incorrect_density, std::vector<DoubleReal> & correct_density, DoubleReal positive_mean);
00107 
00108 
00110       GaussFitter::GaussFitResult getCorrectlyAssignedFitResult() const
00111       {
00112         return correctly_assigned_fit_param_;
00113       }
00114 
00116       GaussFitter::GaussFitResult getIncorrectlyAssignedFitResult() const
00117       {
00118         return incorrectly_assigned_fit_param_;
00119       }
00120 
00122       DoubleReal getNegativePrior() const
00123       {
00124         return negative_prior_;
00125       }
00126 
00128       DoubleReal getGauss(DoubleReal x, const GaussFitter::GaussFitResult & params)
00129       {
00130         return params.A * exp(-1.0 * pow(x - params.x0, 2) / (2 * pow(params.sigma, 2)));
00131       }
00132 
00134       DoubleReal getGumbel(DoubleReal x, const GaussFitter::GaussFitResult & params)
00135       {
00136         DoubleReal z = exp((params.x0 - x) / params.sigma);
00137         return (z * exp(-1 * z)) / params.sigma;
00138       }
00139 
00144       DoubleReal computeProbability(DoubleReal score);
00145 
00147       TextFile * InitPlots(std::vector<double> & x_scores);
00148 
00150       const String getGumbelGnuplotFormula(const GaussFitter::GaussFitResult & params) const;
00151 
00153       const String getGaussGnuplotFormula(const GaussFitter::GaussFitResult & params) const;
00154 
00156       const String getBothGnuplotFormula(const GaussFitter::GaussFitResult & incorrect, const GaussFitter::GaussFitResult & correct) const;
00157 
00159       void plotTargetDecoyEstimation(std::vector<double> & target, std::vector<double> & decoy);
00160 
00162       inline DoubleReal getSmallestScore()
00163       {
00164         return smallest_score_;
00165       }
00166 
00167 private:
00169       PosteriorErrorProbabilityModel & operator=(const PosteriorErrorProbabilityModel & rhs);
00171       PosteriorErrorProbabilityModel(const PosteriorErrorProbabilityModel & rhs);
00173       GaussFitter::GaussFitResult incorrectly_assigned_fit_param_;
00175       GaussFitter::GaussFitResult correctly_assigned_fit_param_;
00177       DoubleReal negative_prior_;
00179       DoubleReal max_incorrectly_;
00181       DoubleReal max_correctly_;
00183       DoubleReal smallest_score_;
00185       DoubleReal (PosteriorErrorProbabilityModel::* calc_incorrect_)(DoubleReal x, const GaussFitter::GaussFitResult & params);
00187       DoubleReal (PosteriorErrorProbabilityModel::* calc_correct_)(DoubleReal x, const GaussFitter::GaussFitResult & params);
00189       const String (PosteriorErrorProbabilityModel::* getNegativeGnuplotFormula_)(const GaussFitter::GaussFitResult & params) const;
00191       const String (PosteriorErrorProbabilityModel::* getPositiveGnuplotFormula_)(const GaussFitter::GaussFitResult & params) const;
00192 
00193     };
00194   }
00195 }
00196 
00197 #endif // OPENMS_MATH_STATISTICS_POSTERIORERRORPROBABILITYMODEL_H

OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:43 using doxygen 1.7.1