Tutorials › Statistical Methods for Single-Cell RNA Sequencing › The Resolution Limit of Modularity

Graph-Based Clustering · Tutorial 252 of 700

The Resolution Limit of Modularity

Learn why modularity can merge well-defined small groups in a large graph, and calculate when that preference arises.

Intermediate 11 min read

What You'll Learn

  • Write the modularity change caused by merging two communities.
  • Derive the merge threshold for neighboring groups in a ring.
  • Calculate how the number of groups and resolution parameter affect the threshold.
  • Distinguish a modularity preference from a guarantee about an algorithm’s output.
  • Identify diagnostics and limitations associated with the resolution limit.

Why Modularity Has a Resolution Limit

In a cell-neighborhood graph, a community might represent cells connected more densely to one another than to the rest of the graph. Modularity evaluates that pattern against a global degree-based null model. Because the comparison uses the total graph size, the score change from merging two groups depends not only on their local connection but also on the scale of the whole graph. As a result, modularity can favor joining small, internally dense groups even when they have only a single edge between them.

This behavior is called the resolution limit. It is a property of the modularity objective, not a claim that every community-detection algorithm must return the same merged partition. The distinction matters: a partition may score worse than a simple merge under modularity even if a particular optimization run does not find that merge.

The Modularity Change From a Merge

For an undirected, unweighted graph with \(m\) edges, let \(l_C\) be the number of edges within community \(C\), and let \(d_C\) be the sum of the degrees of its vertices. Using resolution parameter \(\gamma\), write modularity as follows. The usual modularity objective corresponds to \(\gamma=1\).

$$ Q_\gamma=\sum_C\left[\frac{l_C}{m}-\gamma\left(\frac{d_C}{2m}\right)^2\right]. $$

Suppose communities \(A\) and \(B\) have \(e_{AB}\) edges between them. Merging them adds those edges to the within-community edge count. Their combined degree is \(d_A+d_B\). The contributions of all other communities stay unchanged, so the change in modularity is

$$ \begin{aligned} \Delta Q_\gamma &=Q_\gamma(\text{merged})-Q_\gamma(\text{separate})\\ &=\frac{e_{AB}}{m} -\gamma\frac{(d_A+d_B)^2-d_A^2-d_B^2}{4m^2}\\ &=\frac{e_{AB}}{m}-\gamma\frac{d_A d_B}{2m^2}. \end{aligned} $$
Result: Given a fixed partition and an undirected graph, merging \(A\) and \(B\) increases modularity exactly when \(\Delta Q_\gamma>0\), or equivalently when \(e_{AB}>\gamma d_A d_B/(2m)\). Equality means the merge leaves the objective unchanged.

The first term rewards edges that become internal to the merged community. The second is the increase in the degree-based null-model penalty. Since \(m\) appears in that penalty, a larger graph can make the same local connection more favorable to a merge. This global dependence is the basis of the resolution-limit intuition.

A Ring of Small Dense Groups

Consider a ring of \(g\) groups. Each group has \(l\) internal edges, and there is exactly one edge between each pair of consecutive groups, with no other between-group edges. The graph is simple and undirected, and \(g\geq3\). There are \(g\) between-group edges in the ring, so the total number of edges is \(m=g(l+1)\). Each group has two incident between-group edges, giving it total degree \(d=2l+2\).

For neighboring groups, \(e_{AB}=1\) and \(d_A=d_B=d\). Substituting these values into the merge rule gives

$$ \Delta Q_\gamma =\frac{1}{g(l+1)} -\gamma\frac{[2(l+1)]^2}{2[g(l+1)]^2} =\frac{g-2\gamma(l+1)}{g^2(l+1)}. $$

Thus merging a neighboring pair improves modularity when \(g>2\gamma(l+1)\). For fixed group size and resolution parameter, adding more groups can eventually make that merge favorable. The groups have not changed locally: each still has the same internal edges and just one connection to each neighbor. What changed is the scale of the whole graph.

Worked Example: Twelve Triangles in a Ring

Suppose a hypothetical graph consists of \(g=12\) triangles arranged in a ring, with one edge between each neighboring pair. Each triangle has \(l=3\) internal edges and two incident between-group edges, so its total degree is \(d=2(3)+2=8\). The graph has \(m=12(3+1)=48\) edges. At \(\gamma=1\), compare leaving two neighboring triangles separate with merging them.

There is one edge between the triangles. Therefore,

$$ \begin{aligned} \Delta Q_1 &=\frac{e_{AB}}{m}-\frac{d_A d_B}{2m^2}\\ &=\frac{1}{48}-\frac{8\cdot8}{2(48)^2}\\ &=\frac{1}{48}-\frac{64}{4608}\\ &=\frac{1}{48}-\frac{1}{72} =\frac{1}{144}\approx 0.006944. \end{aligned} $$

The positive change means this particular merge raises modularity by about \(0.006944\). In particular, the partition that keeps all twelve triangles separate cannot be a global maximum of \(Q_1\): a partition formed by merging any one neighboring pair has a higher score. This does not show that the merged pair is the scientifically correct grouping; it describes the objective’s preference.

Worked Example: Finding the Ring Threshold

For triangles, \(l=3\), so \(m=4g\) and each group has degree \(8\). The merge change simplifies to

$$ \Delta Q_\gamma =\frac{1}{4g}-\gamma\frac{64}{2(4g)^2} =\frac{g-8\gamma}{4g^2}. $$

