Skip to content

Target-decoy false discovery rate and q-values of a hit list

ms_target_decoy_fdr

Estimates each target hit's FDR and q-value from a scored target-decoy hit list.

Runs
On the server
Level
Checked against a reference: pyteomics 5.0.2 q-values on 34 cases (target-decoy-fdr-2.json); a second implementation in Python by a separate agent of the same model family
Ask your assistant

What it is

Returns each target hit's estimated FDR and q-value from a scored target-decoy hit list. Use when a person asks which of a short list of PSMs or peptides pass an FDR level. Not for a search engine's full results, hundreds of thousands of hits: never sample or shorten them; use the engine's own FDR filter, Percolator or pyteomics locally; at most one thousand hits. For a ppm error, use `ms_mass_error`; for a peptide's mass, use `ms_peptide_mass`. Refuses protein level, no targets or no decoys, a repeated peptide, and in a separate search the all-hits estimator or a ratio other than one.

Field: Analytical chemistry.

What it does

You give

  • hits (required): The scored hits, targets and decoys together; row k of the reply is hits[k]; label and score are in inputsUsed.
  • hitLevel (required): The level of the hits: psm (peptide-spectrum matches), peptide (one hit per distinct peptide) or protein (refused).
  • scoreDirection (required): Which way scores improve.
  • searchMode (required): How targets and decoys were searched.
  • fdrEstimator (required): How the false discovery rate is estimated from the counts.
  • decoyCountCorrection (required): Whether one is added to the decoy count.

and 3 more, listed below

No request is recorded for this tool.

Limits

  • Research arithmetic: each number follows from the formula, sequence or values you give, by the method and any constants named on the tool, and describes those inputs rather than the sample or instrument they came from.
  • It is not an identification, a validated quantification or a check of an instrument, and it is not for diagnosis or treatment decisions.
  • Estimates the false discovery rate of an accepted list from decoy counts, assuming a decoy hit is as likely as an incorrect target hit; π0 is fixed at one, so estimates are conservative; each spectrum must contribute only its best hit in a concatenated search; PSM or peptide level only; no posterior error probabilities, no re-scoring, and no variance of the estimate.
  • Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.

It will not answer when

  • the hits are protein-level.
  • at peptide level, a label appears more than once.
  • decoys over all hits is asked for in a separate search.
  • a separate search with a decoy-to-target ratio other than one.
Every input, with its units9 inputs
  • hits (required): The scored hits, targets and decoys together; row k of the reply is hits[k]; label and score are in inputsUsed.
  • hitLevel (required): The level of the hits: psm (peptide-spectrum matches), peptide (one hit per distinct peptide) or protein (refused).
  • scoreDirection (required): Which way scores improve.
  • searchMode (required): How targets and decoys were searched.
  • fdrEstimator (required): How the false discovery rate is estimated from the counts.
  • decoyCountCorrection (required): Whether one is added to the decoy count.
  • decoyToTargetRatio (required): Decoy candidate sequences over target candidate sequences in the search (one for reversed or shuffled decoys of the same database). Must be above 0.
  • scoreThreshold: A score on the scale of the hits' scores: the reply gives the counts accepted at or past it and the estimate there. Optional.
  • fdrLevel: An FDR level: the reply gives the least stringent target score whose q-value is at or below it, and the counts accepted there. Must be above 0 and at most 1. Optional.
Every refusal, with its code7 refusals
CodeWhen
PROTEIN_LEVELthe hits are protein-level.
DUPLICATE_PEPTIDEat peptide level, a label appears more than once.
ESTIMATOR_NOT_FOR_SEPARATEdecoys over all hits is asked for in a separate search.
RATIO_NOT_SUPPORTED_FOR_SEPARATEa separate search with a decoy-to-target ratio other than one.
NO_TARGETSno target hit in the list.
NO_DECOYSno decoy hit in the list.
MISSING_ARGUMENTa hit has no label at peptide level.

The calculation

