Skip to content

Anchor-mode HIV rendering, palette/NT-ruler/V1V2 extensions, row labels, multi-panel fixes#1

Open
tmsincomb wants to merge 8 commits into
mainfrom
helpers
Open

Anchor-mode HIV rendering, palette/NT-ruler/V1V2 extensions, row labels, multi-panel fixes#1
tmsincomb wants to merge 8 commits into
mainfrom
helpers

Conversation

@tmsincomb
Copy link
Copy Markdown
Owner

Summary

  • Anchor modehiv_panel and CLI now render HIV Env alignments without an HxB2 row by mapping a known lineage _ref (CH505 / SF162p3 / T250-4) onto bundled per-lineage HxB2 references. New tpixel.anchors module + package data.
  • Variant labels — opt-in K169E-style mutation labels under the x-axis, computed against HxB2 (works in both classic and anchor mode).
  • Marker toggle--markers/--no-markers to suppress PNGS dots.
  • Heterologous coloringsecondary_ref_row for three-way classification (match / mismatch-vs-primary / heterologous-vs-secondary).
  • NT ruler — drawn as top header track above the region bar.
  • Palette + V1V2 mergehiv_panel palette overrides with adjacent same-color region merging.
  • Row labelsrow_label_mode supports group_rollup, per_row_numbered, raw_seqid.
  • Multi-panel rendering — shared inches-per-data-unit scale, shared footer, zero margin, uuid-suffixed brick labels (fixes patchworklib _labelset reuse error across multiple render_panels calls in one process).
  • Region bar fix — gap columns absorb into surrounding region instead of fragmenting the bar.
  • Test fixtures trimmedtests/data/*.fasta cut to 10 records each; full alignment width preserved. Repo no longer carries large sequence sets.
  • .gitignore cleanup — add refs/, restore tests/output/, drop dead prototype entries.

Test plan

  • pytest tests/ — 125 passed
  • CLI smoke: tpixel <CH505 alignment> --hiv -o out.png
  • CLI smoke anchor mode: tpixel <T205-4 fasta> --hiv --anchor-lineage T250-4 -o out.png
  • CLI variant labels: tpixel <alignment> --hiv --variant-labels -o out.png
  • Multi-panel render still works in same process across multiple calls (regression for patchworklib labelset)

…margin

- render_panels now stacks panels with patchworklib instead of overwriting
- Derive shared inches-per-data-unit scale from tallest panel so chrome
  (regions, markers, ref rows) is identical physical size across panels
- Only last panel draws the legend (show_footer parameter)
- Set patchworklib margin to 0 for flush panel stacking
- Fix panel_figsize to account for extra_ref_rows
- Add _data_height helper mirroring _draw_panel coordinate system
- Add figsize/show_footer params to to_patchwork for composition control
Extend Panel with optional secondary_ref_row + heterologous_color so the
renderer can flag cells where a sample matches a secondary reference (e.g.
another lineage's parental) but differs from the primary reference. Useful
for visualizing heterologous-recombination evidence in pixel panels.

- models.Panel: secondary_ref_row + heterologous_color (default #FF6F00)
- hiv.hiv_panel: secondary_ref_path param; reads single-record FASTA,
  asserts length matches alignment columns
- renderer._draw_panel: three-way comparison before mismatch coloring,
  legend gains "Heterologous" entry when secondary ref is present
- 7 new tests covering match/pure-mismatch/heterologous classification,
  short-secondary fallback, end-to-end hiv_panel integration, and
  length-mismatch error path
…ny round 1)

resolves: scrutiny-m2 blocker #2 (ruler below region bar)
… (scrutiny round 1)

resolves: scrutiny-m2 blocker #3

Adds a row_label_mode field to Panel with three modes:
  - group_rollup (default; preserves existing '{name} ({count})' labels)
  - per_row_numbered ('{N}. {short_seqid}' with N monotonic per panel)
  - raw_seqid ('{short_seqid}' only)

Reference rows (extra_ref_rows and the primary ref labelled by
panel.label) are ALWAYS drawn with their logical label and never
numbered, regardless of mode. short_seqid truncates to
row_label_max_chars (default 30).

Threads row_label_mode + row_label_max_chars through hiv_panel().
Adds compute_row_labels() helper exposing the label list in render
order for tests. Adds TestRowLabelMode suite in
tests/test_hiv_panel_extensions.py (9 new tests, 85/85 total).
Adds tpixel.anchors with bundled lineage→HxB2 maps (CH505, SF162p3,
T250-4) so hiv_panel can place the region bar even when the alignment
lacks an HxB2 row. New CLI/API surface:

* hiv_panel: anchor_id, anchor_lineage, show_variant_labels, show_markers
* CLI: --anchor-id, --anchor-lineage, --variant-labels, --markers/--no-markers
* hxb2_variant_labels(): K169E-style mutation labels vs HxB2
* hxb2_col_labels(): always include first mapped column tick
* hxb2_regions(): absorb gap columns instead of fragmenting bar
* renderer: uuid-suffixed brick labels (fixes patchworklib reuse error
  across multiple render_panels calls in one process); footer height
  bump for legend clearance; font-size tweaks

Package data: anchor reference fastas shipped via setuptools package-data
declaration. Tests fixtures trimmed to 10 records each (full alignment
width preserved) — repo no longer carries large sequence sets.

.gitignore: add refs/, restore tests/output/, drop dead prototype entries.
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