scirpy.ir_dist.metrics.DistanceCalculator#
- class scirpy.ir_dist.metrics.DistanceCalculator(cutoff)#
Abstract base class for a CDR3-sequence distance calculator.
Attributes table#
The sparse matrix dtype. |
Methods table#
|
Calculate pairwise distance matrix of all sequences in |
|
Mirror a triangular matrix at the diagonal to make it a square matrix. |
Attributes#
- DistanceCalculator.DTYPE = 'uint8'#
The sparse matrix dtype. Defaults to uint8, constraining the max distance to 255.
Methods#
- abstract DistanceCalculator.calc_dist_mat(seqs, seqs2=None)#
Calculate pairwise distance matrix of all sequences in
seqsandseqs2.When
seqs2is omitted, computes the pairwise distance ofseqsagainst itself.Calculates the full pairwise distance matrix.
Important
Distances are offset by 1 to allow efficient use of sparse matrices (\(d' = d+1\)).
That means, a
distance > cutoffis represented as0, adistance == 0is represented as1, adistance == 1is represented as2and so on.Only returns distances
<= cutoff. Larger distances are eliminated from the sparse matrix.Distances are non-negative.
- static DistanceCalculator.squarify(triangular_matrix)#
Mirror a triangular matrix at the diagonal to make it a square matrix.
The input matrix must be upper triangular to begin with, otherwise the results will be incorrect. No guard rails!
- Return type: