Repository navigation
Feature: pp.var_consistency() and pp.filter_by_var_consistency() - #45
Merged
Merged
Conversation
pp.var_consistency() correlates each variable's profile across group_by groups between every pair of batches (batch_key) and stores the median, min and mean per variable in .var and the per-pair correlations in .varm. pp.filter_by_var_consistency() keeps variables whose score reaches a threshold, inferring the single *_corr_min column when no key is given. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Documentation build overview
7 files changed ·
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9d20ec1e2
ℹ️ 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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fractionation and other profile experiments need a way to drop peptides
whose profile is not reproducible across batches/replicates before COPF
correlates them. Without it, noise drives the proteoform calls. This
adds
pr.pp.var_consistency()andpr.pp.filter_by_var_consistency(),ported from the exp009 proteoform tutorial and generalised: they work
with any batch column and any combination of grouping columns. Before,
replicate, condition and fraction columns were hardcoded.
Related issues
None
General checklist
HISTORY.mdupdated under[Unreleased]the pre-commit/pre-push hooks pass; CI pending. No new tests.
✨ Feature
What it adds:
pr.pp.var_consistency(adata, batch_key, group_by, min_groups=4, ...)group_bygroups. A list such as["condition", "fraction"]usesevery combination of values as a group. Samples sharing a batch and
a group are averaged.
correlation is NaN if fewer than
min_groupsgroups are shared oreither profile is constant.
<key_added>_{median,min,mean,n_valid}in.var, and theper-pair correlations and shared-group counts in
.varm["<key_added>_pairs"].key_addeddefaults to<batch_key>_corr.pr.pp.filter_by_var_consistency(adata, threshold, key=None, ...)keeps the variables with
score >= threshold. Ifkeyis None, ituses the single
.varcolumn ending in_corr_min, and raises ifthere are none or several.
remove_nacontrols whether variableswith an undefined score are dropped.
Example usage:
(
check_proteodataon entry/exit, sparse input warned and densified,inplace,key_added,verbose, validation helpers)purpose; to follow in a separate PR. The checks run instead are
listed below.
docs/sphinx/source/api/pp.rst).The Sphinx build itself was not run.
under
docs/tutorials/uses these functions yet.Notes for reviewers
_pairwise_profile_corr). The originallooped over variables and batch pairs with pandas. This version
computes one masked, column-wise Pearson correlation per batch pair in
numpy. A profile counts as constant when the minimum and maximum of
its shared values are equal. This exact test matches the original
nunique() > 1check and is not affected by rounding.60,698 peptides, 3 replicates × 2 conditions × 6 fractions):
.varsummaries and.varmpairs agree with the originalwithin 8e-16
remove_nasettings keep the same 48,279 peptidesgroup_bycolumns, or passing one combinedcolumn, gives identical results
whose zeros mean "not measured" should convert them to NaN first; the
docstring says this.
batch_key/group_byraise an error. Aplain
groupbywould drop those samples without saying so.🤖 Generated with Claude Code