Add symmetrized linkage stats to ancestral_linkage#60
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60 +/- ##
==========================================
+ Coverage 93.83% 93.92% +0.08%
==========================================
Files 37 37
Lines 3344 3373 +29
==========================================
+ Hits 3138 3168 +30
+ Misses 206 205 -1
🚀 New features to boost your workflow:
|
When symmetrize is not False and test='permutation' in pairwise mode,
ancestral_linkage now writes tdata.uns['{key_added}_symmetrized_linkage_stats']:
a long-form table with one row per unordered category pair (upper triangle
incl. diagonal) giving the symmetrized value, permuted value, z-score, and a
p-value for the symmetrized linkage.
The p-value is computed by symmetrizing each permutation's null matrix (with
the same mean/max/min rule as the observed matrix) and testing the observed
symmetrized value against that null distribution.
- Add _symmetrize_array (symmetrizes along the last two axes; reused by
_symmetrize_matrix) and _symmetrized_stats_rows helpers.
- _run_permutation_test / _run_permutation_test_non_target now also return the
raw null_array so the symmetrized null can be derived.
- Wire into both global and by_tree pairwise paths; clear any stale table when
conditions aren't met.
- Exclude the new key from pl.ancestral_linkage's groupby auto-inference.
- Add test and CHANGELOG entry.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33ed43b to
d6e3aac
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33ed43b599
ℹ️ 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".
| sym_key = f"{key_added}_symmeterized_linkage_stats" | ||
| if sym_stats_rows: | ||
| tdata.uns[sym_key] = pd.DataFrame(sym_stats_rows) | ||
| else: | ||
| # Drop any stale table from a previous run (e.g. when symmetrize was truthy then). | ||
| tdata.uns.pop(sym_key, None) |
There was a problem hiding this comment.
Clear stale symmetrized stats in single-target runs
This cleanup only runs in the pairwise branch, so a prior pairwise call with test='permutation' and truthy symmetrize leaves {key_added}_symmeterized_linkage_stats behind if the next call uses the same key_added in single-target mode. In that scenario tdata.uns still advertises a symmetrized pairwise stats table even though the current result is single-target-only, which can make downstream code consume stale p-values/results.
Useful? React with 👍 / 👎.
- Drop {key_added}_symmetrized_linkage_stats before the mode branch so a later
single-target run under the same key_added does not leave a stale pairwise
table for downstream code to consume (flagged by review).
- Cover the by_tree + permutation_mode='all' symmetrized path in tests.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Addressed in 19ed242:
|
No description provided.