Skip to content

merge: within-tile 1:1 matching, low-score seed filtering, persist aligned SBS - #232

Merged
mat10d merged 1 commit into
mainfrom
merge-fixes-round2
Jul 16, 2026
Merged

merge: within-tile 1:1 matching, low-score seed filtering, persist aligned SBS#232
mat10d merged 1 commit into
mainfrom
merge-fixes-round2

Conversation

@mat10d

@mat10d mat10d commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Three merge/stitch improvements. Backward compatible — no config changes required. Gated by the full small_test_analysis pipeline (2173/2173 steps, exit 0).

Within-tile 1:1 matching (mutual nearest-neighbor)

merge_sbs_phenotype and the plot_merge_example preview now share a match_cells() helper that enforces mutual nearest-neighbor matching, so no cell within a tile is matched more than once. Cross-tile duplicates remain resolved downstream by deduplication. The preview figure is also redesigned: a common-frame overlay (no cross-coordinate fan-lines), per-cell labels removed, and a stats header (matched / % phenotype / median residual / doubles).

Low-score seed filtering

filter_low_score_seeds() drops initial-site seeds whose alignment score is a low outlier relative to the cohort (median/MAD, k=3), always keeping >= 5. Wired into fast_alignment.py after the best-per-site collapse. Uses a relative cut rather than a fixed floor because the score's absolute scale is screen-dependent.

Persist aligned SBS (stitch fix)

align_sbs output is no longer wrapped in temp(), so the stitch merge can read the aligned SBS tiles (previously deleted after use). This matches the phenotype side, which already persisted its aligned/segmented images.

🤖 Generated with Claude Code

…igned SBS

- match_cells(): mutual nearest-neighbor 1:1 matching, shared by merge_sbs_phenotype
  and plot_merge_example (no within-tile double matches); cleaner 3-panel preview
- filter_low_score_seeds(): drop low-score outlier initial sites relative to the
  cohort (median/MAD), always keeping >= 5; wired into fast_alignment.py
- align_sbs output no longer temp() so the stitch merge can read aligned SBS tiles

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mat10d
mat10d merged commit 289378e into main Jul 16, 2026
3 checks passed
@mat10d
mat10d deleted the merge-fixes-round2 branch July 16, 2026 15:56
akcd1 pushed a commit that referenced this pull request Aug 6, 2026
Bring main (5 commits, #227/#231/#232/#234/#240) into the branch ahead of
#171. Merged rather than rebased: a rebase replays 45 commits and re-hits the
same aggregate collisions repeatedly, while the merge conflicts in one file,
and main only accepts squash merges so the linear history would be flattened
on landing anyway.

Both conflicts are in generate_feature_table.py and are complementary:

- #234 added a warning when perturbation_id_col is unset; the branch added the
  control_name_col fallback (#222). Independent, both kept.
- Column ordering for the construct table: the branch dedupes via
  dict.fromkeys over [pert_id_col, pert_col, control_name_col, ...], main
  dedupes only the id/name pair. Kept the branch version -- main's drops
  control_name_col, which the control filter downstream indexes on, so main's
  form would KeyError under a construct-level config.

ruff check and ruff format clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant