Conversation
… mode
Three related changes:
- Pairwise permutation: update docstring to reflect that the stored linkage
matrix is observed - permuted_mean (not z-scores).
- Single-target + permutation: add tdata.obs['{target}_norm_linkage'] with
per-cell z-scores normalized by each cell's source-category null distribution.
- Single-target + by_tree + permutation: run permutation, stats, and
normalization independently per tree so each cell is normalized by its
own tree's null model.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds normalize: bool = False to ancestral_linkage. When True and
test='permutation':
- Pairwise: linkage matrix stores observed - permuted_mean instead of raw values.
- Single-target: tdata.obs['{target}_linkage'] is replaced with
cell_score - category_permuted_mean.
- Both modes support by_tree, where per-tree null distributions are used
for normalization independently per tree.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #55 +/- ##
==========================================
+ Coverage 93.92% 93.99% +0.07%
==========================================
Files 35 35
Lines 2932 2983 +51
==========================================
+ Hits 2754 2804 +50
- Misses 178 179 +1
🚀 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: 5785893917
ℹ️ 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".
| test: Literal["permutation", None] = None, | ||
| normalize: bool = False, | ||
| alternative: Literal["two-sided", None] = None, |
There was a problem hiding this comment.
Keep
normalize from shifting positional arguments
Adding normalize between test and alternative changes the positional call contract of this public API: existing callers that previously passed alternative (or later args) positionally will now silently bind those values to normalize instead. For example, a positional 'two-sided' now becomes a truthy normalize value while alternative stays None, which changes both p-value calculation and stored linkage values without raising an error. Please make normalize keyword-only or append it after existing positional parameters to preserve backward compatibility.
Useful? React with 👍 / 👎.
Summary
normalizeparameter (bool, defaultFalse): whenTrueandtest='permutation', subtract the permuted mean from observed values.uns[linkage]storesobserved - permuted_meaninstead of raw linkage.obs['{target}_linkage']is replaced bycell_score - category_permuted_mean.by_tree+ permutation: runs the permutation test independently per tree, producing per-tree stats (with a"tree"column, consistent with pairwiseby_tree). Whennormalize=True, each cell is normalized against its own tree's null distribution.Test plan
test_pairwise_normalize_stores_value_minus_permuted— linkage matrix = value - permuted_value when normalize=Truetest_pairwise_no_normalize_stores_raw_linkage— raw linkage unchanged when normalize=Falsetest_single_target_normalize_overwrites_linkage— per-cell linkage = score - cat_permuted_meantest_single_target_no_normalize_keeps_raw— raw scores unchanged when normalize=Falsetest_single_target_by_tree_permutation— per-tree stats with "tree" columntest_single_target_by_tree_normalize— per-tree normalization updates _linkagetest_single_target_by_tree_perm_non_target— non_target mode works with by_tree🤖 Generated with Claude Code