8.3 Measuring Similarity: A Mathematical Definition of Biological Behavior
8.3 Measuring Similarity: A Mathematical Definition of Biological Behavior
Section titled “8.3 Measuring Similarity: A Mathematical Definition of Biological Behavior”Learning Goals
Section titled “Learning Goals”After completing this section, you should be able to:
- Explain why similarity must be defined mathematically.
- Distinguish between distance measures and similarity measures.
- Calculate and interpret the Euclidean and Manhattan distances.
- Describe the mathematical properties of a metric.
- Explain why different similarity measures emphasize different biological relationships.
Once biological objects have been represented as feature vectors, the central question of clustering can finally be addressed:
How similar are two biological objects?
Although this question appears intuitive, it has no unique answer. Two genes may be considered similar because they have nearly identical expression levels, because they respond similarly to environmental changes, or because they follow the same temporal dynamics despite different absolute expression values.
Before any clustering algorithm can be applied, similarity must therefore be translated into a mathematical quantity.
This step is far more than a technical necessity—it represents another important modeling decision. The mathematical definition of similarity determines which biological relationships become visible to the algorithm and which remain hidden.
Distance and Similarity
Section titled “Distance and Similarity”There are two complementary ways to quantify the relationship between biological objects.
The first approach measures similarity directly. Large values indicate that two objects resemble each other closely, while small values indicate little similarity.
The second approach measures distance. Here, the interpretation is reversed: objects are considered similar if the distance between them is small.
Although both approaches describe the same underlying concept, clustering algorithms are traditionally formulated in terms of distances. Throughout this chapter, we will therefore focus on distance measures.
Conceptually, the idea is simple.
If two genes exhibit nearly identical expression profiles, their feature vectors should lie close together in feature space. Conversely, genes with very different biological behavior should be located farther apart.
The challenge lies in defining what “close together” actually means.
Euclidean Distance
Section titled “Euclidean Distance”The most familiar distance measure is the Euclidean distance.
It corresponds to the ordinary straight-line distance between two points in geometry. If each gene is represented as a point in feature space, the Euclidean distance simply measures the shortest path connecting them.
For two feature vectors
and
the Euclidean distance is defined as
Although the equation may initially appear intimidating, each component has a clear interpretation.
First, the difference between the two expression values is calculated for every experimental condition. These differences are squared to ensure that positive and negative deviations do not cancel each other and to give greater weight to large discrepancies. Finally, all squared differences are summed, and the square root converts the result back to the original measurement scale.
The Euclidean distance therefore summarizes the overall numerical difference between two expression profiles.
Genes with very similar expression values across all experimental conditions have a small Euclidean distance, whereas genes with markedly different profiles are separated by a larger distance.
Manhattan Distance
Section titled “Manhattan Distance”An alternative and frequently used measure is the Manhattan distance.
Instead of measuring the shortest straight-line distance, the Manhattan distance sums the absolute differences along each individual dimension:
The name originates from the rectangular street grid of Manhattan. A pedestrian cannot walk directly through buildings but must follow the streets, accumulating the distance traveled along each block.
Applied to biological data, the Manhattan distance measures the total amount of difference between two feature vectors without emphasizing particularly large deviations as strongly as the Euclidean distance.
Consequently, it is often more robust to individual outliers or unusually large measurement errors.
Choosing an Appropriate Distance Measure
Section titled “Choosing an Appropriate Distance Measure”Neither the Euclidean nor the Manhattan distance is universally superior.
Each emphasizes different aspects of biological variation.
The Euclidean distance strongly penalizes large differences because these are squared before being summed. It is therefore particularly sensitive to genes that differ substantially under one or a few experimental conditions.
The Manhattan distance treats all deviations linearly. A single large difference contributes proportionally rather than quadratically, making this measure generally less sensitive to extreme observations.
The choice between these distances should therefore be guided by the biological question.
If large expression changes are expected to reflect important biological events, the Euclidean distance may be appropriate. If the goal is to compare overall behavior while reducing the influence of individual outliers, the Manhattan distance may provide a more robust alternative.
Once again, we encounter a recurring principle of computational biology:
The mathematical model determines which biological patterns become visible.
What Makes a Valid Distance Measure?
Section titled “What Makes a Valid Distance Measure?”Although many different distance measures have been proposed, not every numerical function qualifies as a proper distance.
To behave consistently, a distance measure should satisfy four fundamental mathematical properties.
Non-negativity
Distances can never be negative.
Identity
The distance between an object and itself must always be zero.
Symmetry
The order of comparison must not matter.
Triangle Inequality
The direct distance between two objects should never exceed the distance obtained by traveling through a third object.
Together, these four properties define what mathematicians call a metric.
Metrics provide a consistent geometric framework in which distances behave exactly as we intuitively expect. Many clustering algorithms rely on these properties to ensure stable and interpretable results.
Similarity Is a Modeling Choice
Section titled “Similarity Is a Modeling Choice”At this point, it may seem that defining similarity is simply a matter of selecting an appropriate formula.
In reality, the decision is much more profound.
Every distance measure encodes a particular assumption about what constitutes biological similarity.
Should genes with nearly identical expression levels be grouped together?
Or should genes be considered similar whenever they exhibit the same response pattern, regardless of their absolute expression values?
Both interpretations are biologically meaningful, yet they require different mathematical definitions.
This observation leads to one of the central ideas of this book:
Similarity is not measured—it is modeled.
The mathematical definition of similarity represents a scientific hypothesis about which aspects of biological behavior are most relevant for the question under investigation.
Only after this modeling decision has been made can clustering algorithms begin to identify groups of related biological objects.
Conceptual Summary
Section titled “Conceptual Summary”- Clustering requires a mathematical definition of similarity.
- Most clustering algorithms quantify similarity through distance measures.
- Euclidean distance measures straight-line differences in feature space.
- Manhattan distance sums absolute differences across all features.
- Different distance measures emphasize different biological properties.
- A valid distance metric satisfies non-negativity, identity, symmetry, and the triangle inequality.
- Choosing a distance measure is a modeling decision that shapes the biological interpretation of clustering.
Self-Check Questions
Section titled “Self-Check Questions”- Why must similarity be defined mathematically before clustering can be performed?
- What is the conceptual difference between a similarity measure and a distance measure?
- How do the Euclidean and Manhattan distances differ in their treatment of large deviations?
- What mathematical properties define a valid distance metric?
- Why can choosing a distance measure influence the biological conclusions drawn from a clustering analysis?