Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Graph Connectivity Within Cell Types

Integration Methods and Their Benchmarking · Tutorial 193 of 700

Graph Connectivity Within Cell Types

You will construct and summarize within-cell-type neighbor graphs, calculate connectivity scores, and use component composition and biological evidence to investigate disconnections.

Advanced 10 min read

What You'll Learn

  • Define a within-cell-type k-nearest-neighbor graph and its largest-component connectivity score.
  • Calculate type-specific scores and an equal-weight summary across eligible cell types.
  • Examine whether the largest component includes cells from each represented batch.
  • Distinguish a pattern consistent with residual batch structure from one consistent with biological substructure.
  • Recognize how graph construction, cell-type labels, and the choice of k affect interpretation.
  • Compare graph connectivity with batch-mixing and biological-conservation summaries.

What Graph Connectivity Measures

An integration can place cells of the same annotated type near one another overall while leaving some batches in separate graph components. Graph connectivity makes this aspect of integration visible: within each cell type, it asks what fraction of cells belongs to the largest connected component of a neighbor graph. A low value signals that the graph is fragmented, but does not by itself identify why. A split aligned with batch is consistent with residual batch structure; a split aligned with a biological state represented across batches may instead reflect genuine heterogeneity within the broad cell type.

The graph is built using an integrated representation, such as a set of integrated coordinates, and cell-type labels assigned independently of the graph where possible. Choose a representation appropriate for local distances; a two-dimensional visualization is generally not a suitable default, since its distortions can change nearest neighbors. Fix the distance metric, the number of neighbors \(k\), and the symmetrization rule before comparing methods. The resulting score is conditional on these choices.

Definition: For cell type \(c\), let \(V_c\) be its \(N_c\) cells. Construct a \(k\)-nearest-neighbor graph among those cells using distances in the chosen integrated representation. An undirected union graph places an edge between two cells if either is among the other's \(k\) nearest neighbors. Let \(L_c\) be the number of vertices in the graph's largest connected component. The cell-type-specific graph connectivity score is \(GC_c=L_c/N_c\), which lies between 0 and 1. A singleton component counts as a connected component of size 1.

The graph is restricted to a cell type before its connected components are found. Thus, a connection between two different annotated types cannot raise either type's score. The basic score does not use batch labels: labels are used afterward to interpret which cells occupy each component. In the common summary, first define eligible types as those represented in at least two batches, then take an unweighted mean, \(GC_{\mathrm{macro}}=C^{-1}\sum_{c=1}^{C}GC_c\), where \(C\) is the number of eligible types. This gives each eligible type equal weight. Report the individual scores and cell counts as well, since a macro-average can hide a poorly connected rare type.

Assumptions and a Useful Interpretation

This is a descriptive graph statistic, not a hypothesis test. It has no null distribution or p-value unless a separate inferential procedure is specified. Its interpretation depends on several practical conditions:

  • The cell-type labels identify comparable populations across batches. If a label merges distinct states, the graph may be measuring both integration and within-type biological heterogeneity.
  • The chosen representation and distance metric preserve the local relationships relevant to the question. A graph on uncorrected expression may retain batch structure; an aggressively corrected representation may remove meaningful differences.
  • The value of \(k\) and symmetrization rule are fixed and reported. Small \(k\) can leave sparse, fragmented graphs; large \(k\) can create long-range bridges between otherwise separate groups.
  • Types used for cross-batch assessment occur in more than one batch. A type found in only one batch provides no evidence about whether that type aligns across batches.

The score has a narrow interpretation: \(GC_c\) is the observed fraction of type-\(c\) cells in its largest connected component under the specified graph construction. It is not the fraction of cells correctly integrated, nor the probability that a randomly selected pair is connected. In particular, a high score can occur when a small disconnected group is biologically important, while a low score can occur when a broad cell type contains real, separated states.

Worked Example: Calculating Connectivity for One Cell Type