The method's equations, constants and worked example.

Target-decoy false discovery rate and q-valuestarget-decoy-fdr@1.0.1

Equation 1

FDR(s)=D/(rxT)
SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source 1.

Equation 2

FDR(s)=Dx(1+1/r)/(T+D)
SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source 1.

Equation 3

with decoyCountCorrection plus-one: FDR(s) = (D + 1) / (r x T), and over all hits (D + (D + 1)/r) / (T + D)

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source 2.

Equation 4

reported estimate = min(FDR(s), 1)

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source not recorded.

Equation 5

one where T = 0 and D > 0

not given where T = D = 0 and nothing is added

with plus-one, an estimate where no target is accepted is one, T = D = 0 included

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source not recorded.

Equation 6

q_i = min over distinct cutoffs s at or worse than score_i of min(FDR(s), 1)

target hits only

the minimum over cutoffs at or worse than the hit's score is Storey and Tibshirani's minimum over thresholds t >= p_i under a monotone map from score to p-value, which is this project's ruling

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap
q_iq-value of target hit i

Source 3.

Equation 7

rows follow the input order

decoy rows carry no estimate or q-value

rank = 1 + the number of hits scoring strictly better

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source not recorded.

Equation 8

at fdrLevel, the cutoff is the least stringent score held by a target with q <= fdrLevel (inclusive), T and D counted at that score

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source not recorded.

Equation 9

Every estimate, the cap and the running minimum are computed on exact values, the ratio and the level read as below, and the decision q <= fdrLevel is made on those exact values. Each reported estimate and q-value is then rounded once to the nearest double. A printed q can therefore equal the level while its exact value lies above it, and that hit is excluded.

SymbolMeaning
Ddecoy hits scoring at or past the cutoff, ties included
Ttarget hits scoring at or past the cutoff, ties included
rdecoyToTargetRatio, decoy over target candidate sequences in the search
FDR(s)estimated false discovery rate at cutoff s, before the cap

Source not recorded.

Conventions

  • TIES_ACCEPTED_TOGETHER = ties accepted together: Fixed by the method; not an argument. Every hit tied at a score is accepted or rejected with it; the estimate is taken only at distinct scores, and tied targets share one q-value.
  • PI0_ONE = 1: Fixed by the method; not an argument. The proportion of incorrect target hits is taken as one, so the estimates are conservative.
  • FDR_CAPPED_AT_ONE = 1: Fixed by the method; not an argument. Every estimate is capped at one before the q-value's minimum, and an estimate where decoys are accepted but no target is set to one.

A definition, not a model: the equation states what the quantity means. A different convention gives a different number.

Worked example

Worked example: one case of target-decoy-fdr@1.0.1, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.

Inputs

  • hits[0].score = 10
  • hits[0].kind = target
  • hits[1].score = 9
  • hits[1].kind = target
  • hits[2].score = 8
  • hits[2].kind = decoy
  • hits[3].score = 7
  • hits[3].kind = target
  • hits[4].score = 7
  • hits[4].kind = target
  • hits[5].score = 6
  • hits[5].kind = target
  • hits[6].score = 5
  • hits[6].kind = decoy
  • hits[7].score = 4
  • hits[7].kind = target
  • hits[8].score = 3
  • hits[8].kind = decoy
  • hitLevel = psm
  • scoreDirection = higher-is-better
  • searchMode = concatenated
  • fdrEstimator = decoys-over-targets
  • decoyCountCorrection = none
  • decoyToTargetRatio = 1
  • fdrLevel = 0.25
  • scoreThreshold = 6

Steps

  1. fdr-7 = 0.25, from hits, decoyToTargetRatio; by equation 1; gives rows[3].estimatedFdr.
  2. fdr-6 = 0.2, from hits, decoyToTargetRatio; by equation 1; gives rows[5].estimatedFdr.
  3. fdr-5 = 0.4, from hits, decoyToTargetRatio; by equation 1.
  4. fdr-4 = 0.33333333, from hits, decoyToTargetRatio; by equation 1.
  5. fdr-3 = 0.5, from hits, decoyToTargetRatio; by equation 1.
  6. q-7 = 0.2, from fdr-7, fdr-6, fdr-5, fdr-4, fdr-3; by equation 6; gives rows[3].qValue.

