25 class PeptideIdentification;
26 class ProteinIdentification;
28 class PeptideIdentificationList;
122 const std::vector<ProteinIdentification> & protein_ids,
124 const bool split_charge,
125 const bool top_hits_only,
126 const bool peptide_level =
false);
144 const std::vector<ProteinIdentification> & protein_ids,
146 const bool split_charge,
147 const bool top_hits_only,
148 const bool target_decoy_available,
149 const double fdr_for_targets_smaller);
165 const std::string & search_engine,
167 const bool prob_correct,
168 const bool split_charge,
169 std::vector<ProteinIdentification> & protein_ids,
171 bool & unable_to_fit_data,
172 bool & data_might_not_be_well_fit);
193 const std::string & search_engine,
195 const bool prob_correct,
196 const bool split_charge,
197 std::vector<ProteinIdentification> & protein_ids,
199 bool & unable_to_fit_data,
200 bool & data_might_not_be_well_fit,
201 std::set<std::pair<Size, Size>> & updated_hits);
225 bool fit(std::vector<double>& search_engine_scores,
const std::string& outlier_handling);
236 bool fitGumbelGauss(std::vector<double>& search_engine_scores,
const std::string& outlier_handling);
246 bool fit(std::vector<double>& search_engine_scores, std::vector<double>& probabilities,
const std::string& outlier_handling);
262 bool fitTargetDecoy(
const std::vector<double>& target_scores,
const std::vector<double>& decoy_scores,
const std::string& outlier_handling);
277 return td_incorrect_fraction_;
294 return calibration_warning_;
318 void fillDensities(
const std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density);
320 void fillLogDensities(
const std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density);
322 void fillLogDensitiesGumbel(
const std::vector<double> & x_scores, std::vector<double> & incorrect_density, std::vector<double> & correct_density);
324 double computeLogLikelihood(
const std::vector<double> & incorrect_density,
const std::vector<double> & correct_density)
const;
333 const std::vector<double>& incorrect_log_density,
334 const std::vector<double>& correct_log_density,
335 std::vector<double>& incorrect_posterior)
const;
344 const std::vector<double> &incorrect_posteriors);
354 const std::vector<double> &incorrect_posteriors,
355 const std::pair<double, double>& pos_neg_mean);
360 return correctly_assigned_fit_param_;
366 return incorrectly_assigned_fit_param_;
372 return incorrectly_assigned_fit_gumbel_param_;
378 return negative_prior_;
384 double z = exp((params.
x0 - x) / params.
sigma);
385 return (z * exp(-1 * z)) / params.
sigma;
433 return smallest_score_;
444 void processOutliers_(std::vector<double>& x_scores,
const std::string& outlier_handling)
const;
454 bool fitMixture_(std::vector<double> scores,
bool use_gumbel,
const std::string& outlier_handling);
457 bool fitTargetDecoyModel_(
const std::vector<double>& targets,
const std::vector<double>& decoys,
const std::string& outlier_handling);
460 bool fitIsotonic_(
const std::vector<double>& target_scores,
const std::vector<double>& decoy_scores);
478 static double transformScore_(
const std::string& engine,
const PeptideHit& hit,
const std::string& current_score_type,
bool higher_score_better,
const std::string& score_source);
483 const std::string & search_engine,
485 const bool prob_correct,
486 const bool split_charge,
487 std::vector<ProteinIdentification> & protein_ids,
489 bool & unable_to_fit_data,
490 bool & data_might_not_be_well_fit,
491 bool unusable_to_one,
492 std::set<std::pair<Size, Size>> & updated_hits);
506 static bool getScore_(
const std::vector<std::string>& requested_score_types,
const PeptideHit & hit,
const std::string& actual_score_type,
double& value);
A base class for all classes handling default parameters.
Definition DefaultParamHandler.h:66
Implements a fitter for Gaussian functions.
Definition GaussFitter.h:35
Estimates posterior error probabilities (PEPs) of peptide-spectrum matches from search engine scores.
Definition PosteriorErrorProbabilityModel.h:79
PosteriorErrorProbabilityModel & operator=(const PosteriorErrorProbabilityModel &rhs)
assignment operator (not implemented)
static void updateScores_(const PosteriorErrorProbabilityModel &PEP_model, const std::string &search_engine, const Int charge, const bool prob_correct, const bool split_charge, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool &unable_to_fit_data, bool &data_might_not_be_well_fit, bool unusable_to_one, std::set< std::pair< Size, Size > > &updated_hits)
implementation of updateScores(); hits without a usable score get a PEP of 1 if unusable_to_one is se...
bool fitIsotonic_(const std::vector< double > &target_scores, const std::vector< double > &decoy_scores)
estimates the non-parametric target-decoy model; returns false if it cannot be estimated
double computeLLAndIncorrectPosteriorsFromLogDensities(const std::vector< double > &incorrect_log_density, const std::vector< double > &correct_log_density, std::vector< double > &incorrect_posterior) const
std::vector< double > isotonic_scores_
knots of the non-parametric PEP curve: scores (ascending) and PEPs (non-increasing)
Definition PosteriorErrorProbabilityModel.h:530
bool fitGumbelGauss(std::vector< double > &search_engine_scores, const std::string &outlier_handling)
fits the distributions to the data points(search_engine_scores). Estimated parameters for the distrib...
static bool getScore_(const std::vector< std::string > &requested_score_types, const PeptideHit &hit, const std::string &actual_score_type, double &value)
std::vector< double > decoy_peps_
Definition PosteriorErrorProbabilityModel.h:534
double td_incorrect_fraction_
target-decoy estimate of the fraction of incorrect targets (-1 if not available)
Definition PosteriorErrorProbabilityModel.h:536
static std::map< std::string, std::vector< std::vector< double > > > extractAndTransformScores(const std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, const bool split_charge, const bool top_hits_only, const bool target_decoy_available, const double fdr_for_targets_smaller)
extract and transform score types to a range and score orientation that the PEP model can handle
double logCorrectDensity_(double x) const
log density of the correct component at x (in the shifted score space)
double td_auc_
area under the ROC curve of targets vs. decoys of the last target-decoy fit (-1 if not available)
Definition PosteriorErrorProbabilityModel.h:538
GumbelMaxLikelihoodFitter::GumbelDistributionFitResult incorrectly_assigned_fit_gumbel_param_
Definition PosteriorErrorProbabilityModel.h:514
TextFile initPlots(std::vector< double > &x_scores)
initializes the plots
void plotTargetDecoyEstimation(std::vector< double > &target, std::vector< double > &decoy)
plots the score distributions of target and decoy PSMs together with the estimated model
GaussFitter::GaussFitResult incorrectly_assigned_fit_param_
stores parameters for incorrectly assigned sequences. If gumbel fit was used, A can be ignored....
Definition PosteriorErrorProbabilityModel.h:513
double getTargetDecoyIncorrectFraction() const
returns the target-decoy estimate of the fraction of incorrect target PSMs, i.e. (number of decoys) /...
Definition PosteriorErrorProbabilityModel.h:275
static std::map< std::string, std::vector< std::vector< double > > > extractAndTransformScores(const std::vector< ProteinIdentification > &protein_ids, const PeptideIdentificationList &peptide_ids, const bool split_charge, const bool top_hits_only, const bool peptide_level=false)
extract and transform score types to a range and score orientation that the PEP model can handle
std::vector< double > decoy_scores_
knots of the PEP curve of decoys (label-swapped estimates at the scores of the fitted decoys): scores...
Definition PosteriorErrorProbabilityModel.h:533
bool fit(std::vector< double > &search_engine_scores, const std::string &outlier_handling)
fits the distributions to the data points(search_engine_scores). Estimated parameters for the distrib...
const std::string getBothGnuplotFormula(const GaussFitter::GaussFitResult &incorrect, const GaussFitter::GaussFitResult &correct) const
returns the gnuplot formula of the fitted mixture distribution.
bool hasCalibrationWarning() const
returns true if the last call to fitTargetDecoy() found the target-decoy assumptions to be violated a...
Definition PosteriorErrorProbabilityModel.h:292
void resetFit_()
resets the state of the last fit (model type, target-decoy diagnostics, non-parametric curve)
double computeProbability(double score) const
void fillDensities(const std::vector< double > &x_scores, std::vector< double > &incorrect_density, std::vector< double > &correct_density)
Writes the distributions densities into the two vectors for a set of scores. Incorrect_densities repr...
bool fit(std::vector< double > &search_engine_scores, std::vector< double > &probabilities, const std::string &outlier_handling)
fits the distributions to the data points(search_engine_scores) and writes the computed probabilities...
std::vector< std::pair< double, double > > getIsotonicPEPCurve() const
returns the PEP curve of the non-parametric target-decoy estimate as pairs (score,...
bool fitMixture_(std::vector< double > scores, bool use_gumbel, const std::string &outlier_handling)
fits a two-component mixture model with the EM algorithm
const std::string getGumbelGnuplotFormula(const GaussFitter::GaussFitResult ¶ms) const
returns the gnuplot formula of the fitted gumbel distribution. Only x0 and sigma are used as local pa...
static void updateScores(const PosteriorErrorProbabilityModel &PEP_model, const std::string &search_engine, const Int charge, const bool prob_correct, const bool split_charge, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool &unable_to_fit_data, bool &data_might_not_be_well_fit)
update score entries with PEP (or 1-PEP) estimates
PosteriorErrorProbabilityModel(const PosteriorErrorProbabilityModel &rhs)
Copy constructor (not implemented)
void processOutliers_(std::vector< double > &x_scores, const std::string &outlier_handling) const
remove (or clamp) outliers for fitting
bool calibration_warning_
whether the last target-decoy fit found too few decoys among the lowest-scoring PSMs (see hasCalibrat...
Definition PosteriorErrorProbabilityModel.h:540
const std::string getGaussGnuplotFormula(const GaussFitter::GaussFitResult ¶ms) const
returns the gnuplot formula of the fitted gauss distribution.
GaussFitter::GaussFitResult getIncorrectlyAssignedFitResult() const
returns estimated parameters for incorrectly assigned sequences (for the Gumbel distribution,...
Definition PosteriorErrorProbabilityModel.h:364
double incorrectMode_() const
mode of the incorrect component (in the shifted score space)
double getNegativePrior() const
returns the estimated negative prior probability.
Definition PosteriorErrorProbabilityModel.h:376
void fillLogDensities(const std::vector< double > &x_scores, std::vector< double > &incorrect_density, std::vector< double > &correct_density)
Writes the log distributions densities into the two vectors for a set of scores. Incorrect_densities ...
double computeDecoyProbability(double score) const
returns the posterior error probability of a decoy PSM with the given score
double negative_prior_
stores final prior probability for negative peptides
Definition PosteriorErrorProbabilityModel.h:518
void fillLogDensitiesGumbel(const std::vector< double > &x_scores, std::vector< double > &incorrect_density, std::vector< double > &correct_density)
Writes the log distributions of gumbel and gauss densities into the two vectors for a set of scores....
ModelType
The kind of model that was estimated by the last call to one of the fit functions.
Definition PosteriorErrorProbabilityModel.h:84
~PosteriorErrorProbabilityModel() override
Destructor.
std::vector< double > isotonic_peps_
Definition PosteriorErrorProbabilityModel.h:531
bool incorrect_is_gumbel_
whether the incorrect component of the (last) mixture model is a Gumbel distribution (otherwise Gauss...
Definition PosteriorErrorProbabilityModel.h:528
bool fitTargetDecoyModel_(const std::vector< double > &targets, const std::vector< double > &decoys, const std::string &outlier_handling)
fits the target-decoy model (or, without decoys or with decoy_handling 'ignore', the mixture model) t...
GaussFitter::GaussFitResult correctly_assigned_fit_param_
stores gauss parameters
Definition PosteriorErrorProbabilityModel.h:516
static void updateScores(const PosteriorErrorProbabilityModel &PEP_model, const std::string &search_engine, const Int charge, const bool prob_correct, const bool split_charge, std::vector< ProteinIdentification > &protein_ids, PeptideIdentificationList &peptide_ids, bool &unable_to_fit_data, bool &data_might_not_be_well_fit, std::set< std::pair< Size, Size > > &updated_hits)
update score entries with PEP (or 1-PEP) estimates and report which hits were updated
double logIncorrectDensity_(double x) const
log density of the incorrect component at x (in the shifted score space)
static std::string getSearchEngineKey(const ProteinIdentification &protein_id)
the key under which the scores of a search run are reported by extractAndTransformScores()
ModelType getModelType() const
returns the kind of model estimated by the last fit
Definition PosteriorErrorProbabilityModel.h:265
PosteriorErrorProbabilityModel()
default constructor
bool fitTargetDecoy(const std::vector< double > &target_scores, const std::vector< double > &decoy_scores, const std::string &outlier_handling)
estimates the PEP model from scores of target and decoy PSMs. computeProbability() (targets) and comp...
GaussFitter::GaussFitResult getCorrectlyAssignedFitResult() const
returns estimated parameters for correctly assigned sequences. Fit should be used before.
Definition PosteriorErrorProbabilityModel.h:358
static std::string modelTypeToString(ModelType type)
human-readable name of a ModelType
static double getGumbel_(double x, const GaussFitter::GaussFitResult ¶ms)
computes the gumbel density at position x with parameters params.
Definition PosteriorErrorProbabilityModel.h:382
double smallest_score_
smallest score which was used for fitting the model
Definition PosteriorErrorProbabilityModel.h:520
std::pair< double, double > pos_neg_mean_weighted_posteriors(const std::vector< double > &x_scores, const std::vector< double > &incorrect_posteriors)
static double transformScore_(const std::string &engine, const PeptideHit &hit, const std::string ¤t_score_type, bool higher_score_better, const std::string &score_source)
double getSmallestScore() const
returns the smallest score used in the last fit
Definition PosteriorErrorProbabilityModel.h:431
double getTargetDecoyAUC() const
returns the area under the ROC curve for separating target from decoy PSMs by score (ties count half)...
Definition PosteriorErrorProbabilityModel.h:304
static std::map< std::string, std::string > chooseScoreSources_(const std::map< std::string, std::string > &run_to_engine, const PeptideIdentificationList &peptide_ids)
GumbelMaxLikelihoodFitter::GumbelDistributionFitResult getIncorrectlyAssignedGumbelFitResult() const
returns estimated Gumbel parameters for incorrectly assigned sequences. Fit should be used before.
Definition PosteriorErrorProbabilityModel.h:370
void tryGnuplot(const std::string &gp_file)
try to invoke 'gnuplot' on the file to create PDF automatically
ModelType model_type_
kind of the last estimated model
Definition PosteriorErrorProbabilityModel.h:526
std::pair< double, double > pos_neg_sigma_weighted_posteriors(const std::vector< double > &x_scores, const std::vector< double > &incorrect_posteriors, const std::pair< double, double > &pos_neg_mean)
double computeLogLikelihood(const std::vector< double > &incorrect_density, const std::vector< double > &correct_density) const
computes the Likelihood with a log-likelihood function.
Represents a single spectrum match (candidate) for a specific tandem mass spectrum (MS/MS).
Definition PeptideHit.h:52
Container for peptide identifications from multiple spectra.
Definition PeptideIdentificationList.h:66
Representation of a protein identification run.
Definition ProteinIdentification.h:55
int Int
Signed integer type.
Definition Types.h:72
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
struct of parameters of a Gaussian distribution
Definition GaussFitter.h:40
double sigma
parameter sigma of Gaussian distribution (width)
Definition GaussFitter.h:54
double x0
parameter x0 of Gaussian distribution (center position)
Definition GaussFitter.h:51
struct to represent the parameters of a gumbel distribution
Definition GumbelMaxLikelihoodFitter.h:38