Conversation
TwoConditionScores.mean_from_peakcontent declared the per-interval score and its accumulator as `cython.long` after the pure-Python-mode conversion (they were `float64_t` in MACS2 2.2.9.1 and MACS3 3.0.0), so every log10 likelihood ratio was cut to its integer part before the length-weighted mean was taken. With a cutoff below 1 every score in the common file became 0 and cond1/cond2 scores could fall below the cutoff (macs3-project#715); with the default cutoff every score was biased low by up to 1. Declare both as `cython.double` again. Restores the exact scores in test/standard_results_bdgdiff. Also fix the Test_TwoConditionScores fixture, which called the removed bedGraphTrackI.safe_add_loc, and add a regression test. Fixes macs3-project#715 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44
taoliu
self-requested a review
September 18, 2026 06:57
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.
Fixes #715.
Describe the bug
macs3 bdgdiffwrites, as the score of every region in thecond1,cond2andcommonBED files, the length-weighted mean of the log10 likelihood ratios of the intervals inside the region (as documented). Since the pure-Python-mode conversion,TwoConditionScores.mean_from_peakcontentinMACS3/Signal/ScoreTrack.pydeclares the per-interval scoretmp_vand the accumulatorsum_vascython.long, so each log10LR is cut to its integer part before it is summed. In MACS2 2.2.9.1 and MACS3 3.0.0 both werefloat64_t("for better precision"); 3.0.1 through currentmainhavecython.long.Consequences, exactly as reported in #715: with a cutoff below 1 (the reporter used
-C 0.2) every score incommon.bedbecomes 0, andcond1/cond2scores can be below the cutoff; with the default-C 3every score is biased low by up to 1 (e.g. 24.9521 instead of 25.5431).To Reproduce
Four one-interval-per-region bedGraphs where the cond1 intervals have log10LR(t1 vs t2) = 0.3271 and 6.1784 (see
repro.pyin the link below):main:syn_c0.2_cond1.bedscore3.0(= (0 + 6) / 2). Fixed:3.25276(= (0.3271 + 6.1784) / 2).The project's own
test/cmdlineteststep 10 (bdgdiff on the CTCF chr22 50k test data) shows the same: onmain, 638 of 638 cond1 scores differ fromtest/standard_results_bdgdiff/run_bdgdiff_prefix_c3.0_cond1.bed(first three: 24.9521 / 36.903 / 48.8178 vs 25.5431 / 37.3104 / 49.3307). The reference files were evidently produced by a float-correct build;cmdlinetestdoes not catch this because BED files that differ are accepted when their Jaccard index is > 0.99, which ignores the score column.The fix
Declare
tmp_vandsum_vascython.doubleagain (two lines). With the fix, the bdgdiff output on the test data matchestest/standard_results_bdgdiffexactly (0 of 638 scores differ), so no reference file needs regenerating.Tests
test/test_ScoreTrack.py::Test_TwoConditionScores::test_call_peaks_score_is_mean_logLR(new): fails onmainwithAssertionError: 3.0 != 3.2527 within 3 places, passes with the fix.Test_TwoConditionScores.setUpfixture calledbedGraphTrackI.safe_add_loc, which no longer exists; it now usesadd_locso the class can hold tests again.pytest test/test_ScoreTrack.py test/test_BedGraph.py test/test_PeakIO.py: 8 passed before, 9 passed after.pytest --runxfail(excludingtest_online.py, which needs network): 102 passed, 4 skipped onmain; same plus the new test with the fix.ruff check/flake8report no findings on the changed lines (the files' pre-existing findings are unchanged).Found while working through open issues in Mytochondria, a volunteer project that verifies fixes for the software behind published results (methods and harnesses: https://github.com/cindykrafft/mytochondria/tree/main/audits/macs2)
Generated by Claude Code