Nearest ranges strand direction, again - #173
Merged
Merged
Conversation
Overlapping intervals are all at distance 0, so with the default exclude_overlaps=False "every tied interval" means "every interval of other that self overlaps". One interval of self covered by 500 intervals of other produces 500 rows, every one of them equally the nearest. On 100 million hg38-like intervals against themselves that is 1.1 billion output rows against 7.7 million for one per query -- 144x, and the difference between fitting in memory and not. `ties="first"` reports one interval per distance instead, so each interval of self appears at most once. Which one is unspecified, as it is for bedtools `closest -t first`, GenomicRanges `select="arbitrary"` and BEDOPS `--closest`; the same input gives the same answer, and nothing is sorted to decide it because the sort would cost more than the option saves. The default, "all", is unchanged. The tied rows are never built. Filtering afterwards would have cost the same memory as "all" and more time, so the saving comes from the kernel: the overlap sweep stops at the first hit per interval of self, each directional sweep emits one row per distinct distance, and the merge keeps one row per distance bucket. That is `ruranges_core::nearest`, so the floor on ruranges rises to 0.1.8. `k` still counts distinct distances, so `ties="first", k=2` gives two rows rather than being rejected. An unknown value raises ValueError naming the options, like `direction` and `multiple`, rather than reaching the kernel and aborting the interpreter with a Rust panic. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nearest_ranges takes ties
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.
I had PRed into a branch rather than master, by mistake