fix: symmetric N/* handling across strands in PWM energy routines (5.11.11) - #150
Merged
Conversation
…11.11) integrate_energy(), integrate_energy_logspat() and integrate_energy_max_logspat() scored N/* with the column average (get_avg_log_prob) on the forward strand but a flat log(0.25) on the reverse strand. Both strands now use the column average, matching the forward branch, the symmetric likelihood routines (max_like_match, integrate_like_seg), and the shared DnaPSSM code in the prego package. No behavior change for genomic vtrack scoring: an N-containing window is masked to -Inf before these branches run. This keeps misha's DnaPSSM in sync with prego, where the same code path (compute_pwm) feeds ambiguous bases through unmasked and the asymmetry was an observable ~1.6 nat strand-dependent error. Claude-Session: https://claude.ai/code/session_01PK3qefBGDoBwd9w5226FEq
aviezerl
force-pushed
the
fix/pwm-n-strand-asymmetry
branch
from
July 21, 2026 17:41
70d0801 to
6d8f11b
Compare
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.
Context
Companion to a
pregofix (tanaylab/prego#40). A user asked whyprego::compute_pwmtreatsNdifferently on the two strands. It turned out the sharedDnaPSSMscan code uses the column average (get_avg_log_prob()) forN/*on the forward strand but a flatlog(0.25)on the reverse strand. In prego this is an observable ~1.6 nat strand-dependent error, becausecompute_pwmfeeds ambiguous bases straight through the scan.misha carries the same asymmetry in
integrate_energy,integrate_energy_logspat, andintegrate_energy_max_logspat(the PWM-energy vtrack path).This change
Reverse-strand
N/*now usesget_avg_log_prob(), matching the forward branch, the already-symmetric routines (max_like_match,integrate_like_seg), and prego's copy of the shared code.Scope / caveat (please read)
This is a consistency fix with no observable behavior change for genomic scoring. In misha, a genomic
Nreaches the scorer as a masked 0-byte and the window returns-Infat theif(!(*j))guard before theN/*branch runs - verified empirically (flank windows score finitely, anyN-containing window is-Inf, on both spatial and non-spatial paths). So:N-window is always-Inf); correctness of the branch itself is covered by the prego test, which exercises the identical logic through an unmasked path.The value is keeping the two near-identical
DnaPSSM.cppcopies from drifting, and correctness for the*wildcard / any future path that scores ambiguous bases without masking.Left as-is (different, out-of-scope asymmetries):
integrate_like/update_like_vec(forwardlog(0.25), reverseavg);like_thresh_matchis intentionally symmetric onlog(0.25).https://claude.ai/code/session_01PK3qefBGDoBwd9w5226FEq