scirpy.ir_dist.metrics.DistanceCalculator.calc_dist_mat

abstract DistanceCalculator.calc_dist_mat(seqs, seqs2=None)

Calculate pairwise distance matrix of all sequences in seqs and seqs2.

When seqs2 is omitted, computes the pairwise distance of seqs against 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 > cutoff is represented as 0, a distance == 0 is represented as 1, a distance == 1 is represented as 2 and so on.

  • Only returns distances <= cutoff. Larger distances are eliminated from the sparse matrix.

  • Distances are non-negative.

Parameters
seqs : Sequence[str]

array containing CDR3 sequences. Must not contain duplicates.

seqs2 : Sequence[str] | NoneOptional[Sequence[str]] (default: None)

second array containing CDR3 sequences. Must not contain duplicates either.

Return type

csr_matrix

Returns

Sparse pairwise distance matrix.