Shift resized intervals to stay on chromosome - #199
Open
buyan-kh wants to merge 1 commit into
Open
Conversation
Co-authored-by: Buyan Khurelbaatar <buyan-kh@users.noreply.github.com>
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.
Summary
grelu.sequence.utils.resizecan producestart < 0orend > chrom_sizewhen applied to intervals (for exampleadata.var = resize(adata.var, seq_len)). That failure only shows up later, when a dataset callscheck_chrom_ends.This adds an optional
genome=argument on the intervals path. When it is set, chrom sizes are loaded withgrelu.io.genome.read_sizesand windows that leave the chromosome are shifted so they stay on-chromosome while keepingseq_len. Rows are never dropped, so AnnDataX/varalignment is preserved. Ifseq_lenis larger than a chromosome,resizeraises.genome=None(the default) keeps the previous unconstrained behavior.This is intended for #176. It does not change the open column-order work on #198.
Compare for an upstream PR: https://github.com/Genentech/gReLU/compare/main...buyan-kh:gReLU:cursor/resize-genome-bounds-300d?expand=1
Fixes #176
Test plan
Ran locally (this environment does not have the full gReLU stack / hg38):
2 passed in 1.39s
Also ran the rest of
tests/test_sequence.pyexcluding hg38 / tangermeme tests:13 passed, 3 deselected in 1.24s
Coverage of the new tests (
tests/files/test_genome.fa/.sizes, chr10/chr21 size 2000):start < 0is shifted to[0, seq_len)end > chrom_sizeis shifted to[size - seq_len, size)seq_lenlarger than the chromosome raisesgenome=Nonestill allows out-of-bounds coordinates