fix issues with olga heavy/light correction functions - #41
Open
psathyrella wants to merge 1 commit into
Open
Conversation
three issues in correct_olga_*, all covered by tests that fail on the pre-fix source and pass after: 1. utils.py: rename the four `qm.seq_gen_model` writes to `qm.seqgen_model` (no underscore) so the rebuilt sampler reaches the attribute the samplers read. 2. utils.py: replace `[:, 1:]` / `[:, 4:]` with explicit `[:, [1, 2]]` / `[:, [4, 5]]` so the V/J unpack works when Sonia.__init__ has added a trailing `sequence_id` column. 3. sonia.py / sonia_paired.py `_save_pgen_model`: when correct_olga_* has set the new `_olga_corrected` flag, rewrite the corresponding IGoR blocks (@v_choice for VDJ; @v_choice + @j_choice for VJ) in the saved `model_marginals.txt` via a new `write_corrected_marginals` helper. Instances without the flag save byte-identically to before. Fixes statbiophys#40
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 #40.
In
correct_olga_{heavy,light,paired}, rename the fourqm.seq_gen_model(andseq_gen_model_{heavy,light}) assignmentsto match the
qm.seqgen_modelattribute the samplers actually read.See
correct_olga_{heavy,light}doesn't reach the sequence generator #40 for a reproducer showing that the pre-fix writes land on adead attribute so
qm.seqgen_model.CPVJnever picks up thecorrection.
In
correct_olga_light(andcorrect_olga_paired, light half),replace the open-ended
[:, 1:]/[:, 4:]column slice with anexplicit
[:, [1, 2]]/[:, [4, 5]]so the unpack still workswhen
Sonia.__init__has added a trailingsequence_idcolumn.Persist the correction through
save_model/load_model. Whencorrect_olga_*has been called (tracked via a newqm._olga_correctedflag),_save_pgen_modelnow writes thecorrected
@v_choice(VDJ) or@v_choice+@j_choice(VJ) IGoRblocks into the saved
model_marginals.txtinstead of copying theOLGA defaults verbatim. Instances without the flag save
byte-identically to before.
Test additions (all fail on the pre-fix source, pass after):
test_correct_olga_light_no_shape_error/test_correct_olga_paired_no_shape_error— cover the shape fix.test_correct_olga_{heavy,light}_rebuilds_seqgen_model— cover theattribute-name fix by checking
qm.seqgen_modeland itsCPVJ/CPVactually change.
test_correct_olga_light_biases_sampled_v— end-to-end check thatpost-correction sampling follows the biased V/J.
test_save_load_preserves_light_correction/test_save_load_preserves_paired_correction— round-trip viasave_model+ reload.test_save_no_correction_byte_identical— baseline guaranteeingmodels without a correction still save byte-identically to the
shipped defaults.