Suppose a hypothetical integrated dataset contains 12 cells of type A: 4 from batch 1 and 8 from batch 2. For a fixed \(k\) and union symmetrization rule, the within-type graph has components of sizes 8 and 4. The size-8 component contains 4 cells from each batch; the size-4 component contains 4 cells from batch 2.

The largest component has size \(L_A=8\), so \(GC_A=L_A/N_A=8/12=0.6667\). Thus, two-thirds of these type-A cells are in the largest connected component. This does not mean two-thirds of cells are free of batch effects; it describes graph membership only.

Checking the batch composition adds important context. The largest component contains all 4 batch-1 cells, so its batch-1 coverage is \(4/4=1\). It contains 4 of the 8 batch-2 cells, so its batch-2 coverage is \(4/8=0.5\). The component includes both batches, but half of batch 2 lies outside it. The overall score alone would not reveal this imbalance.

Derivation and Aggregation

The connectivity fraction follows directly from the quantity the metric is intended to summarize: the number of cells connected to the largest connected set, divided by the number of cells considered. To see its scale, if every cell of a type lies in one component, then \(L_c=N_c\) and \(GC_c=N_c/N_c=1\). If the type is divided into components with sizes \(m_1,\ldots,m_J\), where \(\sum_{j=1}^{J}m_j=N_c\), then \(L_c=\max_j m_j\), giving \(GC_c=\max_j(m_j)/\sum_{j=1}^{J}m_j\). Because no component can contain more than all \(N_c\) cells, \(0<GC_c\leq1\) for a nonempty type. A lower value means a smaller fraction is connected to the largest set; it does not specify the number or cause of the remaining components.

For an equal-weight summary, suppose eligible types have scores \(g_1,\ldots,g_C\). Then the mean is \(\sum_c g_c/C\), so a rare type and a common type contribute equally. A cell-weighted alternative is \(\sum_c N_cg_c/\sum_c N_c\); it answers a different question by giving larger types more influence. State which summary is used, and do not present the two as interchangeable.

Worked Example: Comparing Cell Types and Summaries

In a hypothetical dataset, eligible type X has 10 cells, split into components of sizes 9 and 1. Type Y has 12 cells, split into two components of size 6. Assume both types are represented in at least two batches.

For X, \(GC_X=9/10=0.9000\). For Y, \(GC_Y=6/12=0.5000\). The equal-weight summary is \((0.9000+0.5000)/2=0.7000\).

If instead the types are weighted by cell count, the summary is \((10(0.9000)+12(0.5000))/(10+12)=(9+6)/22=0.6818\). Both calculations are correct for their stated weighting rules, but answer different questions. Reporting only the macro-average of 0.7000 would conceal that type Y is substantially more fragmented than type X.

Diagnosing Disconnected Components

To investigate a low score, inspect component membership alongside batch, sample, and biological-state annotations. For each component, report its size and the number of cells from each batch; also report, for each batch represented in a type, what fraction of that batch's cells lies in the largest component. These summaries identify whether fragmentation tracks batch, but are descriptive evidence rather than proof of cause.

A component that contains nearly all cells from one batch and few or none from other batches is consistent with residual batch-associated separation. Check whether the pattern is repeated across biological replicates, and whether known biological states or marker patterns provide an alternative explanation. If each component contains cells from several batches but corresponds to a distinct state, the split is less readily explained by batch alone. Conversely, when state and batch are confounded—for example, a state occurs in only one batch—the graph cannot distinguish a biological difference from a batch effect using connectivity alone.

A useful diagnostic is to compare the component pattern across reasonable graph choices, especially nearby values of \(k\). If a small change in \(k\) turns several components into one, the score is sensitive to graph construction; inspect the edges that create the bridge rather than treating the new score as decisive. Also check for very small components, uneven cell counts, uncertain labels, and types present in only one batch. Cell-level resampling should not be treated as independent biological replication: if uncertainty is needed, resample at the sample or replicate level when the study design permits it.

