PosteriorErrorProbabilityModel#

class pyopenms.PosteriorErrorProbabilityModel#

Bases: DefaultParamHandler

Estimates posterior error probabilities (PEPs) of peptide-spectrum matches from search engine scores: with an (unsupervised) mixture model of a Gumbel (or Gauss) and a Gauss distribution, or using target/decoy information (non-parametric target-decoy estimate, see fitTargetDecoy)

__init__() → None#

Methods

__init__()

computeDecoyProbability(score)

Returns the posterior error probability of a decoy PSM with the given score: for the target-decoy estimate, the PEP the decoy would get as a target (label swap), so that decoys and incorrect targets are exchangeable; for the mixture model, the same as computeProbability

computeLogLikelihood(incorrect_density, ...)

Computes the Maximum Likelihood with a log-likelihood function

computeProbability(score)

Returns the computed posterior error probability for a given score

fillDensities(x_scores)

Writes the distributions densities into the two vectors for a set of scores.

fillLogDensities(x_scores)

Writes the log distributions densities into the two vectors for a set of scores.

fit(search_engine_scores, outlier_handling)

Overloaded function.

fitTargetDecoy(target_scores, decoy_scores, ...)

Estimates the PEP model from scores of target and decoy PSMs (higher scores must be better; one top hit per spectrum, search against a concatenated target+decoy database).

getBothGnuplotFormula(incorrect, correct)

Returns the gnuplot formula of the fitted mixture distribution

getCorrectlyAssignedFitResult()

Returns estimated parameters for correctly assigned sequences.

getDefaults()

Returns the default parameters

getGaussGnuplotFormula(params)

Returns the gnuplot formula of the fitted gauss distribution

getGumbelGnuplotFormula(params)

Returns the gnuplot formula of the fitted gumbel distribution

getIncorrectlyAssignedFitResult()

Returns estimated parameters for correctly assigned sequences.

getIncorrectlyAssignedGumbelFitResult()

Returns the location and scale of the Gumbel distribution of incorrectly assigned sequences as tuple (a, b)

getIsotonicPEPCurve()

Returns the PEP curve of the non-parametric target-decoy estimate as list of (score, PEP) tuples, sorted by score

getModelType()

Returns the kind of model estimated by the last fit

getName()

Returns the name

getNegativePrior()

Returns the estimated negative prior probability

getParameters()

Returns the parameters

getSmallestScore()

Returns the smallest score used in the last fit

getSubsections()

getTargetDecoyAUC()

Returns the area under the ROC curve of target vs.

getTargetDecoyIncorrectFraction()

