Tutorials › Multi-Omics Data Integration › Choosing Distances for Omics Profiles

Similarity Network Fusion and Kernel Methods · Tutorial 324 of 597

Choosing Distances for Omics Profiles

Learn to choose and interpret Euclidean, correlation, and Spearman distances for omics profiles, including how each choice affects patient similarities.

Advanced 10 min read

What You'll Learn

  • Define Euclidean, Pearson-correlation, and Spearman rank distances between patient profiles.
  • Explain how feature scaling changes Euclidean distances and resulting similarities.
  • Identify when correlation or rank-based distances are undefined or lose relevant information.
  • Convert distances to similarities and interpret the effect of the distance scale.
  • Diagnose ties, constant profiles, outlying features, and unstable distance patterns.
  • Compare the invariances and limitations of the three distance choices.

Why the Distance Choice Matters

A patient similarity network begins with a quantitative comparison between patients within an omics block. That comparison is not neutral: it encodes which differences count as important. Euclidean distance treats the size of feature-by-feature differences as meaningful. Correlation distance focuses on whether the profiles vary together across features. A rank-based distance focuses on the ordering of features within each profile. Consequently, the same pair of patients can be close under one choice and far apart under another.

Let \(x_i=(x_{i1},\ldots,x_{ip})\) and \(x_k=(x_{k1},\ldots,x_{kp})\) denote the profiles of patients \(i\) and \(k\) for the same \(p\) features in one omics block. A distance is a nonnegative measure of dissimilarity; smaller values indicate greater similarity. Before computing one, the features must be aligned across patients, and the profiles must have comparable, usable values for the features included. Missing values, incompatible measurements, and features with no variation require an explicit preprocessing decision rather than an improvised distance calculation.

Definition: The Euclidean distance between two patient profiles is \(d_E(i,k)=\sqrt{\sum_{j=1}^p(x_{ij}-x_{kj})^2}\). The Pearson-correlation distance is \(d_C(i,k)=1-r_{ik}\), where \(r_{ik}\) is the Pearson correlation between the two profiles across their \(p\) features. The Spearman rank distance is \(d_S(i,k)=1-\rho_{ik}\), where \(\rho_{ik}\) is the Pearson correlation between the profiles’ within-profile ranks. Correlation and rank distances require both vectors being correlated to be nonconstant.

What Each Distance Treats as Similar

Euclidean distance compares corresponding feature values directly. If one feature changes by 10 units and another by 1 unit, the first contributes 100 times as much to the squared distance, unless the features have been scaled. This is appropriate when differences in the measured units and magnitudes are substantively meaningful. In many omics blocks, however, features have different units or variability. A common response is to standardize each feature using a reference set of patients: subtract its reference mean and divide by its reference standard deviation. Euclidean distance is then calculated on the standardized values. A feature with zero reference standard deviation cannot be standardized this way and must be removed or handled by a prespecified alternative.

Pearson-correlation distance compares the pattern of values across features, not their overall level. For example, two profiles that differ by a positive shift and positive rescaling can have correlation 1 and distance 0, even though their Euclidean distance is positive. This can be useful when the shape of a patient’s profile matters more than its absolute scale. It can be misleading when overall abundance or intensity is biologically meaningful: patients with proportional profiles but substantially different levels may be treated as identical.

Spearman rank distance replaces the values in each profile by their ranks across features, then compares the two rank vectors. Tied values are assigned their average ranks. This approach emphasizes whether features are ordered similarly, while discarding the sizes of the gaps between values. It can be useful when relative ordering is more dependable than measurement scale, but it also discards magnitude information and can be sensitive to many ties. In particular, Spearman correlation is undefined if either profile’s rank vector is constant. A constant profile has all features tied and therefore has the same rank for every feature. Such a pair requires a prespecified handling rule or a different comparison; it must not be assigned a Spearman distance as though the correlation were defined.

From Distance to Within-Block Similarity

A distance is often converted into a nonnegative similarity, with larger values indicating more similar patients. One simple decreasing transformation is the Gaussian-shaped function \(w_{ik}=\exp\{-d(i,k)^2/(2\tau^2)\}\), where \(\tau>0\) is a scale parameter in the units of the chosen distance. This is an example of a distance-to-similarity mapping, not a claim that every transformed matrix has all the mathematical properties required of a kernel. The transformation preserves distance ordering: if \(d(i,k)<d(i,\ell)\), then \(w_{ik}>w_{i\ell}\). It does not make the numerical similarities comparable across distance choices or across different values of \(\tau\).

