Skip to content

Plotting lineage tree - #320

Open
yfukai wants to merge 7 commits into
royerlab:mainfrom
yfukai:plot_lineage_tree
Open

Plotting lineage tree#320
yfukai wants to merge 7 commits into
royerlab:mainfrom
yfukai:plot_lineage_tree

Conversation

@yfukai

@yfukai yfukai commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Plotting lineage trees of tracksdata in matplotlib. I believe this is of interest to a fraction of users!

yfukai and others added 4 commits July 24, 2026 09:03
Add plot_lineage_tree in tracksdata.functional._plot: render lineage
trees with matplotlib, supporting attribute-bound node colors and sizes,
time windows, and exact timestamps. Export from tracksdata.functional and
add an optional `plot` extra (matplotlib).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…lineage_tree

Rename color_attr/size_attr to color/size and let color, size, marker, and
text each accept either a fixed value or a callable resolving a per-node
value from the node's attribute row:

- color: numeric attr or callable returning numbers -> cmap + colorbar;
  callable returning literal colors (names/hex/RGBA) -> used verbatim.
- size: attr mapped to size_range, callable returning raw sizes, or constant.
- marker: single glyph, or callable returning a per-node glyph (nodes are
  grouped by glyph, one scatter call per group, sharing one normalization).
- text: attr name or callable -> per-node annotation, styled via text_kwargs.

Add `attrs` to declare the node keys callables read. If a callable is given
without `attrs`, warn and load all node attributes (may pull mask blobs).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
@yfukai
yfukai marked this pull request as ready for review September 10, 2026 01:06
yfukai and others added 3 commits September 10, 2026 14:44
…ature

- add `edge_color`, resolved like `color` (attribute name, callable, or
  literal color); numeric edge values share `cmap`/`color_norm` with the
  face color and are mapped manually since scatter only colormaps `c`
- a `color`/`edge_color` string that is not a node attribute is taken as
  a literal matplotlib color (previously a ValueError)
- drop `node_size`: `size` now defaults to 30.0 and accepts a float
- drop `time_range`: `time_points=range(a, b + 1)` covers it

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
- resolve requested attribute keys through a single validation path and
  dedupe with dict.fromkeys; typos in `size`/`text` now raise ValueError
  even when a callable triggers loading all attributes
- fold `_resolve_color_values` into `_resolve_color_channel`
- draw every marker glyph through one grouped scatter loop, inlining the
  former `_scatter_group` closure; scalar sizes are expanded to an array
  so `size` consistently overrides `scatter_kwargs["s"]`
- build the successor adjacency with a polars group_by and look up node
  coordinates with `Series.replace_strict`
- compute the orientation flag once and label the time axis via
  `Axis.set_label_text`
- rename the shadowed `time_points` local to `shown_time_points`

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
- `time_points` now only limits where markers are drawn; edges are drawn
  for every node between the first and last displayed time point, so
  divisions stay at their true time instead of being bridged
- with `time_positions=None`, all time points in the displayed range are
  evenly separated (hidden ones included) and only the displayed ones
  are labeled
- build edge segments with two polars joins on node coordinates and drop
  the `_bridged_edge_segments` walk
- map attribute sizes with `matplotlib.colors.Normalize(clip=True)`
  instead of `_map_to_size_range`; `size_norm` also accepts a
  `Normalize` instance, mirroring `color_norm`

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WwHX5ciJfQPm9z6zmBsb27
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