# Target-decoy false discovery rate and q-values, version 1.0.1

target-decoy-fdr\@1.0.1: this version's equations with their symbols, each constant's value, their sources and whether each was read, a worked example where the record holds one, its level and what it was checked against, the number of cases, and what was not checked. This version's record is not rewritten; a correction is added under Changes.

## What this page can and cannot show

**Level: Checked against a reference; pyteomics 5.0.2 q-values; q-value as Storey and Tibshirani 2003; all-hits plus-one from pyteomics. Research arithmetic. Reference kind: 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.**

Not fully recorded, and not independently reviewed. Items marked "Not recorded" are missing from this project's records for the version named. Apart from any worked example shown, the cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed these methods or checks.

[Every version of this method](https://www.drybench.com/methods/m/target-decoy-fdr) · [Every method](https://www.drybench.com/methods/m) · [What the levels mean](https://www.drybench.com/methods/levels)

## Version 1.0.1

**Level: Checked against a reference; pyteomics 5.0.2 q-values; q-value as Storey and Tibshirani 2003; all-hits plus-one from pyteomics. Research arithmetic. Reference kind: 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.** `target-decoy-fdr@1.0.1`

Built, not hosted. Generated from a snapshot of the library's records taken on 2026-11-25, as committed on 2026-11-25. A later snapshot replaces this one, so these records and this page can change.

**Verification statement:** Estimators as Elias and Gygi 2010 Eqs 1–5, re-read at source 14 November 2026; plus-one forms as pyteomics 5.0.2 computes them, with no published equation for the all-hits form; q-value the minimum estimate over cutoffs at or worse than the hit's score (Storey and Tibshirani 2003), each estimate capped at one. q-values compared with pyteomics 5.0.2 on 34 cases, tied scores excluded because pyteomics orders ties one by one. Every output compared with a second implementation in Python by a separate agent of the same model family (52 cases, 27 at the edges). Decisions at fdrLevel are exact. Research arithmetic.

The estimated false discovery rate at every distinct score of a scored target and decoy list, by a stated estimator, ratio and decoy-count correction, each estimate capped at one, and each target's q-value: the smallest estimate at any cutoff at or worse than its score.

- **How results are reported:** Each number in the call arrives as a double and is read as the exact rational value of the shortest decimal that converts back to that double (the decimal JavaScript's Number-to-String gives: 0.7 is read as 7/10, not as the double's binary value; −0 is read as 0). Every range end, threshold, refusal at a bound, flag and met-or-not decision is made exactly on those rationals, on the side this record states (at or above; strictly below). Each reported number is the exact result rounded once to the nearest double. Counts are exact; a score cutoff is the stated score. A decoyToTargetRatio of zero or below, or an fdrLevel of zero or below or above one, is the kit's OUT\_OF\_RANGE. An omitted scoreDirection, searchMode, fdrEstimator or decoyCountCorrection answers CONVENTION\_REQUIRED; an omitted hitLevel, decoyToTargetRatio or hits answers MISSING\_ARGUMENT. The refusals are checked in this order: PROTEIN\_LEVEL, DUPLICATE\_PEPTIDE, ESTIMATOR\_NOT\_FOR\_SEPARATE, RATIO\_NOT\_SUPPORTED\_FOR\_SEPARATE, NO\_TARGETS, NO\_DECOYS. Notes appear in the order NO\_HIT\_AT\_FDR\_LEVEL, NO\_HIT\_AT\_SCORE\_THRESHOLD.
- **Uncertainty:** No variance of the estimate is given (Drybench's limits line).
- **Reference, as its record states it:** pyteomics 5.0.2 q-values on 34 cases; a second implementation in Python by a separate agent of the same model family
- **Level confirmed by this project's ruling of** 14 November 2026

[What this page can and cannot show](#what-this-page-can-and-cannot-show)

### What was checked

80 cases in 2 files, linked by this exact version.

Run through the tool at build 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: 75 agree within the tolerance the file states, 5 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 28 cases**
  - **Where the expected values came from:** our own exact-arithmetic script and a hand-worked case
  - **Recorded on:** 2026-11-11
  - **Reference:** exact rational script (Python fractions), 3.13.18; licence PSF-2.0
  - **Tolerance as the file states it:** 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

- **File 2, 52 cases**
  - **Where the expected values came from:** an outside program, second implementation (Python 3.13) 2026-11-14
  - **Recorded on:** 2026-11-14
  - **Reference:** second implementation (Python 3.13), 2026-11-14; licence BSD-3-Clause
  - **Tolerance as the file states it:** every number relative 1e-12 (absolute 1e-15 below 1e-3, in each value's unit); counts, labels, formulas, strings, flags, statuses and codes exact

Apart from the worked example, the cases and their values are not printed here. This shows agreement with this project's recorded cases. It does not show that a method suits your work, and it is not a qualification.

### What was 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. 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.

### Definition or model

A closed form: the result follows from the inputs by the equations alone.

### Equations

**Equation 1**

```equation
FDR(s) = D / (r x T)
```

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Source: Elias JE, Gygi SP. Target-decoy search strategy for mass spectrometry-based proteomics. Methods Mol Biol 2010;604:55-71, equation 1-5; Eq. 2's T is all hits (T + D here), author manuscript (PMC2922680), the PMC article page as served on 14 November 2026; read in full on 2026-11-14 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 511d8168c03f. Free to read (NIH author manuscript on PMC (public access; reuse terms not read)), checked 2026-11-11. No erratum found (searched web search: the chapter title with erratum or correction), 2026-11-11.

**Equation 2**

```equation
FDR(s) = D x (1 + 1/r) / (T + D)
```

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Source: Elias JE, Gygi SP. Target-decoy search strategy for mass spectrometry-based proteomics. Methods Mol Biol 2010;604:55-71, equation 1-5; Eq. 2's T is all hits (T + D here), author manuscript (PMC2922680), the PMC article page as served on 14 November 2026; read in full on 2026-11-14 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning 511d8168c03f. Free to read (NIH author manuscript on PMC (public access; reuse terms not read)), checked 2026-11-11. No erratum found (searched web search: the chapter title with erratum or correction), 2026-11-11.

**Equation 3**

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

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Source: 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, 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, 5.0.2 wheel, the file as installed; read in full on 2026-11-11 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning e7b40cf7e975. Free to read (Apache-2.0), checked 2026-11-11. No erratum found (searched the package's release notes for 5.0.2), 2026-11-11.

**Equation 4**

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

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Ruling of this project: 11 November 2026, section "2. Reasoning". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.

**Equation 5**

```equation
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
```

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Ruling of this project: 11 November 2026, section "Addendum, 11 November 2026 (the CSO, answering the builder)". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.

**Equation 6**

```equation
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
```

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |
| q\_i | q-value of target hit i |

Source: Storey JD, Tibshirani R. Statistical significance for genomewide studies. Proc Natl Acad Sci USA 2003;100:9440-9445, section Proposed Method and Results: q(p\_i) = min over t >= p\_i of FDR(t), the rendered equation; Appendix, Remark A, the PMC article page as served on 14 November 2026 (the PDF behind a reCAPTCHA); equations read as their rendered images; read in full on 2026-11-14 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning e501b9674cc9. Free to read (PNAS open access via PMC (reuse terms not read)), checked 2026-11-14. No erratum found (searched the PMC article page's corrections links), 2026-11-14.

**Equation 7**

```equation
rows follow the input order
decoy rows carry no estimate or q-value
rank = 1 + the number of hits scoring strictly better
```

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Ruling of this project: 11 November 2026, section "2. Reasoning". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.

**Equation 8**

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

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Ruling of this project: 11 November 2026, section "2. Reasoning". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.

**Equation 9**

```equation
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.
```

| Symbol | Meaning and unit |
| --- | --- |
| D | decoy hits scoring at or past the cutoff, ties included |
| T | target hits scoring at or past the cutoff, ties included |
| r | decoyToTargetRatio, decoy over target candidate sequences in the search |
| FDR(s) | estimated false discovery rate at cutoff s, before the cap |

Ruling of this project: 11 November 2026, section "2. Exact rationals, or a ruled order?". Not yet published; its effect is stated on this page. A choice this project made, not a value from the literature.

### 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.

### Constants

Constants: none used.

### 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:

```equation
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.

Who worked this case: not recorded.

### What it refuses, and its input ranges

- `PROTEIN_LEVEL`: the hits are protein-level Next: No change of input makes this computable on these data; protein-level FDR needs a protein scoring scheme.
- `DUPLICATE_PEPTIDE`: at peptide level, a label appears more than once Next: Keep each peptide's best hit only, or call again at the psm level.
- `ESTIMATOR_NOT_FOR_SEPARATE`: decoys over all hits is asked for in a separate search Next: Ask the person whether the search was concatenated; for a separate search use decoys over targets.
- `RATIO_NOT_SUPPORTED_FOR_SEPARATE`: a separate search with a decoy-to-target ratio other than one Next: No change of input makes this computable on these data.
- `NO_TARGETS`: no target hit in the list Next: Give the list with its target hits.
- `NO_DECOYS`: no decoy hit in the list Next: Give the list with its decoy hits; without them nothing can be estimated.
- `MISSING_ARGUMENT` (invalid input): a hit has no label at peptide level

### Flags and notes a reply may carry

A note a reply may carry:

- `NO_HIT_AT_FDR_LEVEL`: No score has a q-value at or below fdrLevel, so no hit is accepted at this level. With plus-one, a short list cannot reach a strict level.
- `NO_HIT_AT_SCORE_THRESHOLD`: No hit scores at or past scoreThreshold and no decoy is added, so the estimate there is zero over zero and is not given.

### Changes

No correction is logged for target-decoy-fdr\@1.0.1.

## Tools that use it

- [`ms_target_decoy_fdr`](https://www.drybench.com/methods/tools/ms-target-decoy-fdr)

## Cite this version

Target-decoy false discovery rate and q-values. Drybench; target-decoy-fdr\@1.0.1; [https://www.drybench.com/methods/m/target-decoy-fdr/1.0.1](https://www.drybench.com/methods/m/target-decoy-fdr/1.0.1) (accessed \[date\]).
