Skip to content

Commit

Permalink
fix: fix bug during calculation of read position bias (#422)
Browse files Browse the repository at this point in the history
### Description

<!--Add a description of your PR here-->

### QC
<!-- Make sure that you can tick the boxes below. -->

* [x] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [x] The documentation at
https://github.com/varlociraptor/varlociraptor.github.io is updated in a
separate PR to reflect the changes or this is not necessary (e.g. if the
change does neither modify the calling grammar nor the behavior or
functionalities of Varlociraptor).
  • Loading branch information
johanneskoester committed Mar 27, 2024
1 parent 58f2924 commit 33d98b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions src/variants/evidence/observations/read_observation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,18 +516,30 @@ where
pub(crate) fn major_read_position(
pileup: &[ReadObservation<Option<u32>, ExactAltLoci>],
) -> Option<u32> {
calc_major_feature(pileup.iter().filter_map(|obs| obs.read_position))
calc_major_feature(pileup.iter().filter_map(|obs| {
if obs.prob_alt > obs.prob_ref {
obs.read_position
} else {
None
}
}))
}

pub(crate) fn major_alt_locus(
pileup: &[ReadObservation<Option<u32>, ExactAltLoci>],
alignment_properties: &AlignmentProperties,
) -> Option<genome::Locus> {
calc_major_feature(pileup.iter().flat_map(|obs| {
obs.alt_locus
calc_major_feature(
pileup
.iter()
.map(|locus| locus_to_bucket(locus, alignment_properties))
}))
// TODO filter for alt obs only?
//.filter(|obs| obs.prob_alt > obs.prob_ref)
.flat_map(|obs| {
obs.alt_locus
.iter()
.map(|locus| locus_to_bucket(locus, alignment_properties))
}),
)
}

pub(crate) fn locus_to_bucket(
Expand Down
2 changes: 1 addition & 1 deletion src/variants/model/bias/alt_locus_bias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Bias for AltLocusBias {
fn prob_ref(&self, observation: &ProcessedReadObservation) -> LogProb {
// METHOD: ref reads should not point to the alt locus. The reason is that in that case,
// the homology does not appear to be variant specific, and hence the normal MAPQs
// should be able to capure it.
// should be able to capture it.
match (self, observation.is_max_mapq, observation.alt_locus) {
(AltLocusBias::None, _, _) => *PROB_05, // normal
(AltLocusBias::Some, true, AltLocus::Some | AltLocus::None) => LogProb::ln_one(), // no bias
Expand Down

0 comments on commit 33d98b6

Please sign in to comment.