Plot linkage#58
Conversation
…o ancestral_linkage - Add `min_size` param: in pairwise mode, exclude categories with fewer than `min_size` cells from the linkage matrix. - Support `aggregate='max'` + `metric='lca'` on non-ultrametric trees via an exact subtree walk-up (`_max_lca_depth_scores`), which previously raised a ValueError. - Use the walk-up as the shared "closest relative" primitive for both closest-target aggregates: `lca`+`max` directly, and ultrametric `path`+`min` via the affine transform `2D - 2*score`. This replaces the per-category Dijkstra with a single bottom-up pass, making linkage substantially faster (esp. with many categories). Non-ultrametric `path`+`min` still uses Dijkstra. - Fix docstring: `aggregate='max'` selects the deepest (not shallowest) LCA. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #58 +/- ##
==========================================
- Coverage 93.98% 93.67% -0.31%
==========================================
Files 35 36 +1
Lines 3008 3194 +186
==========================================
+ Hits 2827 2992 +165
- Misses 181 202 +21
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5cef1bd528
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| result_series = pd.Series( | ||
| {cat: float(np.nanmean([score_map.get(l, np.nan) for l in cat_to_leaves[cat]])) for cat in all_cats}, | ||
| { | ||
| cat: float(np.nanmean([score_map.get(l, np.nan) for l in cat_to_leaves[cat]])) |
There was a problem hiding this comment.
Return normalized single-target copies
When target is set with normalize=True and test=None (now the default normalization path), the obs column is overwritten with norm_map just above, but copy=True still returns per-category means from the raw score_map. Callers using copy=True therefore get values that disagree with the stored {target}_linkage output; build the returned series from the normalized map when normalization is applied.
Useful? React with 👍 / 👎.
Added
pycea.pl.ancestral_linkagefor plotting the pairwise linkage matrix as a clustered heatmap