Skip to content

Cells to profile per sample to find enough of a rare cell type

singlecell_cells_required

Works out the fewest cells to profile per sample for every sample to hold k cells of a rare type, binomially.

Runs
On the server
Level
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. Calculation fully checked; model error not measured
Ask your assistant

What it is

Returns the fewest cells to profile per sample for every sample to hold k cells of a rare type, by a binomial model. Use when planning a single-cell experiment from a type's frequency, the cells wanted and a target probability you state. Not for the probability at a fixed cell number: use `singlecell_sampling_probability`; not for clones of a pooled library: use `screen_library_coverage`; not for a test's sample size: use `stats_power_sample_size`. Cells are those recovered after quality control, not loaded; targets outside 0.5 to 0.999999 are refused.

Field: Cell culture, microbiology, virology.

What it does

You give

  • frequency (required): The frequency of the cell type among profiled cells, as a fraction (1) or in %, above 0 and at most 1. Never assumed. Must be above 0 and at most 1.
  • minimumCells (required): The fewest cells of the type wanted in each sample. Never assumed. At most 10,000. Must be at least 1 and at most 9007199254740991.
  • samples (required): The number of samples, each profiled separately; 1 for a single sample. Never assumed. At most 10,000. Must be at least 1 and at most 9007199254740991.
  • targetProbability (required): The probability, as a fraction (1) or in %, with which every sample is to hold the cells wanted, from 0.5 to 0.999999. Never assumed. Must be above 0 and below 1.

No request is recorded for this tool.

Limits

  • Research arithmetic for planning single-cell experiments on values you supply; probabilities come from a stated sampling model, and no cell number or target is chosen for you.
  • Each recovered cell is taken as an independent draw at the frequency you state, the same in every sample.
  • Capture bias, doublets, quality-control loss and differences between samples are not modelled.
  • A model's probability, not a forecast.
  • Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.

It will not answer when

  • the number of cells per sample, the fewest cells wanted or the number of samples is above the range the method was checked over.
  • the target probability is outside the range in which the comparison with the model's probability was checked.
  • no number of cells per sample within the method's range reaches the target.
Every input, with its units4 inputs
  • frequency (required): The frequency of the cell type among profiled cells, as a fraction (1) or in %, above 0 and at most 1. Never assumed. Must be above 0 and at most 1.
  • minimumCells (required): The fewest cells of the type wanted in each sample. Never assumed. At most 10,000. Must be at least 1 and at most 9007199254740991.
  • samples (required): The number of samples, each profiled separately; 1 for a single sample. Never assumed. At most 10,000. Must be at least 1 and at most 9007199254740991.
  • targetProbability (required): The probability, as a fraction (1) or in %, with which every sample is to hold the cells wanted, from 0.5 to 0.999999. Never assumed. Must be above 0 and below 1.
Every refusal, with its code3 refusals
CodeWhen
COUNT_ABOVE_RANGEthe number of cells per sample, the fewest cells wanted or the number of samples is above the range the method was checked over.
TARGET_OUTSIDE_RANGEthe target probability is outside the range in which the comparison with the model's probability was checked.
TARGET_NOT_REACHEDno number of cells per sample within the method's range reaches the target.

The calculation

The method's equations, constants and worked example.

Cells to profile per sample so that every sample holds enough cells of a rare typesinglecell-cells-required@1.0.2

N* = min { N : P(N) ≥ p }, with P(N) = (F_NB(N − k

k,f))^s

the search runs from N = k to N = 10,000,000 cells per sample (the method's largest N) by at most 24 halvings (2^24 is above 10^7)

TARGET_NOT_REACHED when P(10^7) is below p

the target p is in [0.5, 0.999999], both ends inside, tested on the converted double

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

order of checks: the kit's checks of each argument, then the method's ranges in the order minimumCells, samples (COUNT_ABOVE_RANGE), targetProbability (TARGET_OUTSIDE_RANGE), then the search

SymbolMeaning
fthe frequency of the cell type among the profiled cells, a fraction above 0 and at most 1 (argument frequency)
kthe fewest cells of the type wanted in a sample (argument minimumCells)
sthe number of samples, each profiled separately (argument samples)
pthe target probability that every sample holds at least k cells of the type (argument targetProbability)
P(N)the model's probability at N cells per sample, by singlecell-sampling-probability; returned at N* as probabilityAllSamples, with the one-sample value as probabilityPerSample
N*the smallest number of cells per sample reaching the target, returned as cellsPerSample; s·N* is returned as totalCells

Source 1.

A model of nature: it predicts a measurement and can be wrong for your sample. No prediction error is available.

Worked example

Worked example: one case of singlecell-cells-required@1.0.2, 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

  • frequency = 0.5
  • minimumCells = 1
  • samples = 1
  • targetProbability = 0.9

Steps

  1. oneFewer = 0.875, from frequency, minimumCells, samples; by the equation above.
  2. perSample = 0.9375, from frequency, minimumCells, samples; by the equation above; gives probabilityPerSample.
  3. allSamples = 0.9375, from perSample, samples; by the equation above; gives probabilityAllSamples.
  4. cells = 4, from oneFewer, allSamples, targetProbability; by the equation above; gives cellsPerSample.
  5. total = 4, from cells, samples; by the equation above; gives totalCells.

The working, as the case writes it:

with k = 1 and one sample, P(N) = 1 − (1 − 0.5)^N: P(3) = 0.875, below the target 0.9, and P(4) = 0.9375, at or above it, so N* = 4 and the total is 4 cells (worked by hand by Drybench on 12 November 2026

not an independent check)

Answer

probabilityPerSample = 0.9375

probabilityAllSamples = 0.9375

cellsPerSample = 4

totalCells = 4

Where these values came from: an outside program, mpmath (arithmetic: mpf powers and products) 1.3.0; stored reference values (an integer search over mpmath 1.3.0 arithmetic at 400 digits).

At build the tool returned this answer within the tolerance the file states: the two probabilities relative 1e-9, with a floor of 1e-209 below 1e-200; the cells per sample, the total cells, statuses, codes and units exact.

Sources

  1. 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)

    Used for: Cells to profile per sample so that every sample holds enough cells of a rare type. At: section Results, Power analysis framework for scRNA-seq experimental design; Methods, Frequency of the rarest cell type.

    Read in full, 12 November 2026

How it is checked

Level

Calculation fully checked; model error not measured.

Checked 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; the search compares at that precision; not an outside program; a reference program this project wrote itself, second implementation (Python 3.13, mpmath), 2026-11-14, mpmath sums at 60 significant digits, rounded once to a double; the search compares at that precision; not an outside program; values written by our own engine, the record's stated order of checks (1.0.2), worked by hand; the second implementation (Python 3.13, mpmath) as cross-check, 2026-11-24: a regression check, not a reference.

Cases

No case set is linked to this version.

Not checked

Everything singlecell-sampling-probability leaves unchecked; the cells to load, which need a recovery fraction the method does not take; a target within rounding of a probability the model attains, where the count returned can differ by one: the engine's probability is within one part in ten thousand million of the model's at the targets the method takes, and the cases keep their targets clear of that.

Changes to its methods0 changes

No change is logged for these method versions.