Skip to content

Methods and checksMethods

How every result is reached and what it was checked against, app by app.

Methods and checks pages

Median-of-ratios size factor per sample, version 1.0.1

ngs-size-factors-mor@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; Anders and Huber Eq. 5; pydeseq2 0.5.4 agrees within 6e-16 relative; counts at most 1e10. 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 1.0.1

Level: Checked against a reference; Anders and Huber Eq. 5; pydeseq2 0.5.4 agrees within 6e-16 relative; counts at most 1e10. Reference kind: our own exact-arithmetic script and a hand-worked case. ngs-size-factors-mor@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: Median of ratios as Anders and Huber 2010 Eq. 5 states it (re-read at source 14 November 2026), on genes positive in every sample. Compared with pydeseq2 0.5.4 (within 6e-16 relative), and with a second implementation in Python by a separate agent of the same model family (35 cases, 14 at the edges). Counts at most 1e10.

Anders and Huber 2010's Eq. 5: each sample's size factor is the median over genes of its count over the gene's geometric mean across samples, in log space, using only genes positive in every sample; returned unrescaled with a copy rescaled to geometric mean one.

  • How results are reported: none: full double precision, unrounded
  • Uncertainty: Double-precision arithmetic on the supplied counts; counting noise is not propagated.
  • Reference, as its record states it: pydeseq2 0.5.4, with a 50-digit decimal 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

57 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: 32 agree within the tolerance the file states, 25 refuse as the case expects, 0 differ, 0 were not run.

  • File 1, 22 cases

    • Where the expected values came from: our own exact-arithmetic script and a hand-worked case
    • Recorded on: 2026-11-11
    • Reference: In-house decimal reference (CPython decimal, 50 digits), cross-checked against pydeseq2 0.5.4, 3.13.18; licence PSF-2.0 (decimal); pydeseq2 MIT
    • Tolerance as the file states it: factors and their geometric mean relative 1e-13 against the 50-digit reference; gene counts, gene lists, texts, statuses and codes exact
  • File 2, 35 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, mpmath), 2026-11-14; licence BSD-3-Clause
    • Tolerance as the file states it: factors and their geometric mean relative 1e-13 against the 50-digit reference; gene counts, gene lists, texts, 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

DESeq2 itself (LGPL, build-time only, not run here: R is not available); any minimum-gene threshold (none is applied); whether the supplied genes are representative.

Definition or model

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

Equations

s_j = median over genes i positive in every sample of k_ij / (prod over v of k_iv)^(1/m), the median of an even count the mean of the middle two log ratios
rescaled s_j = s_j / (prod over the m samples v of s_v)^(1/m)
order of checks: the kit's checks of each argument (each count at least 0 and at most 1e10, the tool's input bound shared with ngs_expression_normalise, else OUT_OF_RANGE), then DUPLICATE_NAME (genes, then samples), then MATRIX_ABOVE_CAP (samples × genes above 6,000 numeric cells), then per sample in order VALUES_MISALIGNED and, for read counts, NOT_AN_INTEGER, then CONFLICTING_ARGUMENT for a referenceSample, then NO_GENE_IN_EVERY_SAMPLE
Symbol Meaning and unit
s_j size factor of sample j
k_ij count of gene i in sample j
m number of samples

Source: Anders S, Huber W (2010), Differential expression analysis for sequence count data, Genome Biology 11:R106, doi 10.1186/gb-2010-11-10-r106, equation Eq. 5, 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 835f7de4e21a. Free to read (CC BY), checked 2026-11-11. No erratum found (searched Europe PMC correction list for doi 10.1186/gb-2010-11-10-r106), 2026-11-11.

Conventions

What each mode computes:

  • method = median-of-ratios: Anders and Huber's median of ratios: each sample's counts against the per-gene geometric mean across samples

Constants

Constants: none used.

Worked example

Worked example: one case of ngs-size-factors-mor@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

  • method = median-of-ratios
  • countKind = read-counts
  • genes[0] = geneA
  • genes[1] = geneB
  • genes[2] = geneC
  • samples[0].id = s1
  • samples[0].counts.values[0] = 10
  • samples[0].counts.values[1] = 20
  • samples[0].counts.values[2] = 40
  • samples[0].counts.unit = 1
  • samples[1].id = s2
  • samples[1].counts.values[0] = 20
  • samples[1].counts.values[1] = 40
  • samples[1].counts.values[2] = 80
  • samples[1].counts.unit = 1

Steps

  1. s1 = 0.70710678, from samples[0].counts, samples[1].counts; by the equation above; gives result.samples[0].sizeFactor.
  2. s2 = 1.4142136, from samples[0].counts, samples[1].counts; by the equation above; gives result.samples[1].sizeFactor.

The working, as the case writes it:

the pseudo-reference is sqrt(2) times sample 1 for every gene, so s1 = 1/sqrt 2 = 0.70710678118654752440 and s2 = sqrt 2 = 1.4142135623730950488

Answer

  • result.samples[0].sizeFactor = 0.70710678
  • result.samples[1].sizeFactor = 1.4142136

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: factors and their geometric mean relative 1e-13 against the 50-digit reference; gene counts, gene lists, texts, statuses and codes exact.

Who worked this case: not recorded.

What it refuses, and its input ranges

  • NO_GENE_IN_EVERY_SAMPLE: no gene is positive in every sample, so no ratio to a geometric mean exists Next: Send genes that are expressed in every sample, or drop the sample with no counts.
  • VALUES_MISALIGNED (invalid input): a sample's counts do not have one value per gene
  • MATRIX_ABOVE_CAP (invalid input): the counts are more numeric cells than the tool's cap; a smaller gene subset changes the factors

Changes

No correction is logged for ngs-size-factors-mor@1.0.1.

Tools that use it

Cite this version

Median-of-ratios size factor per sample. Drybench; ngs-size-factors-mor@1.0.1; https://www.drybench.com/methods/m/ngs-size-factors-mor/1.0.1 (accessed [date]).