Skip to content

Plot linkage#58

Merged
colganwi merged 6 commits into
mainfrom
plot-linkage
Jul 8, 2026
Merged

Plot linkage#58
colganwi merged 6 commits into
mainfrom
plot-linkage

Conversation

@colganwi

@colganwi colganwi commented Jul 8, 2026

Copy link
Copy Markdown
Collaborator

Added pycea.pl.ancestral_linkage for plotting the pairwise linkage matrix as a clustered heatmap

colganwi and others added 4 commits July 7, 2026 17:23
…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

codecov Bot commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.53846% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.67%. Comparing base (d807c24) to head (bb80f45).

Files with missing lines Patch % Lines
src/pycea/tl/ancestral_linkage.py 95.62% 6 Missing ⚠️
src/pycea/pl/plot_ancestral_linkage.py 98.27% 2 Missing ⚠️
src/pycea/utils.py 83.33% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
src/pycea/pl/__init__.py 100.00% <100.00%> (ø)
src/pycea/utils.py 90.94% <83.33%> (-0.23%) ⬇️
src/pycea/pl/plot_ancestral_linkage.py 98.27% <98.27%> (ø)
src/pycea/tl/ancestral_linkage.py 94.62% <95.62%> (-3.64%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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]]))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@colganwi colganwi merged commit 32044bd into main Jul 8, 2026
6 of 7 checks passed
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