Repository navigation
Conversation
check_intervals previously required chrom/start/end as the first three columns, which broke resize and tutorials when columns were present but reordered. Identify required columns by name, update docstrings, select interval columns by name in DFSeqDataset, and add unit tests for out-of-order dataframes. Fixes Genentech#34
avantikalal
left a comment
There was a problem hiding this comment.
Thanks for this — the root cause tracking is spot on. I confirmed check_intervals()'s positional column check (df.columns[:3] == ["chrom","start","end"]) and DFSeqDataset.__init__'s df.iloc[:, :3] / df.iloc[:, 3:] were the only two places in the codebase making that positional assumption (grepped for columns[:3] / iloc[:, :3] repo-wide), so this fix is complete in scope — no other callers need touching. resize() itself already indexed interval columns by name internally, so that diff is correctly docs/type-hints only.
Two things I'd like addressed before merging:
-
Stale docstring in
DFSeqDataset(src/grelu/data/dataset.py) — the class docstring still says "genomic intervals in the first 3 columns," which is no longer accurate now that column order doesn't matter. Worth updating alongside theresize()/format.pydocstring changes you already made. -
Missing test coverage for the
dataset.pychange itself — the new tests (test_get_input_type,test_resizeintests/test_sequence.py) covercheck_intervals/resize, buttests/test_dataset.pyalready has extensiveDFSeqDatasetcoverage and gets no new case for reordered interval columns. SinceDFSeqDataset.__init__'sseqs/labelssplit is one of the two files this PR actually changes, I'd like a test that constructs aDFSeqDatasetfrom a dataframe with out-of-orderchrom/start/end(plus label columns) and asserts the labels extracted are correct — that's the part most likely to silently regress later.
Logic itself looks correct and the existing tests are good (nice touch testing extra columns too). Requesting changes mainly for the test gap above.
Summary
check_intervalsnow validateschrom/start/endby column name (order-independent), sogrelu.sequence.utils.resizeand other callers no longer fail when those columns are present but reordered.resize/ format docstrings to document name-based interval columns;DFSeqDatasetalso selects interval columns by name for consistency.get_input_typeandresize.Fixes #34
Test plan
pytest tests/test_sequence.py::test_get_input_type tests/test_sequence.py::test_resizename, end, chrom, startworks withresize