Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
RalfG opened this issue Aug 21, 2024 · 0 comments

Comments

@RalfG
Copy link

RalfG commented Aug 21, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant