Skip to content

Add optional absolute threshold to trim_pwm - #196

Merged
avantikalal merged 2 commits into
Genentech:mainfrom
buyan-kh:fix/trim-pwm-absolute-threshold
Oct 7, 2026
Merged

avantikalal merged 2 commits into
Genentech:mainfrom
buyan-kh:fix/trim-pwm-absolute-threshold

Conversation

@buyan-kh

@buyan-kh buyan-kh commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes an inconsistency in trim_pwm (trim_pwm inconsistency #125): the function previously always treated trim_threshold as relative to the max per-position score, which assumes an IC-style PWM and is awkward for more general matrices (e.g. PPMs).
  • Adds relative: bool = True so callers can request an absolute threshold (relative=False) while keeping the existing relative behavior as the default for backwards compatibility.
  • Updates the docstring to document that the function works with general weight matrices, and extends unit tests to cover relative vs absolute thresholding.

API change

trim_pwm(pwm, trim_threshold=0.3, return_indices=False, relative=True)
  • relative=True (default): trim_thresh = max(score) * trim_threshold (unchanged behavior)
  • relative=False: trim_thresh = trim_threshold (absolute threshold on summed absolute weights per position)

Test plan

  • pytest tests/test_interpret.py::test_trim_pwm passes
  • Existing relative-threshold assertions still pass with default args
  • New tests cover absolute threshold and a case where relative vs absolute diverge

Fixes #125

buyan-kh and others added 2 commits September 8, 2026 18:18
trim_pwm previously always treated trim_threshold as relative to the
max per-position score, which is awkward for non-IC matrices such as
PPMs. Add a relative flag (default True) so callers can opt into an
absolute threshold while preserving backwards-compatible behavior.

Fixes Genentech#125
@avantikalal
avantikalal merged commit af271ad into Genentech:main Oct 7, 2026
2 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.

trim_pwm inconsistency

2 participants