bamCompare: compute --operation first/second/add/mean and orient reciprocal_ratio as documented - #1458
Open
cindykrafft wants to merge 1 commit into
Open
Conversation
…procal_ratio as documented calc_ratio matched only log2, ratio, reciprocal_ratio and subtract; its catch-all arm computed the log2 ratio, so the four remaining choices the CLI offers (first, second, add, mean) wrote the log2 track. The reciprocal_ratio arm returned b/a for a/b >= 1 and -a/b otherwise, the inverse of the documented "a/b if a/b >= 1 else -b/a" that the 3.5.x getRatio implemented (2/3 became -0.67 instead of -1.5). first/second/add/mean output the scaled signals without a pseudocount, as before (the --pseudocount help: only used with log2 / ratio). The catch-all now panics on an unknown operation instead of silently computing something else. Tests: the existing test_calc_ratio expectation for reciprocal_ratio (6/22 -> -22/6 = -3.67) is corrected, two cargo tests are added, and a pytest checks all five operations on the shipped testA/testB. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44
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 #1457.
CHANGES.txtbullet onlycalc_ratio(src/calc.rs) matched onlylog2,ratio,reciprocal_ratioandsubtract; its catch-all arm computed the log2 ratio, so the four remaining--operationchoices (first,second,add,mean) wrote the log2 track. Thereciprocal_ratioarm returned b/a for a/b ≥ 1 and −a/b otherwise, the inverse of the documented "a/b if a/b ≥ 1 else −b/a" that 3.5.x'sgetRatioimplemented (2/3 became −0.67 instead of −1.5). This adds four explicit arms returning the scaled signals without a pseudocount (as before, and as the--pseudocounthelp says), swaps the tworeciprocal_ratiobranches, and makes the catch-all a panic so an unknown operation cannot produce a plausible track. Behaviour change to flag in review: the existingtest_calc_ratiopinned the inverted reciprocal value (-0.27for 6/22); it now expects −22/6 = −3.67. Not changed here, but worth a look: thesubtractarm adds both pseudocounts before subtracting (invisible at the default--pseudocount 1, a shift of p1 − p2 with two different pseudocounts; 3.5.x subtracted the scaled signals only).Tests:
test_calc_ratiocorrected,test_calc_ratio_reciprocal_ratio_sign_and_orientationandtest_calc_ratio_first_second_add_meanadded (src/tests/test_calc.rs);test_bam_compare_operations_first_second_add_mean_reciprocalchecks all five operations on the shippedtestA.bam/testB.bam. Onmasterthe pytest fails (firstwrites3R 0 50 0 | 50 100 -1 | …) and the cargo tests fail (left: -0.27, right: -3.67;left: 0.5, right: 2.0); with the patchcargo test50 passed,test_bamCoverage_and_bamCompare.py22 passed, full pytest suite 233 passed.Found in Mytochondria, a volunteer project that checks the numerical core of research software and verifies every finding by execution (methods and harnesses: https://github.com/cindykrafft/mytochondria/tree/main/audits/deeptools)
Generated by Claude Code