From 167d7155b0f1c598361b98b3d3b343637d07807b Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sat, 12 Sep 2026 19:02:19 +0200 Subject: [PATCH] Introduce k-mer based distances (Hamming and Mash). Defines the Hamming distance based on k-mer presence/absence vectors and introduces the Mash distance, noting it is an evolutionary estimator rather than a metric. --- theory-phylogeny-kmer_based-kmer_set_distances.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/theory-phylogeny-kmer_based-kmer_set_distances.md b/theory-phylogeny-kmer_based-kmer_set_distances.md index f04be62..c23caf4 100644 --- a/theory-phylogeny-kmer_based-kmer_set_distances.md +++ b/theory-phylogeny-kmer_based-kmer_set_distances.md @@ -28,7 +28,7 @@ $$D = \sum_i \mathbb{1}[a_i \ne b_i],$$ where (a\_i,b\_i\\in{0,1}) indicate the presence of k-mer (i) in the two genomes. It counts the number of k-mers for which the two incidence vectors differ, without normalization by the size of the k-mer space. As an (L^1) distance, Hamming distance is a metric. Unlike abundance-based measures, it cannot be recovered from k-mer counts alone once the presence/absence representation has been discarded. -**Mash** is not an independent set dissimilarity but a nonlinear transformation of the Jaccard similarity. If +**Mash** is not an independent set dissimilarity but a nonlinear transformation of the Jaccard similarity ([Ondov et al. 2016](#ref-Ondov2016-dq)). If $$J = 1-D_{\mathrm{Jaccard}},$$ @@ -36,7 +36,7 @@ the Mash distance is defined as $$D = -\frac{1}{k}\ln\left(\frac{2J}{1+J}\right) = -\frac{1}{k}\ln\left(\frac{2(1-J_{\mathrm{Jaccard}})} {2-J_{\mathrm{Jaccard}}}\right),$$ -with the result clamped to (1.0) when the Jaccard similarity reaches zero. This transformation is monotone increasing with Jaccard distance and therefore preserves the ordering of pairwise dissimilarities. Monotonicity alone, however, does not guarantee preservation of the triangle inequality. Mash should consequently be regarded as an evolutionary distance estimator derived from k-mer similarity rather than assumed to be a metric. +with the result clamped to $1.0$ when the Jaccard similarity reaches zero. This transformation is monotone increasing with Jaccard distance and therefore preserves the ordering of pairwise dissimilarities. Monotonicity alone, however, does not guarantee preservation of the triangle inequality. Mash should consequently be regarded as an evolutionary distance estimator derived from k-mer similarity rather than assumed to be a metric. ## Abundance-based distances @@ -136,4 +136,10 @@ Legendre, P. & Gallagher, E.D. (2001). + +Ondov, B.D., Treangen, T.J., Melsted, P., Mallonee, A.B., Bergman, N.H., Koren, S., et al. (2016). Mash: fast genome and metagenome distance estimation using MinHash. Genome biology, 17, 132. + + +