At \(\gamma=1\) and \(g=8\), the numerator is zero, so merging a neighboring pair changes modularity by exactly zero. At \(g=9\),

$$ \Delta Q_1=\frac{9-8}{4(9)^2}=\frac{1}{324}\approx 0.003086. $$

The merge now improves the score. At \(g=6\), the change is \(\Delta Q_1=(6-8)/[4(6)^2]=-2/144\approx-0.01389\), so this particular merge lowers the score. These calculations locate the boundary for this specific ring construction; they do not imply a universal minimum number of groups for every graph.

Worked Example: Unequal Community Degrees

In a different hypothetical undirected graph, suppose \(m=60\), two communities have degrees \(d_A=8\) and \(d_B=14\), and there is one edge between them. At \(\gamma=1\), use the merge rule directly:

$$ \begin{aligned} \Delta Q_1 &=\frac{1}{60}-\frac{8\cdot14}{2(60)^2}\\ &=\frac{120}{7200}-\frac{112}{7200} =\frac{8}{7200} =\frac{1}{900}\approx0.001111. \end{aligned} $$

The score increases slightly if these communities are merged. Their unequal degrees matter: the null-model penalty depends on the product \(d_A d_B\), not simply on the number of edges between them. A single connecting edge can therefore have different implications for pairs of communities with different degrees and in graphs with different total edge counts.

What the Resolution Parameter Changes

In the ring calculation, increasing \(\gamma\) increases the penalty associated with the degree-based null model. For triangles, the condition for a favorable neighboring-pair merge is \(g>8\gamma\). In a ring of twelve triangles, for example, \(\gamma=2\) gives

$$ \Delta Q_2=\frac{12-16}{4(12)^2} =-\frac{4}{576}\approx-0.006944. $$

For this pair and this partition, that merge lowers modularity at \(\gamma=2\), unlike at \(\gamma=1\). Changing \(\gamma\) changes the objective and its preferred scale; it does not repair an objective-independent defect or prove that either partition corresponds to biological cell types. The introductory material on the resolution parameter gives its general role; here the merge calculation shows how it enters this particular limit.

Assumptions, Diagnostics, and Limitations

The ring derivation assumes an undirected, unweighted graph with the specified number of internal and between-group edges, and compares two partitions that differ only by merging one neighboring pair. The merge formula itself applies to an undirected graph with a fixed partition when \(m\), the two community degrees, and their between-community edge count are defined consistently. For a weighted graph, edge counts must be replaced by the corresponding edge-weight totals and \(m\) by the total edge weight; the ring formulas above should not be reused without recalculating those quantities.

A useful diagnostic is to inspect communities that have few edges between them but whose degrees are small relative to the whole graph. Calculate \(\Delta Q_\gamma\) for plausible neighboring merges, or examine whether a modest change in graph size or \(\gamma\) changes the score comparison. Such checks identify a possible scale effect; they are not by themselves proof that a detected community is an artifact.

  • Do not confuse a favorable merge with an algorithmic guarantee. The calculation compares objective values for two specified partitions. A heuristic optimizer may fail to find the higher-scoring one.
  • Do not infer biology from the sign alone. Positive \(\Delta Q_\gamma\) says which of these two partitions scores higher under the chosen objective, not whether two cell groups have the same biological identity.
  • Check the graph construction and units of the calculation. A changed edge definition, weighting scheme, or total edge weight changes the quantities in the merge rule.

One alternative is to vary \(\gamma\) and report how the partition changes, making the scale dependence visible rather than treating one setting as definitive. Another is to assess partitions using information not contained in the modularity objective, such as relevant marker expression or independent biological annotations. These comparisons can provide context, but neither removes the need to state what graph and clustering objective were used. No resolution setting can establish a uniquely correct biological partition from graph structure alone.

Key takeaway: Modularity compares between-community edges with a degree-based penalty scaled by the whole graph. In the ring example, that dependence means that sufficiently many small dense groups make merging neighbors score better, even though each group’s local structure is unchanged.

Check Your Understanding

Use the merge rule to answer each question. Solutions follow so that the arithmetic and interpretation can be checked.

  1. Two communities have degrees \(d_A=10\) and \(d_B=12\), one edge between them, and the graph has \(m=100\) edges. At \(\gamma=1\), calculate \(\Delta Q_\gamma\) and state whether the merge improves modularity.
  2. For a ring of groups with \(l=4\) internal edges each, what condition on \(g\) makes a neighboring merge favorable at \(\gamma=1\)?
  3. For a ring of triangles with \(g=10\), calculate the merge change at \(\gamma=1\). Interpret its sign.
  4. True or false: if the merge change is positive, every community-detection algorithm must return the merged partition. Explain.

Solutions. (1) \(\Delta Q_1=1/100-(10\cdot12)/[2(100)^2]=0.01000-0.006000=0.004000\). The positive value means this merge increases modularity. (2) The ring condition is \(g>2\gamma(l+1)\). With \(l=4\) and \(\gamma=1\), the condition is \(g>10\); at \(g=10\), the merge is neutral. (3) For triangles, \(\Delta Q_1=(g-8)/(4g^2)\), so at \(g=10\) it is \(2/400=0.005000\), a positive score change. (4) False. The calculation establishes an objective preference between two specified partitions, not a guarantee that an algorithm’s optimization procedure will find the higher-scoring partition.

Clinical Biostats