Tutorials › Statistical Methods for Single-Cell RNA Sequencing › Fuzzy Simplicial Sets in UMAP

Dimension Reduction and Embeddings · Tutorial 217 of 700

Fuzzy Simplicial Sets in UMAP

Learn how UMAP converts locally scaled neighbor distances into directed memberships and combines them into a symmetric fuzzy graph.

Intermediate 10 min read

What You'll Learn

  • Define a fuzzy simplicial set and interpret its edge memberships.
  • Calculate directed UMAP neighbor strengths from distances, local offsets, and adaptive scales.
  • Explain how local connectivity changes the distance threshold for full membership.
  • Combine reciprocal directed strengths using fuzzy union and verify its bounds and monotonicity.
  • Diagnose ties, scale-fitting problems, and the limits of interpreting graph weights.

From Neighbor Distances to Fuzzy Memberships

A nearest-neighbor graph records which cells are near one another, but a binary edge does not distinguish a barely included neighbor from a very close one. UMAP instead assigns graded strengths to directed neighbor relationships, adapts the distance scale to each cell, and then combines the two directions of each pair. The result is a fuzzy representation of local relationships, not a set of statistically estimated probabilities.

The construction begins with a directed \(k\)-nearest-neighbor list. For cell \(i\), let \(N_k(i)\) be the cells in its list and let \(d_{ij}\) be the chosen input-space distance from \(i\) to neighbor \(j\). The distance is generally not symmetric in the neighbor lists: \(j\) can be among \(i\)'s nearest neighbors without \(i\) being among \(j\)'s. Each cell receives its own offset \(\rho_i\) and scale \(\sigma_i\), so the same distance can yield different directed strengths from different cells.

Definition: A fuzzy set assigns each object a membership value in \([0,1]\), rather than only classifying it as present or absent. In UMAP, the directed local fuzzy set at cell \(i\) assigns each neighbor \(j\) a membership strength \(w_{i\to j}=\exp\left(-\max(0,d_{ij}-\rho_i)/\sigma_i\right)\). Here \(\rho_i\) is a local-connectivity offset and \(\sigma_i>0\) is a cell-specific distance scale. The undirected edge strength is formed by combining the directed strengths for the pair.

The maximum in the formula makes every neighbor at distance no greater than \(\rho_i\) have membership 1. Beyond that offset, membership decreases exponentially with distance, with the rate of decrease determined by \(\sigma_i\). A larger \(\sigma_i\) makes weights decline more gradually; a smaller one makes them decline more sharply.

The offset \(\rho_i\) represents a local distance floor: it ensures that the closest neighbor or neighbors receive full membership despite differences in local density. In a common setting with local connectivity equal to 1, \(\rho_i\) is based on the distance to the nearest nonzero-distance neighbor. More general local-connectivity settings can place the offset farther into the ordered neighbor distances, with interpolation when needed. Implementations also need conventions for duplicate points and zero distances. Thus, \(\rho_i\) is not simply a universal distance threshold shared by all cells.

After choosing the offset, UMAP selects \(\sigma_i\) by a numerical smoothing procedure. In the standard formulation, the target is to make the sum of directed memberships over the \(k\) neighbors approximately \(\log_2(k)\):

$$ \sum_{j\in N_k(i)} \exp\left(-\frac{\max(0,d_{ij}-\rho_i)}{\sigma_i}\right) \approx \log_2(k). $$

This target gives each local neighborhood a comparable aggregate membership while allowing its distance scale to adapt. It is a construction rule, not a claim that every cell has exactly \(\log_2(k)\) neighbors in a probabilistic sense. Numerical implementations solve to a tolerance and may use bounds or special handling for ties. If several neighbors lie at or inside \(\rho_i\), they each contribute 1, which can make exact matching to the target impossible; practical handling of such cases matters.

Worked Example: Computing One Cell’s Directed Memberships