Euclidean distances have units inherited from the features, or no units after standardization; correlation and rank distances are dimensionless and lie between 0 and 2 when defined. Therefore the scale parameter must be chosen with the selected distance in mind. A large \(\tau\) makes similarities less sensitive to distance differences; a small \(\tau\) concentrates weight on the closest pairs. Even when two distance choices order patient pairs identically, their numerical values and resulting weights can differ substantially. For this reason, report both the distance definition and the scaling used to turn it into similarity.

Worked Example: Proportional Profiles

Suppose two hypothetical patients have profiles \(x=(1,2,3)\) and \(y=(2,4,6)\) for three aligned features. These values are illustrative. Their Euclidean distance is \(d_E=\sqrt{(1-2)^2+(2-4)^2+(3-6)^2}=\sqrt{1+4+9}=\sqrt{14}\approx3.742\).

The second profile is twice the first, so the Pearson correlation is \(r=1\), giving \(d_C=1-1=0\). Their rank vectors are both \((1,2,3)\), so \(\rho=1\) and \(d_S=0\). Thus, Euclidean distance detects their different magnitudes, whereas these correlation-based distances regard their across-feature patterns and orderings as identical.

For illustration, apply the same Gaussian-shaped mapping separately to each distance with \(\tau=2\). Euclidean similarity is \(\exp\{-14/(2\cdot 2^2)\}=\exp(-1.75)\approx0.1738\). The correlation and Spearman similarities are both \(\exp(0)=1\). The contrast is not evidence that one metric is universally better: it shows that the scientific meaning assigned to magnitude versus profile pattern changes the network weights.

A Useful Relationship and a Rank-Based Calculation

The correlation distance \(1-r\) is a dissimilarity, but it is not generally a metric: in particular, it does not generally satisfy the triangle inequality. Its relationship to a genuine Euclidean distance helps explain what it measures. Center each profile by subtracting its own mean across features, and divide by its Euclidean norm to obtain unit vectors \(u\) and \(v\). This requires each original profile to be nonconstant. Their inner product is the Pearson correlation \(r\). Expanding the squared distance between these normalized vectors gives the justification:

$$ \|u-v\|^2 = (u-v)^\mathsf{T}(u-v) = \|u\|^2+\|v\|^2-2u^\mathsf{T}v =2-2r =2(1-r). $$

Thus, \(\sqrt{2(1-r)}\) is the Euclidean distance between centered, unit-length profiles. The correlation dissimilarity \(1-r\) has the same ordering of pairs, but is half the squared chord distance and should not automatically be treated as a metric. This relationship also makes the invariance clear: centering removes a constant offset and normalization removes positive overall scale.

Worked Example: Profiles With a Rank Swap

Consider hypothetical profiles \(x=(1,2,3,4)\) and \(y=(1,3,2,4)\). The Euclidean distance is \(d_E=\sqrt{0^2+(-1)^2+1^2+0^2}=\sqrt{2}\approx1.414\). Their rank vectors are \(R_x=(1,2,3,4)\) and \(R_y=(1,3,2,4)\), with no ties. The rank differences are \(0,-1,1,0\), so the Spearman correlation is \(\rho=1-\frac{6(0^2+(-1)^2+1^2+0^2)}{4(4^2-1)}=1-\frac{12}{60}=0.8\).

Therefore the Spearman distance is \(d_S=1-0.8=0.2\). With the Gaussian-shaped mapping and \(\tau=1\), its similarity is \(\exp(-0.2^2/2)=\exp(-0.02)\approx0.9802\). This high value reflects that only two adjacent ranks switch places. It does not mean the profiles are identical in value: the Euclidean distance records the size of their value differences, while Spearman uses only the rank ordering.

Scaling, Diagnostics, and Failure Modes

