Skip to content

Non-descriptive IndexError when PEPs (or q-values?) cannot be calculated from score distribution #29

@RalfG

Description

@RalfG

Hi,

As part of MS²Rescore, which uses Mokapot, which uses Triqler for PEP calculation, we received an error report with a non-descriptive IndexError (CompOmics/ms2rescore#165 (comment)). This occurred because the input score distribution only contain 0 and 100. It therefore makes sense that PEP values could not be calculated. Perhaps a more descriptive error message could be produced?

Here's the relevant part of the stack trace:

File mokapot/confidence.py:476, in LinearConfidence._assign_confidence(self, desc)
    474 LOGGER.info("Assiging PEPs to %s...", level)
    475 try:
--> 476     _, pep = qvality.getQvaluesFromScores(
    477         scores[targets], scores[~targets], includeDecoys=True
    478     )
    479 except SystemExit as msg:
    480     if "no decoy hits available for PEP calculation" in str(msg):

File triqler/qvality.py:80, in getQvaluesFromScores(targetScores, decoyScores, includePEPs, includeDecoys, tdcInput, pi0, plotRegressionCurve, numBins)
     77 if plotRegressionCurve:
     78     scoresForPlot = evalScores.copy()
---> 80 probs = factor * np.exp(splineEval(evalScores, medians, variables))
     81 probs = monotonize(probs)
     83 if plotRegressionCurve:

File triqler/qvality.py:334, in splineEval(scores, medians, variables)
    325 derr = (g[1] - g[0]) / (medians[1] - medians[0]) - (
    326     medians[1] - medians[0]
    327 ) / 6 * gamma[0]
    328 scores[rights == 0] = (
    329     g[0] - (medians[0] - scores[rights == 0]) * derr
    330 )  # reuse "scores" array to save memory
    332 derl = (g[-1] - g[-2]) / (medians[-1] - medians[-2]) + (
    333     medians[-1] - medians[-2]
--> 334 ) / 6 * gamma[-3]
    335 scores[rights == n] = g[-1] + (scores[rights == n] - medians[-1]) * derl
    337 idxs = np.where((rights > 0) & (rights < n))

IndexError: index -3 is out of bounds for axis 0 with size 1

Thanks!
Ralf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions