Why Seed Management Belongs in the Workflow
Subsampling cells, initializing an embedding, and fitting some statistical models can involve random-number generation. That randomness may be part of the method: for example, a procedure may randomly select observations or use random initial values during optimization. If the seed setting is implicit or lost, it can be difficult to connect an output to the particular stochastic choices made during a run.
A seed is therefore a workflow parameter, not merely a line of code added just before analysis. Its value should be recorded with the settings that determine what the stochastic step did: the input and its identity, the method, relevant arguments, and the software context. The goal here is to make seed choices explicit and traceable, not to claim that one seed is statistically preferable or that a seed alone makes every computation reproducible.
A seed is not the random sequence itself, and it is not a parameter of the biological model. It is a setting for the computational process that supplies random values. In a single-cell workflow, record it at the level of each stochastic step rather than treating “the analysis seed” as a complete description of all randomness in a multi-stage pipeline.
What to Record for Each Stochastic Step
A useful record ties each seed to a named stage and to the parameters that define that stage. At minimum, identify the input, operation, seed, and settings that affect the operation. Include the output location or identifier so that the record can be connected to the artifact produced.
- Stage identity: a stable name such as cell_subsample or umap_initialization, rather than an ambiguous label such as “random step.”
- Input identity: a file name plus a checksum, or another stable identifier for the input object. A seed cannot identify which count matrix or filtered cell set was used.
- Seed setting: the actual value, its type if relevant, and which generator or software interface received it.
- Stage parameters: for subsampling, such as the target number of cells and sampling scheme; for an embedding, such as the method, dimensions, and initialization options.
- Execution context: software and version, and the code or configuration version that defines the call.
- Output identity: a saved artifact path, name, or checksum, so the record points to the result associated with these settings.
These fields are useful together. A record containing only a seed does not say whether it was used for cell selection, model initialization, or an embedding. Conversely, a record of the algorithm and its parameters without the seed omits a setting that may have influenced the realized output. Keeping both in one run record makes their relationship explicit.
Worked Example: Recording a Cell Subsample
Suppose a hypothetical analysis has 12,000 eligible cells and selects 2,000 without replacement for a visualization. The analyst uses a specified software function with seed 4817. In this hypothetical run, the function returns a selected set of 2,000 cell identifiers.
The selection fraction is \(2000/12000=1/6\), or about 16.67% of the eligible cells. That calculation describes the scale of the subsample; it does not determine which cells are selected. The selected identifiers are the realized output of the stochastic step.
A useful record might contain: stage cell_subsample; input identifier and checksum for the eligible-cell object; method “simple random sample without replacement”; target size 2,000; seed 4817; function and software version; configuration or code revision; and the path or identifier for the saved list of selected cell IDs.
The seed and sampling settings answer different questions. The target size and sampling scheme define what selection procedure was requested. The seed identifies the initialization used by the generator for this run. Saving the selected IDs as an output artifact also makes it possible to inspect the actual selection rather than inferring it from the seed record alone.
Assign Seeds by Stage and Preserve Them With Parameters
A multi-stage workflow can have several stochastic operations. Assigning a named setting to each stage makes the run easier to audit and rerun deliberately. For example, a configuration could hold one value for cell subsampling and another for embedding initialization. These values should be passed to the corresponding calls explicitly and written to the run record along with the parameters for those calls.
Distinct seed values are convenient for keeping stage settings separate, but they should not be described as a proof that the generated sequences are statistically independent. The purpose of stage-specific values here is traceability: a record makes clear which value was intended for which operation. If a stage is rerun with different parameters, update or create a run record that preserves the new combination rather than overwriting the old record.
Worked Example: Two Stochastic Stages in One Run
Consider a hypothetical workflow with two stages. The first selects 2,000 cells from a fixed eligible-cell object without replacement, using seed 4817. The second computes a two-dimensional embedding of the selected cells, using seed 9032, with 15 nearest neighbors and a specified embedding implementation. Assume that each software call accepts and uses the seed setting shown.
The run configuration can represent these as separate parameter groups:
The first record is linked to the eligible-cell input and the selected cell IDs. The second is linked to the selected-cell input and the embedding output. This ordering matters: the embedding is computed on the selected cells, so its input identity should refer to that selection, not just to the original count matrix.
If the analyst changes the target size from 2,000 to 1,500, that is a changed subsampling parameter even if seed 4817 is retained. The new run record should therefore capture both the retained seed value and the new target size. Recording only “seed 4817” would not distinguish these two analyses.
A Short Justification for Explicit Seed Records
The connection between a seed and a realized sequence can be understood through a simple state-transition description. Let \(S_0\) be the generator state initialized from a seed, and let \(F\) be the generator’s state-update rule. At step \(t\), write the state as \(S_t\) and the generated value as \(R_t=G(S_t)\), where \(G\) maps state to output.
For a fixed generator, suppose two runs start with the same state \(S_0\) and apply the same operations in the same order. Their states agree initially. If their states agree at step \(t\), applying the same function \(F\) gives equal states at step \(t+1\), and applying the same function \(G\) gives equal outputs at step \(t\). By induction, their generated sequences agree for as many steps as those conditions continue to hold.
This justification explains why seed settings belong beside the operation and its parameters: the seed initializes a process, while the operation determines how generated values are consumed. A seed record preserves the settings that describe that process. The argument does not establish that the same seed, by itself, makes all runs identical across different software or execution contexts.
Mark each operation that uses random-number generation, such as sampling, random initialization, or a stochastic fitting procedure.
Store a seed value for each stage in the run configuration and pass it to the intended software call.
Record the input identity, method, arguments, software context, and code or configuration version alongside the seed.
Save output identifiers and, where useful, realized selections or other stage outputs so that each record can be checked against the artifact it describes.
Diagnostics, Pitfalls, and Alternatives
A seed-management check asks whether the run record is sufficiently specific to identify what the seed controlled. It is not a test of the biological validity of an embedding or the statistical quality of a subsample. Useful checks include confirming that every documented stochastic stage has an explicit seed field, that the field is passed to the corresponding call, and that the saved record agrees with the actual stage parameters and inputs.
Common warning signs include a single undocumented seed set at the beginning of a long script, a configuration that has a seed field but never passes it to the relevant function, or a record that names a seed but not the stage. Another warning sign is reusing a run identifier after changing a seed or a stage parameter: the record then no longer uniquely describes the execution that produced the output.
Why this is wrong: the seed alone does not identify the input, the stochastic stage, its parameters, or the software call that used it.
Correction: save the seed in a stage-specific run record alongside the relevant input identity, method, parameters, software context, and output identity.
For some workflows, an alternative is to preserve the realized stochastic output, such as a selected-cell list or an initialized object, rather than relying only on regenerating it from a seed. This can be valuable when the realized choice itself must be inspected or reused. It complements a seed record: the record explains the settings, while the saved artifact preserves what the stage actually produced. A further alternative is to store both, which supports both traceability and direct reuse.
Seed management has limits. It cannot establish that a sampling design is appropriate, that a model is well specified, or that an embedding represents biological structure. Nor does documenting a seed replace recording inputs and software context. Treat seeds as one part of the run’s provenance, together with configuration, code, input identity, and outputs.
Worked Example: Finding an Incomplete Run Record
A hypothetical run log says: “Seed 2026; embedding completed.” The analyst also has a configuration stating that the intended embedding used two dimensions and 20 neighbors, but the log does not name the input object, implementation, software version, or output artifact.
The log is insufficient to connect the seed to a specific analysis. It does not establish which operation received 2026, whether the intended configuration was used, or which embedding was produced. The configuration supplies two parameters, but it does not fill in those missing links.
A corrected record would identify the embedding stage, identify the selected-cell input, state the method and its implementation, record seed 2026 together with two dimensions and 20 neighbors, include the relevant software and configuration or code version, and point to the saved embedding output. If the input selection was itself stochastic, its own stage record would also be needed to trace the embedding’s input.
The correction does not change the analysis result; it improves the account of how that result was generated. If the missing context cannot be recovered, the record should state what is unknown rather than filling gaps with assumptions.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A workflow randomly selects 800 cells from a larger set, then computes an embedding. Why should the selection and embedding have separate stage records?
- A run record contains a seed but no input identifier or target subsample size. Name two important pieces of context that are missing.
- An analyst changes the embedding from two dimensions to three but keeps the same seed. What should change in the run record?
- What does the state-transition argument establish about a fixed seed under the same generator and operation sequence?
- Why might saving the selected cell IDs be useful in addition to recording the seed?
Solutions. (1) They are distinct stochastic operations with different inputs and parameters; separate records show which seed and settings belong to each, and link each output to the next stage. (2) The input identity and the target size are missing; the stage method, software context, and output identity are also useful. (3) Record the three-dimensional setting in a new or updated run record linked to the relevant input and output; retaining the same seed does not make the changed parameter disappear. (4) Given the same generator, initial state, and same sequence of operations, the deterministic state updates produce the same generated sequence for the corresponding steps. (5) The selected IDs preserve the realized selection directly, allowing inspection or reuse without having to infer the selection from the seed record.