Worked Example: Two Causes With the Same Connectivity Score

Consider a hypothetical broad cell type with 12 cells, forming two disconnected components of 6 cells each. In both scenarios below, \(GC=6/12=0.5000\). The score alone cannot distinguish the scenarios.

Scenario 1: batch-aligned components. The first component contains 6 cells from batch A and the second contains 6 from batch B. If the type is otherwise expected to be comparable and the pattern recurs across samples, this is consistent with residual batch separation. It is not conclusive if batch and biological state are confounded.

Scenario 2: state-aligned components. Each component contains 3 cells from batch A and 3 from batch B, and the components correspond to two independently supported biological states. Both batches are represented in both components, so the disconnection is more consistent with separation by state than with separation by batch. It may still indicate that the broad label combines populations that should be examined separately.

The arithmetic is identical in both cases; interpretation changes because component composition and external biological evidence differ. A connectivity score should therefore be reported with these diagnostics, not as a standalone verdict about integration quality.

Comparison, Limitations, and Common Mistakes

Batch-mixing summaries ask whether batches are interspersed in a neighborhood or representation; graph connectivity instead asks whether cells of a given type belong to one large connected set. The measures are related but not equivalent. A graph can be connected through a narrow chain of cross-batch edges while batches remain locally segregated. Conversely, multiple components can each contain several batches. Biological-conservation summaries address whether biological distinctions are retained, a different target again. Use these measures together as complementary evidence, rather than assuming any one score diagnoses both batch removal and biology preservation.

The main limitations follow from the construction. Connectivity depends on \(k\), the distance metric, the integrated representation, and the cell-type annotation. A large \(k\) can artificially join groups; a small \(k\) can fragment a continuous population. The largest-component fraction ignores the sizes and arrangement of all but the largest component except insofar as they reduce its fraction. It is also sensitive to unequal sampling: a rare batch or state can form a small component without determining the main pattern. The statistic is descriptive and does not establish that integration caused a change in connectivity.

  • Mistake: “The score is low, so the integration failed to remove batch effects.” Correction: Low connectivity means the specified within-type graph is fragmented. Check whether components align with batch, biological state, or graph choices before attributing the split.
  • Mistake: “The score is high, so batches are well mixed everywhere.” Correction: One large connected component can contain a path between groups without good local mixing. Inspect batch composition within components and use an appropriate batch-mixing summary as a complement.
  • Mistake: Including a type found in only one batch as evidence of cross-batch connectivity. Correction: Report that type separately; cross-batch alignment cannot be assessed for it.
Key takeaway: Calculate connectivity within each cell type from a specified neighbor graph, report the largest-component fraction and component composition, and interpret fragmentation using batch structure, biological evidence, and sensitivity to graph construction. The score describes connectivity; it does not identify its cause.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A type has 15 cells in components of sizes 11, 3, and 1. Calculate its graph connectivity score and state what it means.
  2. Two eligible types have scores 0.8 and 0.4. What is their equal-weight summary? Why might it differ from a cell-weighted summary?
  3. A low-scoring type has one component almost entirely from batch A and another almost entirely from batch B. What conclusion is justified, and what additional evidence should be checked?
  4. Why can increasing \(k\) raise connectivity without demonstrating that the integration improved?

Solutions. 1. \(GC=11/15=0.7333\). About 73.3% of the type's cells lie in its largest component under the specified graph; this does not identify the reason for the other components. 2. The equal-weight summary is \((0.8+0.4)/2=0.6000\). A cell-weighted summary gives greater influence to the type with more cells, so it can differ if the type sizes are unequal. 3. The pattern is consistent with batch-associated separation, but is not proof of a residual batch effect. Check replicate patterns, state annotations, markers, possible batch-state confounding, and graph sensitivity. 4. Larger \(k\) adds more neighbor relationships and may create bridging edges that merge components. The score can rise because the graph definition changed, not because the integrated representation improved.

Clinical Biostats