fix(split-phase1): generalize z-gap splitter for alphanumeric cell_ids - #1
Open
atuldeshpande wants to merge 1 commit into
Open
fix(split-phase1): generalize z-gap splitter for alphanumeric cell_ids#1atuldeshpande wants to merge 1 commit into
atuldeshpande wants to merge 1 commit into
Conversation
The Split-Phase1 z-gap stage (_spatial_split_phase1_entities) gated
entities through a numeric-only regex (^\d+(-\d+){0,2}$). On datasets
with dash-containing cell_ids (PDAC, e.g. "jikammne-1"), every entity was
rejected and the entire stage became a silent no-op — z-gap splits never
fired.
Gate on the _etype column (cell/partial) when present; it is set upstream
from kernel codes (pruning.etype_from_codes) so it stays correct on
alphanumeric cell_ids where label parsing is ambiguous. Falls back to the
legacy numeric regex when the column is absent, leaving that path
unchanged. Collapse the numeric collision pre-scan and the
m_main/m_part/m_sub mint branches into a single prefix-agnostic
"append next free suffix" — behavior-equivalent on numeric ids.
Sibling label parsers (_phase1_rerank_within_parent_etype,
_reassign_nuclear_post_1c_etype) already anchor on the cell_id column and
the UNASSIGNED mirror uses numeric component indices, so none were
affected. The proper -tr- delimiter migration remains deferred.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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
_spatial_split_phase1_entities(the Split-Phase1 z-gap splitter intests/_pipeline_runner.py) gated entities through a numeric-only regex^\d+(-\d+){0,2}$. On datasets whose cell_ids contain dashes (PDAC, e.g.jikammne-1), the regex rejected every entity, so the entire z-gap stage was a silent no-op — entities that should split on a z-gap >dz_threshold(2.0 µm) were never examined._etypecolumn (cell/partial) when present._etypeis set upstream from kernel codes (pruning.etype_from_codes), so it stays correct on alphanumeric cell_ids where label-string parsing is ambiguous. The legacy numeric regex is retained as a fallback when the column is absent, leaving that path byte-for-byte unchanged.next_suffix/next_subsuffix) and them_main/m_part/m_submint branches collapse into a single prefix-agnostic counter that appends the next collision-free-{k}suffix to the parent label — behavior-equivalent on numeric ids, correct for any prefix.Why
PDAC and other Xenium FFPE/IO datasets carry alphanumeric, dash-containing cell_ids. The numeric-only assumption silently disabled the z-gap splitter on exactly those datasets. This is the same root issue tracked under the entity-type-column refactor: infer identity/kind from the
_etypecolumn rather than parsing the label string.Audit (other numeric-only label parsers)
_phase1_rerank_within_parent_etypeand_reassign_nuclear_post_1c_etypealready anchor on the realcell_idcolumn (lab.startswith(cid + "-")) and parse only the suffix — they handleadohnpem-1-style ids correctly. No change._split_unassigned_componentsusesUNASSIGNED_{i}with a numeric connected-component index by construction — unaffected. No change.-tr-delimiter scheme (src/tracer/_etype.py) is the proper long-term fix but has zero live emitters; activating it requires regenerating all reference partitions, so it remains deferred to its own branch.Tests
tests/test_split_phase1_zgap.py(6 direct unit tests): alphanumeric+_etypesplits, numeric+_etypeparity, numeric no-_etypelegacy parity, alphanumeric no-_etypeboundary no-op, no-gap control, and existing-child collision avoidance.test_pipeline_regression.py(reference-partition comparison) andtest_etype.py— confirms numeric pipeline behavior is unchanged.Test plan
PYTHONPATH=src python -m pytest tests/test_split_phase1_zgap.py -x -qPYTHONPATH=src python -m pytest tests/test_pipeline_smoke.py -x -qPYTHONPATH=src python -m pytest tests/ -q(157 passed)🤖 Generated with Claude Code