Count-based transcripts per million per gene and sample, version 2.0.0
ngs-expression-count-tpm@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; Agrees with rnanorm 2.2.0 and exact rationals; counts stand in for estimated abundances. Reference kind: our own exact-arithmetic script and a hand-worked case.
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 · Every method · What the levels mean
Version 2.0.0
Level: Checked against a reference; Agrees with rnanorm 2.2.0 and exact rationals; counts stand in for estimated abundances. Reference kind: our own exact-arithmetic script and a hand-worked case. ngs-expression-count-tpm@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: count-based TPM checked against rnanorm 2.2.0 on random cases and exactly against rationals in a script of our own, hand-worked, with lengths in bp and kb; the counts-for-abundances substitution is a stated convention
Count-based TPM = (count / length) / sum over genes of (count / length) x 10^6 for each sample: Li and Dewey 2011's tau x 10^6 with counts in place of their estimated abundances, a stated convention; lengths annotated or effective, one vector or one per sample; an all-zero sample is withheld.
- How results are reported: none: full double precision, unrounded; each TPM is within a few ulps of the exact value on the counts and lengths given (each rate rounded once, a compensated sum, one quotient and one product), so relative 1e-14 holds at the 6,000-value cap (SEQ-F16 fixed in 2.0.0), where every rate is a normal double; where a rate c/l would overflow (a length far below a base), the rates are scaled by the smallest length first, c x (l_min / l), the same shares, and the rule holds where every scaled rate is a normal double (S128)
- Uncertainty: Double-precision arithmetic on the supplied counts and lengths; counting noise and length uncertainty are not propagated.
- Reference, as its record states it: rnanorm 2.2.0's TPM on random cases (the outside comparison), with exact rational arithmetic in a script of our own
- Level confirmed by this project's ruling of 14 November 2026
What this page can and cannot show
What was checked
61 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: 29 agree within the tolerance the file states, 32 refuse as the case expects, 0 differ, 0 were not run.
File 1, 30 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-14
- Reference: second implementation (Python 3.13), 2026-11-14; licence BSD-3-Clause
- Tolerance as the file states it: TPM relative 1e-14 (zero exact); texts, statuses, codes and withheld rules exact
File 2, 31 cases
- Where the expected values came from: our own exact-arithmetic script and a hand-worked case
- Recorded on: 2026-11-14
- Reference: CPython standard library (fractions), 3.13.18; licence PSF-2.0
- Tolerance as the file states it: TPM relative 1e-14 (zero exact); texts, 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
Agreement with TPM from an expectation-maximisation quantifier (not the same quantity); gene lengths derived from isoforms (not done).
Definition or model
A closed form: the result follows from the inputs by the equations alone.
Equations
TPM_gj = (c_gj / l_gj) / sum over the supplied genes h of (c_hj / l_hj) x 10^6: Li and Dewey's tau x 10^6, with counts c in place of their estimated theta (a stated convention) and l their effective length l'
annotated lengths are the record's extension
the sum is compensated (Neumaier) in input order
lengths are at most 10 Mb, above the longest human gene spans read (NCBI Gene, GRCh38.p14, RS_2025_08, read 14 November 2026: CNTNAP2 2,304,198 bp, DMD 2,220,167 bp
genes of other species not checked), so titin's longest transcript, 109,224 bp, is taken
inputs are read as the exact value of their shortest decimal, and the range and whole-number tests are decided on that value
TPM is in double precision
order of checks: the kit's checks of each argument in schema order (a bare array where { values, unit } is expected is UNIT_REQUIRED, an object with no unit is MISSING_UNIT, a count above 1e10 or below 0 and a length above 10 Mb or not above 0 are OUT_OF_RANGE), then DUPLICATE_NAME (genes, then samples), then MATRIX_ABOVE_CAP, then per sample in order VALUES_MISALIGNED and, for read counts, NOT_AN_INTEGER, then the measure's argument checks (with count-based-tpm, in this order: MISSING_ARGUMENT without lengthBasis
CONFLICTING_ARGUMENT for libraryBasis, for a librarySize, for geneLengths with effectiveLengths, for per-sample lengths under annotated, then for effectiveLengths in some samples only
MISSING_ARGUMENT with no lengths
then VALUES_MISALIGNED for geneLengths, then per sample for effectiveLengths)
| Symbol | Meaning and unit |
|---|---|
| TPM_gj | count-based transcripts per million, transcriptsPerMillion |
| c_gj | count of gene g in sample j |
| l_gj | length of gene g, for sample j where given per sample, bp |
Source: Li B, Dewey CN (2011), RSEM: accurate transcript quantification from RNA-Seq data with or without a reference genome, BMC Bioinformatics 12:323, doi 10.1186/1471-2105-12-323, section tau_i = (theta_i / l'_i) / sum over j != 0 of theta_j / l'_j at Methods, Statistical model, "Expectation-Maximation" (so printed; equation image 1471-2105-12-323-i9.gif); TPM = tau x 10^6 at Implementation, "Read mapping and abundance estimation", version of record, Europe PMC full-text XML; 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 cea9de0746fc. Free to read (CC BY), checked 2026-11-11. No erratum found (searched Europe PMC correction list for doi 10.1186/1471-2105-12-323), 2026-11-11.
Conventions
What each mode computes:
measure = count-based-tpm: Li and Dewey's TPM with counts in place of their estimated abundances: each count over its length, as a share of the sample's sum, times one millionlengthBasis = annotated: the lengths are annotated gene lengths, one vector for every samplelengthBasis = effective: the lengths are effective lengths, one vector for every sample or one per sample
Constants
Constants: none used.
Worked example
Worked example: one case of ngs-expression-count-tpm@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
- measure = count-based-tpm
- countKind = read-counts
- lengthBasis = annotated
- genes[0] = geneA
- genes[1] = geneB
- genes[2] = geneC
- samples[0].id = s1
- samples[0].counts.values[0] = 100
- samples[0].counts.values[1] = 100
- samples[0].counts.values[2] = 0
- samples[0].counts.unit = 1
- geneLengths.values[0] = 1000
- geneLengths.values[1] = 4000
- geneLengths.values[2] = 500
- geneLengths.unit = bp
Steps
- tA = 800000 transcriptsPerMillion, from samples[0].counts, geneLengths; by the equation above; gives result.samples[0].expression.values[0].
- tB = 200000 transcriptsPerMillion, from samples[0].counts, geneLengths; by the equation above; gives result.samples[0].expression.values[1].
The working, as the case writes it:
s1: TPM = 800000, 200000, 0
Answer
result.samples[0].expression.values[0]= 800000 transcriptsPerMillionresult.samples[0].expression.values[1]= 200000 transcriptsPerMillion
Where these values came from: our own exact-arithmetic script and a hand-worked case; Worked by hand by Drybench on 11 November 2026 (ruling 7). This is not an independent check.
At build the tool returned this answer within the tolerance the file states: TPM relative 1e-14 (zero exact); texts, statuses, codes and withheld rules exact.
Who worked this case: not recorded.
What it refuses, and its input ranges
VALUES_MISALIGNED(invalid input): a sample's counts, or a length vector, does not have one value per geneMATRIX_ABOVE_CAP(invalid input): the counts and lengths together are more numeric cells than the tool's cap; a smaller gene subset changes the results
Input ranges: geneLengths: at most 10000000 bp; outside it, invalid input (OUT_OF_RANGE).
Changes
2026-11-14-ngs-expression-count-tpm@2.0.0-1
2026-11-14 · ngs-expression-count-tpm@2.0.0 · Corrections to our methods
- What was wrong: Count-based TPM summed each sample's rates in plain double arithmetic. At the 6,000-value cap the result was 1.7e-14 relative off the exact value, above the record's stated 1e-14. The gene-length cap of 100,000 bp also refused real lengths: titin's transcript variant IC is 109,224 bp.
- Affected: Count-based TPM in version 1.0.0 of the assistant tool ngs_expression_normalise: values on large gene sets differed from the exact value in the last digits (observed 1.7e-14 relative at the 6,000-value case; a plain sum of up to 2,000 positive terms can be off by up to about 2e-13 relative), immaterial to biology; lengths above 100,000 bp up to 10 Mb were refused; and a length far below a base, whose rate overflows a double, got no reply.
- What changed: In 2.0.0 the sum of the rates is compensated (Neumaier), so each TPM is within a few ulps of the exact value and the 6,000-value case gives exactly 1,000. Lengths are taken up to 10 Mb, above the longest human gene spans read (CNTNAP2 and DMD, NCBI Gene, GRCh38.p14; other species not checked), and rates that would overflow are scaled by the smallest length first. The record corrects Li and Dewey's locators and states the order of checks; rnanorm 2.2.0's TPM is recorded as an outside check.
- How it was found: A second implementation in Python by a separate agent of the same model family, in the raising run's full check of 14 November 2026 (finding SEQ-F16); the length cap from the CSO's review of the same run (S98).
- Cases added: stored reference values re-records the retired -1 at 2.0.0, with the 6,000-value case, lengths at and above 10 Mb, titin's transcript and three random cases checked against rnanorm 2.2.0.
Tools that use it
Cite this version
Count-based transcripts per million per gene and sample. Drybench; ngs-expression-count-tpm@2.0.0; https://www.drybench.com/methods/m/ngs-expression-count-tpm/2.0.0 (accessed [date]).