Probability that profiled cells hold enough cells of a rare type, version 1.0.1
singlecell-sampling-probability@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
Its calculation passed Drybench's full check: source read, a separately written implementation, edge and refusal cases, and an outside comparison where one exists. It stays below the top level because no measured prediction error is available for the model.
Level: Calculation fully checked; model error not measured; Binomial sampling model; independent, unbiased capture assumed; no measured prediction error. Reference kind: a reference program this project wrote itself, mpmath (arithmetic: mpf powers and products), 1.3.0, direct summation of the binomial terms in mpmath 1.3.0 at 400 decimal digits; no special function; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13, mpmath), 2026-11-14, mpmath sums at 100 to 120 significant digits, rounded once to a double; not an outside program.
Tested 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 a separately written implementation within the stated tolerance; no measured prediction error is available for its model. 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: Calculation fully checked; model error not measured; Binomial sampling model; independent, unbiased capture assumed; no measured prediction error. Reference kind: a reference program this project wrote itself, mpmath (arithmetic: mpf powers and products), 1.3.0, direct summation of the binomial terms in mpmath 1.3.0 at 400 decimal digits; no special function; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13, mpmath), 2026-11-14, mpmath sums at 100 to 120 significant digits, rounded once to a double; not an outside program. singlecell-sampling-probability@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.
With every profiled cell an independent draw of the type at frequency f, the number of cells of the type among N is binomial, and the probability that a sample holds at least k of them is one minus the sum of the binomial probabilities of fewer than k: the source's cumulative negative binomial F_NB(N − k; k, f), the probability that the k-th cell of the type is drawn within N cells. For s samples profiled alike it is that probability to the power s. The smaller of the two sums is formed, so a small probability keeps its figures.
- How results are reported: none: full double precision
- Uncertainty: A sampling model with no measured prediction error: no read source compares the cells of a type recovered in an experiment with the number this model expects.
- Iterates: series, at most 1000000 iterations
- Reference, as its record states it: The binomial sum at 400 digits (mpmath arithmetic), checked against SciPy 1.17.0's negative binomial distribution function (fixture -1) and SciPy 1.18.1's binomial survival function (fixture -2, the raising run)
- Level confirmed by this project's ruling of 24 November 2026
What this page can and cannot show
What was checked
76 cases in 2 files, linked by this exact version.
Run through the tool at build against a reference program this project wrote itself, mpmath (arithmetic: mpf powers and products), 1.3.0, direct summation of the binomial terms in mpmath 1.3.0 at 400 decimal digits; no special function; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13, mpmath), 2026-11-14, mpmath sums at 100 to 120 significant digits, rounded once to a double; not an outside program: 57 agree within the tolerance the file states, 19 refuse as the case expects, 0 differ, 0 were not run.
File 1, 25 cases
- Where the expected values came from: an outside program, mpmath (arithmetic: mpf powers and products) 1.3.0
- Recorded on: 2026-11-12
- Reference: mpmath (arithmetic: mpf powers and products), 1.3.0; licence BSD-3-Clause
- Tolerance as the file states it: both probabilities relative 1e-9, with a floor of 1e-209 below 1e-200; statuses, codes and units exact
File 2, 51 cases
- Where the expected values came from: an outside program, second implementation (Python 3.13, mpmath) 2026-11-14
- 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: both probabilities relative 1e-9, with a floor of 1e-209 below 1e-200; statuses, codes and units 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
Whether cells are captured independently and without bias for the type; doublets, ambient RNA and quality-control loss; whether the frequency is the same in every sample; cells loaded against cells recovered; Abrams et al. 2019, which the source cites for the model and which does not print it; any measured comparison of recovered against expected cells.
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
P₁ = F_NB(N − k
k, f) = 1 − Σ_{i=0}^{k−1} C(N, i)·f^i·(1 − f)^(N − i)
formed as the smaller of its two sums: one minus the lower sum over i < k when k is at or below N·f, else the upper sum from i = k, which stops when the next term with the geometric bound on all that follow is below 2^−60 of the sum, or at i = N
order of checks: the kit's checks of each argument against the schema's range (counts at least 1 and at most 2^53 − 1, frequency above 0 and at most 1, else OUT_OF_RANGE), then the method's range (cells per sample at most 10^7, the fewest cells and the samples at most 10,000, else COUNT_ABOVE_RANGE), then RESULT_OUTSIDE_DOUBLE_RANGE
a frequency in % is divided by 100 and its range (0, 1] is tested on the converted double, not the stated decimal, so 100.00000000000001 % is accepted as 1
| Symbol | Meaning and unit |
|---|---|
| N | the number of cells profiled per sample: cells recovered after quality control, not cells loaded (argument cellsPerSample) |
| f | the frequency of the cell type among the profiled cells, a fraction above 0 and at most 1 (argument frequency) |
| k | the fewest cells of the type wanted in a sample (argument minimumCells) |
| C(N, i) | the binomial coefficient, the number of ways to choose i cells among N |
| F_NB | the cumulative negative binomial distribution, as the source writes the model: the probability of at most N − k cells of other types before the k-th cell of the type |
| P₁ | the probability that one sample holds at least k cells of the type, returned as probabilityPerSample; exactly 0 when k is above N |
Source: Schmid KT, Höllbacher B, Cruceanu C, Böttcher A, Lickert H, Binder EB, Theis FJ, Heinig M, scPower accelerates and optimizes the design of multi-sample single cell transcriptomic studies, Nat Commun 12:6625 (2021), section Methods, Frequency of the rarest cell type, version of record (Nature Communications) as deposited in PMC; Europe PMC's JATS XML, not the publisher's copy; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning b13358e0aa10. Free to read (CC BY 4.0), checked 2026-11-12. No erratum found (searched publisher, crossref, europe-pmc, retraction-watch), 2026-11-12.
Equation 2
P = P₁^s
| Symbol | Meaning and unit |
|---|---|
| P₁ | the probability for one sample |
| s | the number of samples, each profiled separately (argument samples) |
| P | the probability that every one of the s samples holds at least k cells of the type, returned as probabilityAllSamples |
Source: Schmid KT, Höllbacher B, Cruceanu C, Böttcher A, Lickert H, Binder EB, Theis FJ, Heinig M, scPower accelerates and optimizes the design of multi-sample single cell transcriptomic studies, Nat Commun 12:6625 (2021), section Methods, Frequency of the rarest cell type, version of record (Nature Communications) as deposited in PMC; Europe PMC's JATS XML, not the publisher's copy; read in full on 2026-11-12 by an AI-assisted session; not yet checked by a person. Read from the file itself, SHA-256 beginning b13358e0aa10. Free to read (CC BY 4.0), checked 2026-11-12. No erratum found (searched publisher, crossref, europe-pmc, retraction-watch), 2026-11-12.
Constants
Constants: none used.
Worked example
Worked example: one case of singlecell-sampling-probability@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
- cellsPerSample = 10
- frequency = 0.1
- minimumCells = 1
- samples = 3
Steps
- noneOfTheType = 0.34867844, from cellsPerSample, frequency; by equation 1.
- perSample = 0.65132156, from noneOfTheType; by equation 1; gives probabilityPerSample.
- allSamples = 0.27630349, from perSample, samples; by equation 2; gives probabilityAllSamples.
The working, as the case writes it:
with k = 1 the sum has one term, the probability that no cell is of the type: (1 − 0.1)^10 = 0.34867844
so one sample holds at least one with probability 1 − 0.34867844 = 0.65132156, and all 3 samples do with probability 0.65132156^3 = 0.27630349 (worked by hand by Drybench on 12 November 2026
not an independent check)
Answer
probabilityPerSample= 0.65132156probabilityAllSamples= 0.27630349
Where these values came from: an outside program, mpmath (arithmetic: mpf powers and products) 1.3.0; stored reference values (mpmath 1.3.0 arithmetic at 400 digits).
At build the tool returned this answer within the tolerance the file states: both probabilities relative 1e-9, with a floor of 1e-209 below 1e-200; statuses, codes and units exact.
Who worked this case: not recorded.
What it refuses, and its input ranges
COUNT_ABOVE_RANGE: the number of cells per sample, the fewest cells wanted or the number of samples is above the range the method was checked over Next: Give a count inside the method's range; where the counts are as intended, no change of input makes this computable by this method.RESULT_OUTSIDE_DOUBLE_RANGE: the model's probability for one sample, or for every sample, is above zero and below the smallest normal double Next: Check the frequency, its unit and the counts; where they are as intended, the probability is too small to state and no change of input makes this computable on these data.
Input ranges: cellsPerSample: at most 10000000; outside it, refused (COUNT_ABOVE_RANGE). minimumCells: at most 10000; outside it, refused (COUNT_ABOVE_RANGE). samples: at most 10000; outside it, refused (COUNT_ABOVE_RANGE).
Changes
No correction is logged for singlecell-sampling-probability@1.0.1.
Tools that use it
Cite this version
Probability that profiled cells hold enough cells of a rare type. Drybench; singlecell-sampling-probability@1.0.1; https://www.drybench.com/methods/m/singlecell-sampling-probability/1.0.1 (accessed [date]).