For Euclidean distance, inspect feature scales and contributions to squared distance. A quick diagnostic is to identify which features contribute most to \((x_{ij}-x_{kj})^2\) across patient pairs. If a small number of high-variance or differently measured features dominate, decide whether that reflects scientific importance or a scale mismatch. Standardization can reduce scale dominance, but it also gives low-variance features influence comparable to high-variance ones; noisy, nearly constant features may then have disproportionate impact. Scaling should be chosen with the measurement process and scientific goal in view.

For correlation and Spearman distances, inspect profile variability, the number of features, ties, and the distribution of pairwise distances. A constant profile makes Pearson correlation undefined; for Spearman, constant or otherwise nonvarying ranks also make the correlation undefined. With few features, correlation estimates can take only a limited set of values and may be unstable. Many ties can make rank comparisons less informative. Extreme feature values can strongly affect Pearson correlation, whereas rank correlation reduces sensitivity to their magnitude but cannot correct a feature-alignment error or a misleading feature ordering.

A useful diagnostic is to compare pairwise distance rankings across plausible choices and to inspect representative pairs that change neighbors. If the resulting patient neighborhoods differ markedly, the network structure depends on a substantive modeling decision. This is not resolved by selecting a distance solely because it produces a visually appealing network. State the choice, its motivation, and any sensitivity of conclusions to reasonable alternatives.

ChoiceEmphasizesImportant limitation
EuclideanMagnitude of feature-by-feature differencesScale-sensitive; large-scale features can dominate
Pearson-correlation distanceLinear pattern across features, ignoring profile offset and positive scaleUndefined for constant profiles; may discard meaningful overall level
Spearman rank distanceSimilarity in feature orderingUndefined for constant rank vectors; discards gaps and can be weakened by ties

Choosing and Reporting a Distance

There is no universally preferred distance. Choose Euclidean distance when the magnitude of aligned feature differences is meaningful and scaling is defensible. Choose Pearson-correlation distance when similarity of linear profile shape is the target and overall offset or positive scale should not define dissimilarity. Choose Spearman distance when ordering is the target and a monotone change in values should leave the comparison unchanged. These are different definitions of patient similarity, not merely alternative computations of the same quantity.

Before constructing within-block similarities, verify that each profile comparison is defined, all patients use the same feature set, and any scaling was estimated and applied consistently. If a distance is undefined for some pairs, specify in advance whether to exclude affected patients, use an alternative comparison, or apply another explicit rule; silently replacing an undefined value with an arbitrary number changes the network. Also record the distance, feature scaling, tie handling, missing-data rule, and distance-to-similarity transformation. These choices determine what the block contributes to later network analysis.

Key takeaway: Euclidean, Pearson-correlation, and Spearman distances encode magnitude, profile pattern, and rank order, respectively. The resulting within-block similarities are meaningful only relative to that choice, its assumptions, and its scaling.

Check Your Understanding

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

  1. Two profiles are positive scalar multiples of one another. Which of the three distances must be zero, assuming both profiles are nonconstant?
  2. Why can standardizing every feature change Euclidean patient neighbors?
  3. A profile is constant across all features. Is its Spearman correlation with another profile defined? Give a defensible response in an analysis.
  4. For profiles \(x=(1,2,3)\) and \(y=(1,3,2)\), calculate the Euclidean distance and Spearman distance.
  5. Does applying a strictly decreasing distance-to-similarity transformation change which pair is closest? Does it make similarity values comparable across metrics?

Solutions. (1) Pearson-correlation and Spearman distances are zero: positive rescaling leaves the correlation and ranks unchanged. Euclidean distance is zero only if the profiles are equal, not merely proportional. (2) Standardization changes the relative contribution of feature differences to the sum of squared differences, so pairwise distance orderings can change. (3) No. Its rank vector is constant, so the correlation is undefined. Specify a handling rule in advance or use another comparison; do not silently assign a correlation value. (4) The Euclidean distance is \(\sqrt{0^2+(-1)^2+1^2}=\sqrt{2}\approx1.414\). The rank vectors are \((1,2,3)\) and \((1,3,2)\), giving \(\rho=1-6(2)/(3(3^2-1))=0.5\), so \(d_S=0.5\). (5) A strictly decreasing transformation reverses distance order, so the smallest distance becomes the largest similarity and the closest pair remains closest. It does not make similarity values comparable across metrics or scale parameters.

Clinical Biostats