Refine networks#21
Merged
Merged
Conversation
Rewrite the C++ core (fastEditEdges.cpp) around candidate generation instead of all-pairs comparison. No new dependencies, and the default (clique) output is identical to the previous engine. - Deduplicate to unique (sequence, V, J) representatives so clonal expansion no longer drives quadratic distance computation. - Use length and V/J blocking as an index. Only length-compatible representatives in the same block are compared. - Add SymSpell deletion-neighborhood hashing for Levenshtein (radius k) and Damerau (radius 2k, since a transposition costs 2 in Levenshtein), and pigeonhole segment indexing for Hamming. Both fall back to length-blocked comparison outside their range. - Return integer node indices from the engine and attach labels in R, avoiding millions of barcode strings inside the parallel core. - Add an `expand` argument to buildNetwork(): "clique" (default) keeps exact edge multiplicity, "star" preserves connected components with far fewer edges for a large memory win. Fix a pre-existing banded Levenshtein error that dropped pairs whose only optimal alignment rides the band edge, including identical sequences at a tight normalized threshold. The boundary cell read the wrong diagonal value. The fix only recovers true edges. Also make the normalized-threshold cutoff robust to floating-point rounding so a normalized distance exactly equal to the threshold is kept. Add a set-equality regression harness plus star, Damerau, and Levenshtein-vs-adist correctness tests. Bump version to 1.7.1.
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On clonally expanded repertoires
buildNetwork()spent most of its time recomputing distances between identical sequences and skipping length-incompatible pairs one at a time. The engine was effectively all-pairs within each V/J block.What
The C++ core was rewritten around candidate generation. No new dependencies, and the default output is unchanged.
(sequence, V, J)representatives. Distance work runs over representatives, then edges expand back to member nodes.2k). Hamming uses pigeonhole segment indexing. Each falls back to length-blocked comparison when the edit radius is too large.expandargument."clique"(default) reproduces exact edge multiplicity for community detection."star"preserves connected components with far fewer edges.Performance (identical output, clique mode)
starexpansion also cut edge count ~13x on the first case with identical connected components.Bug fixes
D[i-1][0]instead ofD[i-1][start_j-1], so pairs whose only optimal alignment rides the band edge were missed (true distance == |Δlen| == threshold), including identical sequences at tight normalized thresholds. Masked before because callers passed loose thresholds (wide band). The fix only recovers true edges (verified: 4 added, 0 removed across the regression grid, all confirmed againstadist).Testing
cliquemode is byte-identical to the previous engine apart from the band-bug recoveries now baked into the golden snapshot.starpreserves components and vertex sets, Damerau transposition trap, and Levenshtein vsstats::adistexactness across thresholds.