Returns the target-decoy estimate of the fraction of incorrect targets (#decoys / #targets / decoy_ratio) of the last call to fitTargetDecoy, or -1

hasCalibrationWarning()

Returns True if the last call to fitTargetDecoy found targets not scoring better than decoys (AUC <= 0.5), or significantly too few decoys among the lowest-scoring PSMs (one-sided binomial test, PEP below 0.8 there), i.e. the target-decoy assumptions are violated at low scores and the PEPs stay well below 1 (only checked with enough decoys and decoy_handling auto).

initPlots(x_scores)

Initializes the plots.

modelTypeToString(type)

Human-readable name of a ModelType

plotTargetDecoyEstimation(target, decoy)

Plots the estimated distribution against target and decoy hits

pos_neg_mean_weighted_posteriors(x_scores, ...)

setName(name)

Sets the name

setParameters(param)

Sets the parameters

tryGnuplot(gp_file)

class ModelType(*values)#

Bases: Enum

Kind of model estimated by the last fit

MIXTURE = 1#
NONE = 0#
TARGET_DECOY_ISOTONIC = 2#
getMapping()#

Returns a dict mapping int values to enum member name strings.

computeDecoyProbability(score: float) → float#

Returns the posterior error probability of a decoy PSM with the given score: for the target-decoy estimate, the PEP the decoy would get as a target (label swap), so that decoys and incorrect targets are exchangeable; for the mixture model, the same as computeProbability

computeLogLikelihood(incorrect_density: collections.abc.Sequence[float], correct_density: collections.abc.Sequence[float]) → float#

Computes the Maximum Likelihood with a log-likelihood function

computeProbability(score: float) → float#

Returns the computed posterior error probability for a given score

fillDensities(x_scores: collections.abc.Sequence[float]) → tuple#

Writes the distributions densities into the two vectors for a set of scores. Incorrect_densities represent the incorrectly assigned sequences

fillLogDensities(x_scores: collections.abc.Sequence[float]) → tuple#

Writes the log distributions densities into the two vectors for a set of scores. Incorrect_densities represent the incorrectly assigned sequences

fit(search_engine_scores: collections.abc.Sequence[float], outlier_handling: str) → tuple#
fit(search_engine_scores: collections.abc.Sequence[float], probabilities: collections.abc.Sequence[float], outlier_handling: str) → tuple

Overloaded function.

  1. fit(search_engine_scores: collections.abc.Sequence[float], outlier_handling: str) -> tuple

Fits the distributions to the data points(search_engine_scores). Estimated parameters for the distributions are saved in member variables. computeProbability can be used afterwards.

Parameters:

search_engine_scores – A vector which holds the data points

Returns:

Tuple of (success, sorted_scores). Note: scores are sorted from smallest to biggest value

  1. fit(search_engine_scores: collections.abc.Sequence[float], probabilities: collections.abc.Sequence[float], outlier_handling: str) -> tuple

Fits the distributions to the data points(search_engine_scores) and computes the probabilities. Estimated parameters for the distributions are saved in member variables computeProbability can be used afterwards Fits a Gumbel (or Gauss, parameter incorrectly_assigned) and a Gauss distribution with the EM algorithm; the same distributions give the probabilities. With fewer than min_mixture_scores scores (default 35), no model is fitted

Parameters:
  • search_engine_scores – A vector which holds the data points

  • probabilities – Output vector for computed probabilities

  • outlier_handling – Outlier handling strategy

Returns:

Tuple of (success, sorted_scores, probabilities). success is true if algorithm has run through

In/out compatibility (pyOpenMS 3.5 behaviour): a Python list passed as search_engine_scores, probabilities is also updated in place with the returned contents.

fitTargetDecoy(target_scores: collections.abc.Sequence[float], decoy_scores: collections.abc.Sequence[float], outlier_handling: str) → bool#

Estimates the PEP model from scores of target and decoy PSMs (higher scores must be better; one top hit per spectrum, search against a concatenated target+decoy database). With at least one decoy, the non-parametric target-decoy estimate is used; without decoys (or with decoy_handling ‘ignore’), the mixture model. computeProbability can be used afterwards.

Parameters:
  • target_scores – Scores of target PSMs

  • decoy_scores – Scores of decoy PSMs

  • outlier_handling – Outlier handling strategy (only used for the mixture model)

Returns:

True if a model could be estimated

getBothGnuplotFormula(incorrect: pyopenms.GaussFitResult, correct: pyopenms.GaussFitResult) → str#

Returns the gnuplot formula of the fitted mixture distribution

getCorrectlyAssignedFitResult() → pyopenms.GaussFitResult#

Returns estimated parameters for correctly assigned sequences. Fit should be used before

getDefaults() → pyopenms.Param#

Returns the default parameters

getGaussGnuplotFormula(params: pyopenms.GaussFitResult) → str#

Returns the gnuplot formula of the fitted gauss distribution

getGumbelGnuplotFormula(params: pyopenms.GaussFitResult) → str#

Returns the gnuplot formula of the fitted gumbel distribution

getIncorrectlyAssignedFitResult() → pyopenms.GaussFitResult#

Returns estimated parameters for correctly assigned sequences. Fit should be used before

getIncorrectlyAssignedGumbelFitResult() → tuple#

Returns the location and scale of the Gumbel distribution of incorrectly assigned sequences as tuple (a, b)

getIsotonicPEPCurve() → list[tuple[float, float]]#

Returns the PEP curve of the non-parametric target-decoy estimate as list of (score, PEP) tuples, sorted by score

getModelType() → pyopenms.PosteriorErrorProbabilityModel.ModelType#

Returns the kind of model estimated by the last fit

getName() → str#

Returns the name

getNegativePrior() → float#

Returns the estimated negative prior probability

getParameters() → pyopenms.Param#

Returns the parameters

getSmallestScore() → float#

Returns the smallest score used in the last fit

getSubsections() → list[str]#
getTargetDecoyAUC() → float#

Returns the area under the ROC curve of target vs. decoy PSMs of the last call to fitTargetDecoy (0.5 or below: targets do not score better than decoys), or -1

getTargetDecoyIncorrectFraction() → float#

Returns the target-decoy estimate of the fraction of incorrect targets (#decoys / #targets / decoy_ratio) of the last call to fitTargetDecoy, or -1

hasCalibrationWarning() → bool#

Returns True if the last call to fitTargetDecoy found targets not scoring better than decoys (AUC <= 0.5), or significantly too few decoys among the lowest-scoring PSMs (one-sided binomial test, PEP below 0.8 there), i.e. the target-decoy assumptions are violated at low scores and the PEPs stay well below 1 (only checked with enough decoys and decoy_handling auto)

initPlots(x_scores: collections.abc.Sequence[float]) → tuple#

Initializes the plots. Returns (TextFile, sorted_scores)

In/out compatibility (pyOpenMS 3.5 behaviour): a Python list passed as x_scores is also updated in place with the returned contents.

static modelTypeToString(type: pyopenms.PosteriorErrorProbabilityModel.ModelType) → str#

Human-readable name of a ModelType

plotTargetDecoyEstimation(target: collections.abc.Sequence[float], decoy: collections.abc.Sequence[float]) → None#

Plots the estimated distribution against target and decoy hits

pos_neg_mean_weighted_posteriors(x_scores: collections.abc.Sequence[float], incorrect_posteriors: collections.abc.Sequence[float]) → tuple[float, float]#
setName(name: str) → None#

Sets the name

setParameters(param: pyopenms.Param) → None#

Sets the parameters

tryGnuplot(gp_file: str) → None#