Suppose a hypothetical cell \(A\) has \(k=3\) neighbors at distances 1, 2, and 3 in arbitrary distance units. Let \(\rho_A=1\). For this illustration, find a scale \(\sigma_A\) that makes the membership sum equal to \(\log_2(3)\).

The neighbor at distance 1 has membership 1. Write \(x=\exp(-1/\sigma_A)\). The memberships at distances 2 and 3 are \(x\) and \(x^2\), respectively. Since \(\log_2(3)\approx1.585\), the scale equation is \(1+x+x^2=1.585\), or \(x^2+x-0.585=0\).

The positive solution is \(x=(-1+\sqrt{1+4(0.585)})/2\approx0.4138\). Therefore, \(\sigma_A=-1/\ln(0.4138)\approx1.133\) distance units. The three directed memberships are approximately \(1\), \(0.4138\), and \(0.1712\); their sum is \(1.585\), up to rounding.

These values describe \(A\)'s directed view of its neighbors only. They do not yet say what the final undirected edge weights will be, because each neighbor can assign a different membership back to \(A\).

Combining the Two Directions

For a pair of cells \(i\) and \(j\), write \(a=w_{i\to j}\) and \(b=w_{j\to i}\). UMAP combines them using the fuzzy union:

$$ w_{ij}=a+b-ab=1-(1-a)(1-b). $$

This is the probabilistic-sum fuzzy union, also called the algebraic sum. The complement form shows its logic: the combined membership is one minus the product of the two non-memberships. This is an algebraic rule for fuzzy memberships; it does not assert that the two directions are independent random events. The resulting weight is symmetric in \(i\) and \(j\), even when the directed values differ.

Worked Example: Fuzzy Union for a Reciprocal Pair

Suppose cell \(A\) assigns membership \(a=0.60\) to cell \(B\), while \(B\) assigns \(b=0.30\) to \(A\). The fuzzy-union weight is \(w_{AB}=0.60+0.30-(0.60)(0.30)=0.90-0.18=0.72\).

The symmetric edge therefore has weight 0.72. It is larger than either directed input because both values are positive and less than 1. If instead \(b=0\), the union is \(a+0-a(0)=a\), so a missing reverse membership does not erase the observed direction. If \(a=1\) and \(b=0.30\), the union is \(1+0.30-(1)(0.30)=1\), not a value above 1.

The union rule has useful bounds and monotonicity properties. For \(a,b\in[0,1]\), its membership is at least each input because \(w_{ij}-a=b(1-a)\geq0\) and \(w_{ij}-b=a(1-b)\geq0\). It is at most 1 because \(w_{ij}=1-(1-a)(1-b)\leq1\), and it is nonnegative because both inputs are nonnegative. Thus \(w_{ij}\in[0,1]\).

It is also nondecreasing in each directed strength. Holding \(b\) fixed and increasing \(a\) to \(a'\geq a\), the change in the union is \(w(a',b)-w(a,b)=(a'-a)(1-b)\geq0\). Holding \(a\) fixed and increasing \(b\) to \(b'\geq b\), the change is \(w(a,b')-w(a,b)=(b'-b)(1-a)\geq0\). If both inputs are positive and both are less than 1, then \(w_{ij}-a=b(1-a)>0\) and \(w_{ij}-b=a(1-b)>0\), so the union is strictly greater than either input. If either input is 1, the union is 1.

Worked Example: Symmetrizing a Small Directed Graph

Consider three hypothetical cells, \(A\), \(B\), and \(C\). Suppose their directed memberships are \(w_{A\to B}=0.60\), \(w_{B\to A}=0.30\), \(w_{B\to C}=0.50\), \(w_{C\to B}=0\), \(w_{A\to C}=0.20\), and \(w_{C\to A}=0.40\). Compute each undirected edge strength.

