scirpy.ir_dist.metrics.NeedlemanWunschDistanceCalculator#
- class scirpy.ir_dist.metrics.NeedlemanWunschDistanceCalculator(cutoff=10, *, gap_penalty=4, n_jobs=-1, n_blocks=1, histogram=False)#
Computes pairwise global-alignment distances with linear-gap Needleman-Wunsch.
For each sequence pair, a global alignment score is computed using the Needleman-Wunsch dynamic programming algorithm with one linear gap penalty for every gap position. The alignment score is converted into a distance by subtracting it from the best possible self-alignment score of the two sequences:
min(self_score(seq1), self_score(seq2)) - alignment_score(seq1, seq2). Distances are therefore small for sequence pairs that can be globally aligned with few or conservative substitutions and short gaps, and larger for sequence pairs requiring strongly penalized substitutions or many gap positions.- Parameters:
gap_penalty (
int(default:4)) – Linear penalty for each gap positioncutoff (
int(default:10)) – Will eliminate distances > cutoff to make efficient use of sparse matricesn_jobs (
int(default:-1)) – Number of numba parallel threads to use for the pairwise distance calculationn_blocks (
int(default:1)) – Number of joblib delayed objects (blocks to compute) given to joblib.Parallelhistogram (
bool(default:False)) – Determines whether a nearest neighbor histogram should be created. Not implemented for this metric
Methods table#
|
Calculates the pairwise distances between two vectors of gene sequences based on the distance metric of the derived class and returns a CSR distance matrix. |
Methods#
- NeedlemanWunschDistanceCalculator.calc_dist_mat(seqs, seqs2=None)#
Calculates the pairwise distances between two vectors of gene sequences based on the distance metric of the derived class and returns a CSR distance matrix. Also creates a histogram based on the minimum value per row of the distance matrix if histogram is set to True.
- Return type: