# Library size in distinct molecules from read-pair duplicate counts, version 2.0.0

ngs-library-complexity\@2.0.0: 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; Picard 3.4.0's estimator reproduced at duplicate fraction 1e-3 and above; a model, no measured prediction error. Reference kind: a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-14, mpmath 1.4.1 at 100 digits: bisection on ln y in the record's bracket, rounded once; not an outside program.**

Checked by this project, not independently reviewed. Every method on this page has its equations, constants, sources and cases on record, and its cases agree with the stated reference within the stated tolerance. A reader can follow each method's worked example by hand; that shows the stated method gives the stated answer for one set of inputs, and does not test the code. The other cases and their values are not printed, so a reader cannot re-run these checks. No independent scientist has yet reviewed them.

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

## Version 2.0.0

**Level: Checked against a reference; Picard 3.4.0's estimator reproduced at duplicate fraction 1e-3 and above; a model, no measured prediction error. Reference kind: a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-14, mpmath 1.4.1 at 100 digits: bisection on ln y in the record's bracket, rounded once; not an outside program.** `ngs-library-complexity@2.0.0`

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:** Picard 3.4.0's estimator (DuplicationMetrics through its jar) reproduced to the molecule where Picard's double arithmetic and 40-step bisection resolve the root (duplicate fraction >= 1e-3, bisection resolution below half a molecule); 54 cases within 1e-12 relative (the fixture's tolerance); about 1e-14 measured on the cases run, of a second implementation in Python by a separate agent of the same model family, solved in mpmath at 100 digits, to 10^15 pairs and one distinct pair; few-duplicate limit checked by series by hand; the equation is a model, no measured prediction error

Solves C/X = 1 - exp(-N/X) for the number of distinct molecules X, with N the read pairs less optical duplicates and C the distinct pairs, as Picard defines them; returns the pairs used, the distinct pairs, the duplicate fraction and, as a model, X and C/X.

- **How results are reported:** none: full double precision, unrounded (Picard truncates to a whole number)
- **Uncertainty:** A model with no measured prediction error; from the count of duplicate events alone, about 1/sqrt(D) relative (a judgement).
- **Iterates:** bisection, at most 200 iterations, between y = 2d and y = N/C
- **Reference, as its record states it:** Picard 3.4.0 run offline and a second implementation in Python by a separate agent of the same model family (mpmath at 100 digits)
- **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

54 cases in 1 file, linked by this exact version.

Run through the tool at build against a reference program this project wrote itself, second implementation (Python 3.13), 2026-11-14, mpmath 1.4.1 at 100 digits: bisection on ln y in the record's bracket, rounded once; not an outside program: 42 agree within the tolerance the file states, 12 refuse as the case expects, 0 differ, 0 were not run.

- **File 1, 54 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:** relative 1e-12 (exact below 1e-300); Picard agreement asserted by the generator as floor equality where its arithmetic resolves the root; statuses, codes and withheld rules 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

Lander and Waterman 1988 itself (cited through Picard); real libraries against UMI-counted molecules; how the upstream tool marks duplicates and optical duplicates; unpaired reads; Picard's ROI projection (out of 1.0.0); Daley and Smith 2013.

### Definition or model

A model of nature: it describes how a system behaves, and can be wrong about it.

Prediction error: none available.

### Equations

**Equation 1**

```equation
C/X = 1 - exp(-N/X)
with d = (N - C)/N from the integers and y = N/X: g(y) = 1 - (1 - e^(-y))/y = d, X = N/y
fraction of the library observed = C/X
```

| Symbol | Meaning and unit |
| --- | --- |
| X | distinct molecules in the library |
| N | read pairs examined less optical duplicate pairs |
| C | read pairs examined less duplicate pairs |
| d | duplicate events per pair used |

Source: Picard (Broad Institute), stored reference values, the Javadoc of estimateLibrarySize and calculateDerivedFields, equation C/X = 1 - exp(-N/X) (lines 136 to 141); ESTIMATED\_LIBRARY\_SIZE (line 111); PERCENT\_DUPLICATION (line 115), release tag 3.4.0; 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 af744e2ce9be. Free to read (MIT), checked 2026-11-11. No erratum found (searched Picard's release notes for 3.4.0), 2026-11-11.

**Equation 2**

```equation
the root y lies in [2d, N/C] (g(y) <= y/2
g(N/C) >= d)
bisection on the natural log of y, starting from lo = ln(2d) and hi = ln(N/C), at most 200 iterations: mid = (lo + hi)/2 in double
if mid equals lo or hi the solve has settled and y = e^mid, else lo = mid when the root lies above e^mid and hi = mid otherwise
the root lies above e^mid when g(e^mid) < d (g increases with y) or, where 2(N - C) > N, when h(e^mid) > c (the same test on the complement, h = 1 - g, c = C/N, 2.0.0)
X = N/y
an unconverged solve is refused with the kit's NO_CONVERGENCE and returns no number
```

| Symbol | Meaning and unit |
| --- | --- |
| y | N/X |

Source: Picard (Broad Institute), stored reference values, the Javadoc of estimateLibrarySize and calculateDerivedFields, equation C/X = 1 - exp(-N/X) (lines 136 to 141); ESTIMATED\_LIBRARY\_SIZE (line 111); PERCENT\_DUPLICATION (line 115), release tag 3.4.0; 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 af744e2ce9be. Free to read (MIT), checked 2026-11-11. No erratum found (searched Picard's release notes for 3.4.0), 2026-11-11.

**Equation 3**

```equation
duplicateFraction = READ_PAIR_DUPLICATES / READ_PAIRS_EXAMINED, optical included (Picard's PERCENT_DUPLICATION on pairs only)
```

| Symbol | Meaning and unit |
| --- | --- |
| duplicateFraction | fraction of pairs marked duplicate |

Source: Picard (Broad Institute), stored reference values, the Javadoc of estimateLibrarySize and calculateDerivedFields, equation C/X = 1 - exp(-N/X) (lines 136 to 141); ESTIMATED\_LIBRARY\_SIZE (line 111); PERCENT\_DUPLICATION (line 115), release tag 3.4.0; 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 af744e2ce9be. Free to read (MIT), checked 2026-11-11. No erratum found (searched Picard's release notes for 3.4.0), 2026-11-11.

### Constants

Constants: none used.

### Worked example

Worked example: one case of ngs-library-complexity\@2.0.0, 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**

- readPairsExamined = 10
- readPairDuplicates = 1
- readPairOpticalDuplicates = 0

**Steps**

1. dup = 0.1, from readPairDuplicates, readPairsExamined; by equation 3; gives result.duplicateFraction.
2. d = 0.1, from readPairsExamined, readPairDuplicates, readPairOpticalDuplicates; by equation 1.
3. y = 0.21455574, from d; by equation 2.
4. X = 46.607935, from readPairsExamined, y; by equation 1; gives result.model.estimatedLibrarySize.

The working, as the case writes it:

```equation
N = 10, C = 9, d = 0.1
g(y) = 1 - (1 - e^-y)/y = 0.1 at y = 0.21455574
X = 10/y = 46.607935 (worked by hand by the raising builder, 14 November 2026)
```

**Answer**

- `result.duplicateFraction` = **0.1**
- `result.model.estimatedLibrarySize` = **46.607935**

Where these values came from: an outside program, second implementation (Python 3.13) 2026-11-14; the second implementation's run(arguments).

At build the tool returned this answer within the tolerance the file states: relative 1e-12 (exact below 1e-300); Picard agreement asserted by the generator as floor equality where its arithmetic resolves the root; statuses, codes and withheld rules exact.

Who worked this case: not recorded.

### What it refuses, and its input ranges

- `ALL_DUPLICATES`: every pair examined is a duplicate: the counts are inconsistent, since every duplicate set keeps one pair Next: Check the counts against the duplicate metrics file.
- `PAIRS_ABOVE_RANGE`: the read pairs are above the method's range, beyond which the counts are not exact in double Next: No change of input makes this computable on these data.

**Input ranges:** readPairsExamined: at most 1000000000000000; outside it, refused (PAIRS\_ABOVE\_RANGE).

### Changes

#### 2026-11-14-ngs-library-complexity\@2.0.0-1

2026-11-14 · [`ngs-library-complexity@2.0.0`](https://www.drybench.com/methods/m/ngs-library-complexity) · Corrections to our methods

- **What was wrong:** When nearly every read pair was a duplicate, the estimated library size lost precision: the solver compared two quantities that were both within a few parts in 10^16 of 1, so the size carried a relative error of about 1e-16 times the pairs used over the distinct pairs. With one distinct pair the size was off by 4e-13 at 10^4 pairs, 3e-8 at 10^9 pairs, 3e-5 at 10^12 pairs and 5.5 % at 10^15 pairs (1.055 molecules where the answer is 1); with 1,000 distinct pairs at 10^15 pairs, by 3e-5.
- **Affected:** estimatedLibrarySize and fractionOfLibraryObserved from ngs\_library\_complexity in version 1.0.0, where more than half of the pairs used were duplicate events; the error was below 1e-12 relative only while the pairs used were fewer than about 10^4 times the distinct pairs. Below half duplicates no number changed.
- **What changed:** In 2.0.0, where more than half of the pairs used are duplicate events, the solver compares the fraction of distinct pairs, (1 - e^(-y))/y against C/N, which keeps full relative precision. The size is now within 1e-12 relative (the fixture's tolerance); about 1e-14 measured on the cases run: within 1e-14 on the 54 cases of stored reference values, whose expected values are the second implementation's solve in mpmath at 100 digits, and at most 1.0e-14 on a sweep of N from 2 to 10^15 pairs and C/N from 10^-15 to 1 - 10^-15 against a solve in mpmath at 60 digits, a check of our own made at the fix and not kept in the repository. One published case moved: stored reference values#one-distinct (1,000 pairs, one distinct pair), from 1.000000000000057 to 1.0000000000000002, within its 1e-12 tolerance either way.
- **How it was found:** The raising run's full check on 14 November 2026 (RAISE-F20): a second implementation in Python by a separate agent of the same model family, at 100 digits, differed from the tool on its edge case edge-cap-one-distinct (10^15 pairs, one distinct pair).
- **Cases added:** stored reference values: 54 cases from the second implementation, 19 of them checked against Picard 3.4.0 run offline, among them edge-cap-one-distinct; unit tests hold the size within 1e-12 of C for C far below N up to 10^15 pairs and show 1.0.0's comparison failing at that case.

## Tools that use it

- [`ngs_library_complexity`](https://www.drybench.com/methods/tools/ngs-library-complexity)

## Cite this version

Library size in distinct molecules from read-pair duplicate counts. Drybench; ngs-library-complexity\@2.0.0; [https://www.drybench.com/methods/m/ngs-library-complexity/2.0.0](https://www.drybench.com/methods/m/ngs-library-complexity/2.0.0) (accessed \[date\]).
