# TCR Metrics for Pairwise Distance Matrix

**URL:** <https://discourse.scverse.org/t/tcr-metrics-for-pairwise-distance-matrix/2015>\
**Category:** scirpy\
**Created:** [January 22, 2024, 3:42pm UTC](https://discourse.scverse.org/t/tcr-metrics-for-pairwise-distance-matrix/2015 "2024-01-22T15:42:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![grst](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.scverse.org/grst/32/17_2.png) [@grst](https://discourse.scverse.org/u/grst)\
**Post date:** [January 26, 2024, 7:06am UTC](https://discourse.scverse.org/t/tcr-metrics-for-pairwise-distance-matrix/2015/2 "2024-01-26T07:06:45Z")

</div>

First, I want to make the distinction between “clonotypes” and “clonotype clusters” clear:

- A [clonotype](https://scirpy.scverse.org/en/latest/glossary.html#term-Clonotype) refers to T cells with the same origin and _exactly the same_ CDR3 nucleotide sequence
- A [clonotype cluster](https://scirpy.scverse.org/en/latest/glossary.html#term-Clonotype-cluster) is a group of _similar clonotypes_ that likely recognize the same epitope, as defined by some distance metric.

This implies that for defining _clonotypes_, the only relevant metric is the _identity_ metric.

As for defining clonotype clusters, clonotype networks and database queries, I don’t think that any of the metrics available in scirpy behaves fundamentally different. Ultimately, we don’t know which metric is best (in that it captures best which receptors recognize the same antigen), because there is insufficient gold standard data for benchmarking. It is very likely though that the “alignment” metric captures this better than the “levenshtein” distance because it takes the properties of the individual amino acids into account (at a higher computational cost). The “hamming” distance is more useful for B cells than for T cells.

The overall network structure is more affected by the distance threshold you set (a higher cutoff will lead to larger network components) and whether you set `receptor_arms` and `dual_ir` to `all` or `any`. This is also demonstrated to some extent in this thread: [Is it necessary to remove orphan-VJ/VDJ cells in practice?](https://discourse.scverse.org/t/is-it-necessary-to-remove-orphan-vj-vdj-cells-in-practice/513)

Hope that helps!

---

_[View the full topic](https://discourse.scverse.org/t/tcr-metrics-for-pairwise-distance-matrix/2015)._