The working, as the case writes it:

Cumulative T, D at scores 10..3: (1,0) (2,0) (2,1) (4,1) (5,1) (5,2) (6,2) (6,3)

D/T = 0, 0, 1/2, 1/4, 1/5, 2/5, 1/3, 1/2

q from the worst score up = 0, 0, 1/5, 1/5, 1/5, 1/3, 1/3, 1/2. The two targets at 7 share 1/5. At level 0.25 the least stringent target with q <= 0.25 scores 6: 5 targets, 1 decoy. At threshold 6 the estimate is 1/5.

Answer

rows[3].estimatedFdr = 0.25

rows[5].estimatedFdr = 0.2

rows[3].qValue = 0.2

Where these values came from: our own exact-arithmetic script and a hand-worked case; exact rationals (Python fractions), by this script, from Drybench's rulings of 11 November 2026.

At build the tool returned this answer within the tolerance the file states: Estimates, q-values and cutoffs within absolute 1e-12 (each rounded once from an exact quotient; the decision at fdrLevel is exact); ranks, counts, kinds, texts, statuses and codes exact.

Sources

  1. Elias JE, Gygi SP. Target-decoy search strategy for mass spectrometry-based proteomics. Methods Mol Biol 2010;604:55-71

    Used for: Target-decoy false discovery rate and q-values. At: equation 1-5; Eq. 2's T is all hits (T + D here).

    Read in full, 14 November 2026
  2. pyteomics 5.0.2, stored reference values (Levitsky LI, Klein JA, Ivanov MV, Gorshkov MV. Pyteomics 4.0. J Proteome Res 2019;18:709-714), Apache-2.0

    Used for: Target-decoy false discovery rate and q-values. At: section _calculate_qvalues, lines 59-79: correction 1 adds one to the decoy count; formula 1 is tfalse / targets / ratio, formula 2 is (decoys + tfalse / ratio) / hits.

    Read in full, 11 November 2026
  3. Storey JD, Tibshirani R. Statistical significance for genomewide studies. Proc Natl Acad Sci USA 2003;100:9440-9445

    Used for: Target-decoy false discovery rate and q-values. At: section Proposed Method and Results: q(p_i) = min over t >= p_i of FDR(t), the rendered equation; Appendix, Remark A.

    Read in full, 14 November 2026

How it is checked

Level

Checked against a reference.

Checked against

Our own exact-arithmetic script and a hand-worked case; a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-14, exact rationals (Python fractions) on the exact value of each input double, each output rounded once to the nearest double; not an outside program.

Cases

No case set is linked to this version.

Not checked

Käll et al. 2008 not read (subscription); the q-value rests on Storey and Tibshirani 2003; the map from score to p-value is Drybench's ruling; the plus-one correction's primary source is not read (He et al., arXiv 1501.00537, Eq.

What was not checked, in fullfrom the method records
  • Käll et al.
  • 2008 not read (subscription); the q-value rests on Storey and Tibshirani 2003; the map from score to p-value is Drybench's ruling; the plus-one correction's primary source is not read (He et al., arXiv 1501.00537, Eq.
  • 8, is the candidate, its equations images not yet confirmed); decoys over all hits with plus-one follows pyteomics 5.0.2, with no published equation, and does not count towards the level; Käll's p.
  • 31 counts are checked in the script only, being over the hit cap; one session wrote the first script and the engine, and a second implementation in Python by a separate agent of the same model family agrees on 52 cases.
What this project's records still lack1 thing
  • The source's location for each equation for target-decoy-fdr@1.0.1.
Changes to its methods0 changes

No change is logged for these method versions.