Repository navigation
Conversation
tolerance pairs features within a fixed distance of each other, so finding the features that fall inside per-box ranges, such as a feature's m/z and retention time extent padded by a margin, needs a dense feature by box comparison. within reads a lower and an upper bound column per dimension from the boxes and returns every feature and containing box, row for row, like tolerance. It windows each feature over the boxes sorted by lower bound, back to the widest box, in the dimension with the fewest candidates, then checks every dimension in chunks, as tolerance does since pnnl#67.
The pandas 2.3.3 annotations accept a list of strings for DataFrame columns only through SequenceNotStr, which pyright rejects for list[str].
This branch has not been deployed
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.
Description
deimos.alignment.tolerancepairs features within a fixed distance of each other. Some lookups need the reverse geometry: which features fall inside a set of ranges, each with its own extent. An example is labeling MS2 spectra by whether their precursor m/z and retention time fall inside a feature's m/z and time span, padded by a margin. Batchdeimos.slicehandles one range per slice, but withreturn_indexit builds a ranges-by-rows boolean mask, and it returns the rows of each range rather than the ranges of each row. Code with that need writes a dense comparison in chunks.This PR adds
deimos.alignment.within(features, boxes, dims, low, high):boxeshas a lower and an upper bound per dimension, in the columns thatlowandhighgive in the order ofdims. They default to each dimension with_minand_maxappended.tolerance: the matched rows offeaturesandboxes, row for row, ordered by position infeaturesand then inboxes, orNone, Nonewhen no box contains a feature.The search follows the sparse approach of
tolerancesince #67. A box can contain a value only when its lower bound lies between the value minus the widest box and the value. Each feature is windowed over the boxes sorted by lower bound in the dimension that yields the fewest candidates, and the candidates are then checked in every dimension, about a million at a time. A dimension with an unbounded box is not used for windowing, since that box can contain any value.Verification
7 new tests in
tests/test_alignment.py:python -m pytest: 390 tests, 5 failing, the same 5 that fail on master in this environment (pandas 3.0.3, NumPy 2.5.2). They are intests/test_deconvolution.py, where this environment's SciPy raises_dfitpack.errorfor a spline with too few points.ruff checkandruff format --checkpass, and In this environment,pyrightreports the same 19 errors in the two changed files as on master. CI installs pandas 2.3.3, under which pyright also checks the label arguments toDataFrame; its pyright check and its test runs on Ubuntu, macOS, and Windows pass.On two LC-MS studies, the MS2 precursors (m/z and retention time) were assigned to background features (m/z range padded by a ppm window, time range padded by a margin), taking the first containing feature in m/z order. The assignments were identical to a dense chunked comparison:
withinNotes for reviewers
withinafter the condition it tests.contained_inorin_boxeswould also fit.No related issue.
Quality assurance and AI policy
To maintain project quality and respect maintainer bandwidth, please confirm the following about this pull request (PR):
python -m pytestpasses locally.Status
Developer Certificate of Origin
Note to contributors: We reserve the right to close PRs without review if they appear to lack human validation or do not meet the quality standards described in our contributing guide.