Why Repeated Runs Can Differ
A community-detection result is often treated as if it were a single, inevitable summary of a cell-neighborhood graph. For a randomized algorithm, that can be misleading: even when the graph and analysis settings are held fixed, different runs may return different assignments of cells to communities. This is algorithmic variability. It is not, by itself, evidence that the graph changed or that the cell data were resampled.
Randomized community-detection methods use random choices during their search. Those choices can affect which candidate assignments are considered and the path taken through possible partitions. Because methods such as Louvain and Leiden use heuristic optimization, a run may stop at a locally strong solution rather than establish that one uniquely best partition exists. Distinct partitions can also have equal or nearly equal objective scores. The important diagnostic question is therefore not merely whether the score changes, but whether the cell groupings change and how those changes relate to score differences.
A partition groups vertices into non-overlapping communities. Community labels themselves are arbitrary: the assignments \((1,1,2,2)\) and \((7,7,3,3)\) describe the same partition. Comparisons should therefore be based on which vertices are grouped together, not on the numerical names assigned to communities.
Separate Partitions From Objective Scores
An objective score summarizes a partition according to a specified criterion. For example, modularity evaluates how much more edge weight falls within communities than would be expected under its degree-based null model. For an undirected graph with nonnegative edge weights \(A_{ij}\), define \(k_i=\sum_j A_{ij}\) and \(m=\frac{1}{2}\sum_{i,j}A_{ij}\). A partition \(P\), with community label \(c_i\) for vertex \(i\), has resolution-\(\gamma\) modularity
where \(I(c_i=c_j)\) equals 1 when vertices \(i\) and \(j\) are in the same community and 0 otherwise. This expression is given here to make clear what a score comparison means; the earlier material on modularity develops the objective itself. A score is interpretable only in relation to its objective, graph, and settings. Scores from different objectives, different graphs, or different resolution parameters should not be treated as if they were on one directly comparable scale.
Repeated runs can show substantial partition variation but almost identical scores. This happens when distinct partitions are nearly tied under the chosen objective. The reverse pattern is also possible: most assignments may be similar, while a few changes involving high-weight edges noticeably change the score. Thus, report evidence about both the partitions and the objective values.
Worked Example: Summarizing Scores Across Ten Runs
Suppose a hypothetical undirected cell graph is analyzed ten times with the same modularity objective and settings. Six runs return partition A with score 0.421, three return partition B with score 0.420, and one returns partition C with score 0.397. These values are dimensionless.
The observed frequency of partition A is \(6/10=0.600\); the frequency of B is \(3/10=0.300\), and that of C is \(1/10=0.100\). The mean score across runs, weighting each run equally, is
The observed score range is \(0.421-0.397=0.024\). Partitions A and B are both frequent and have close scores, whereas C is less frequent and has the lowest score in this set. These results describe these ten runs; they do not establish that A is the uniquely correct biological partition. To interpret the score pattern, one must also compare the cell assignments, not just rank the scores.
Comparing Assignments Without Depending on Labels
One direct summary of repeated assignments is the co-assignment proportion. For two vertices \(i\) and \(j\), it is the fraction of runs in which they share a community. It is 1 if they are grouped together in every run and 0 if they are separated in every run. Intermediate proportions identify pairs whose relationship varies across runs. This summary does not require community labels to match between runs.
For \(R\) runs, let \(I_r(i,j)\) equal 1 if \(i\) and \(j\) are assigned to the same community in run \(r\), and 0 otherwise. Their empirical co-assignment proportion is
A collection of these proportions forms a co-assignment matrix. It can reveal stable blocks of cells and uncertain boundaries. It is a descriptive summary of the runs, not a guarantee that the groups with high co-assignment are biologically meaningful.
Worked Example: Finding Which Cell Relationships Vary
Consider three hypothetical runs on a graph with six cells \(a,b,c,d,e,f\). Runs 1 and 3 return \(\{a,b,c\}\) and \(\{d,e,f\}\). Run 2 returns \(\{a,b\}\) and \(\{c,d,e,f\}\). Suppose their objective scores are, respectively, 0.412, 0.411, and 0.412.
Cells \(a\) and \(b\) are together in all three runs, so \(\widehat{C}_{ab}=3/3=1\). Cells \(d\) and \(e\) are also together in all runs, so \(\widehat{C}_{de}=1\). Cells \(a\) and \(c\) are together in runs 1 and 3 but separated in run 2, giving \(\widehat{C}_{ac}=2/3\approx0.667\). Cells \(c\) and \(d\) are separated in runs 1 and 3, and together in run 2, giving \(\widehat{C}_{cd}=1/3\approx0.333\).
The scores range from 0.411 to 0.412, a difference of 0.001, even though the relationship of \(c\) to the other cells changes. The near-equal scores indicate that these runs found similarly scoring solutions under the objective, not that every cell assignment is stable. In this small example, inspecting co-assignment proportions points directly to the uncertain boundary.
What Repeated Runs Estimate
The repeated-run summaries describe a conditional distribution: the distribution of outputs produced by the selected algorithm and settings on the fixed graph. They do not measure all uncertainty in a single-cell analysis. In particular, they do not include changes that might arise from a different graph, a different set of cells, or a different analysis configuration.
If repeated runs are independent and use the same graph and settings, the frequency of a particular partition estimates its probability of appearing in a run under that procedure. To see why, define \(Z_r=1\) if run \(r\) returns that partition and \(Z_r=0\) otherwise. If its run probability is \(\pi\), then \(Z_r\) is a Bernoulli random variable with mean \(\pi\) and variance \(\pi(1-\pi)\). The observed frequency is \(\hat{\pi}=R^{-1}\sum_r Z_r\). Independence gives
Thus, the frequency is an estimate, not a known long-run probability, and a small number of runs can give an unstable estimate. This reasoning applies to the frequency of an exactly specified partition; it does not say that different partitions are equally important or that run frequency is a measure of biological plausibility.
Worked Example: Interpreting a Partition Frequency
In a hypothetical set of 20 independent runs with fixed settings, one partition appears 15 times. Its observed frequency is \(15/20=0.750\). Under the same-run-probability model, the estimated standard error of this frequency is
The frequency of 0.750 means that this partition appeared in 15 of these 20 runs. The estimated standard error indicates that the frequency estimate is imprecise with only 20 runs. It is not the probability that the partition is biologically correct. The calculation also relies on the runs being independent and identically configured; if run outputs are dependent or settings differ, this standard-error interpretation need not hold.
A Practical Diagnostic Workflow
A useful repeated-run comparison keeps the graph, objective, algorithm, and all other analysis settings fixed. Otherwise, observed differences mix algorithmic variability with changes in the analysis. Record each run's partition and objective score, then inspect the frequency of recurring partitions, score summaries, and co-assignment patterns. When many distinct partitions occur, exact partition frequencies may be less informative than pairwise co-assignment, since a small local change can create a new complete partition.
Use the same graph and the same algorithmic objective and settings for every run. State any settings that define the score, such as the modularity resolution parameter.
Report the mean and spread, such as the range or sample standard deviation, while retaining the individual scores when useful. A mean alone can hide a small number of unusually low or high values.
Count recurring partitions when that is practical, and calculate co-assignment proportions for cell pairs or groups of interest. Ignore arbitrary differences in community labels.
Near-equal scores with changing assignments suggest objective ties or near-ties. Larger score differences together with changing assignments indicate that some runs found less favorable solutions under the chosen objective, but do not by themselves identify the scientifically preferred partition.
Assumptions, Comparisons, and Failure Modes
The interpretation above depends on a controlled comparison. Runs must use the same graph and settings for their differences to be attributed to the randomized procedure. If a graph is directed, weighted, or processed differently between runs, the objective and its interpretation must match those features. If the graph or objective changes, score variation no longer isolates run-to-run stochasticity.
A single run is cheaper and may be adequate when the procedure is known to be reproducible for the task, but it cannot reveal output variation. Repeated runs expose that variation, at additional computational cost. Choosing the run with the largest objective score is a different strategy: it selects the best observed score among the runs, but does not show that the selected partition is unique, stable, or biologically valid. A deterministic method can avoid variation conditional on fixed inputs, but determinism alone does not establish that its result is better.
Repeated runs also differ from comparing different algorithms. For example, Louvain and Leiden need not optimize or implement precisely the same procedure; comparing their outputs changes more than the random run. And a score from one objective should not be used to declare a partition from another objective superior. Objective scores answer a criterion-specific question, not a general question of biological truth.
- Do not equate a high score with stable assignments. Several partitions can have similar objective values while assigning boundary cells differently.
- Do not equate repeated agreement with validity. An algorithm can consistently return a partition that is poorly matched to the scientific question.
- Do not compare incompatible scores. Graph, objective, resolution, and other score-defining settings must be aligned for a direct score comparison.
- Do not overinterpret small run counts. Observed frequencies and score summaries can change materially when only a few runs are performed.
The main limitation is scope: repeated runs assess variability of the algorithm conditional on the graph and settings. They do not assess sensitivity to graph construction, cell sampling, or biological interpretation. Those are distinct questions. The practical conclusion should therefore be calibrated: describe what was stable across the runs, where assignments varied, and whether that variation coincided with changes in the objective score.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- Why can two partitions with almost equal modularity scores still indicate meaningful run-to-run variation?
- Across 12 runs, cells \(u\) and \(v\) are assigned to the same community in 9 runs. What is their empirical co-assignment proportion, and what does it mean?
- One partition appears in 8 of 10 runs. Does this show that it is biologically correct? Explain.
- Why is it not a fair direct comparison to rank modularity scores computed on different graphs or at different resolution parameters?
Solutions. (1) The objective can assign nearly equal scores to different groupings, so similar scores do not imply identical cell assignments; inspect co-assignment or partition frequencies. (2) The proportion is \(9/12=0.750\). In these runs, \(u\) and \(v\) were grouped together 75.0% of the time; this is a conditional empirical summary, not a biological probability. (3) No. The frequency describes how often the partition appeared under the specified procedure and settings, not whether it is biologically correct. (4) Changing the graph or resolution changes the score's basis or criterion, so the numerical values do not represent a like-for-like comparison.