For \(A\) and \(B\), the union is \(0.60+0.30-(0.60)(0.30)=0.72\). For \(B\) and \(C\), it is \(0.50+0-(0.50)(0)=0.50\). For \(A\) and \(C\), it is \(0.20+0.40-(0.20)(0.40)=0.52\). The resulting undirected weights are \(w_{AB}=0.72\), \(w_{BC}=0.50\), and \(w_{AC}=0.52\).

The direction \(C\to B\) contributes nothing, but \(B\to C\) preserves an edge of weight 0.50. The resulting graph represents the union of the local fuzzy relationships; it does not mean that all three pairs were mutual nearest neighbors.

Why This Construction Matters—and Where It Can Fail

Local offsets and scales let the graph represent neighborhood relationships across regions with different distance densities. Without a local offset, the nearest relationship might receive a small membership in a sparse region simply because all distances there are large. Without a cell-specific scale, a single exponential decay could make dense neighborhoods overly connected or sparse neighborhoods too weak. Fuzzy union then preserves one-sided neighbor evidence while strengthening a pair supported in both directions.

A useful diagnostic is to inspect the directed memberships, \(\rho_i\), and \(\sigma_i\) for a sample of cells, especially when the resulting graph looks unexpectedly dense, weak, or uneven. Extremely small scales can make most memberships beyond \(\rho_i\) nearly zero; very large scales can leave many neighbors with substantial weights. Many tied distances or duplicate cells can yield multiple memberships of 1 and complicate the scale target. These patterns may reflect the data, but can also point to a distance choice, preprocessing issue, or numerical edge case that deserves checking.

The fuzzy union is one of several possible symmetrizations. Keeping only directed edges retains asymmetry but does not produce the undirected fuzzy graph used in the standard construction. Adding reciprocal weights can exceed 1, and clipping the sum at 1 behaves differently from fuzzy union. Taking the arithmetic mean keeps weights bounded but can reduce a strong one-sided relationship. A fuzzy intersection, often represented by the product \(ab\), emphasizes reciprocal support; for \(a,b\in[0,1]\), it is no greater than either input and is strictly smaller than both when \(a,b\in(0,1)\). These alternatives encode different choices; they are not interchangeable versions of the same rule.

The edge weights summarize the constructed neighborhood structure. They are not p-values, probabilities that two cells belong to the same biological population, or direct measures of gene-expression difference. The graph also depends on the input representation, distance metric, neighbor count, local-connectivity setting, and numerical implementation. A fuzzy edge can retain local evidence without guaranteeing that the chosen neighbors are biologically meaningful. The construction defines the input relationships to a later embedding stage; it does not by itself explain or validate the resulting coordinates.

Key takeaway: UMAP converts each cell’s neighbor distances to directed memberships using a local offset and adaptive scale, then combines reciprocal memberships as \(a+b-ab\). The union stays between 0 and 1, is nondecreasing in either input, preserves one-sided edges, and reaches 1 if either directed membership is 1.

Check Your Understanding

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

  1. If a directed neighbor has distance \(d_{ij}\leq\rho_i\), what is its membership, and why?
  2. For \(a=0.4\) and \(b=0.5\), calculate the fuzzy-union weight. Is it greater than both inputs?
  3. Suppose \(a\) increases to \(a'\geq a\) while \(b\) is fixed. Show why the union cannot decrease.
  4. Why can a pair have a positive undirected edge when only one direction has positive membership?
  5. What is one reason that the scale-fitting target may not be matched exactly?

Solutions. (1) Its membership is 1, since \(\max(0,d_{ij}-\rho_i)=0\) and \(\exp(0)=1\). (2) The union is \(0.4+0.5-(0.4)(0.5)=0.70\), which exceeds both inputs. (3) The change is \((a'-a)(1-b)\geq0\), since \(a'\geq a\) and \(b\leq1\). (4) If \(b=0\), then \(a+b-ab=a\), so the positive direction is retained. (5) Ties or multiple neighbors at or inside \(\rho_i\) can contribute several memberships of 1, potentially making their sum already greater than the target; implementations also solve numerically to a tolerance.

Clinical Biostats