-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make --indel-bias more sensitive to indels #1648
Open
pd3
wants to merge
2
commits into
develop
Choose a base branch
from
bt-1459
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
/* bam2bcf.h -- variant calling. | ||
mplp.indel_bias = 1.01; | ||
|
||
Copyright (C) 2010-2012 Broad Institute. | ||
Copyright (C) 2012-2021 Genome Research Ltd. | ||
Copyright (C) 2012-2022 Genome Research Ltd. | ||
|
||
Author: Heng Li <[email protected]> | ||
|
||
|
@@ -99,7 +100,8 @@ typedef struct __bcf_callaux_t { | |
uint16_t *bases; // 5bit: unused, 6:quality, 1:is_rev, 4:2-bit base or indel allele (index to bcf_callaux_t.indel_types) | ||
errmod_t *e; | ||
void *rghash; | ||
float indel_bias; // adjusts indel score threshold; lower => call more. | ||
float indel_bias_inverted; // adjusts indel score threshold, 1/--indel-bias, so lower => call more. | ||
int no_indelQ_tweaks; | ||
} bcf_callaux_t; | ||
|
||
// per-sample values | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* bam2bcf_indel.c -- indel caller. | ||
|
||
Copyright (C) 2010, 2011 Broad Institute. | ||
Copyright (C) 2012-2014,2016-2017, 2021 Genome Research Ltd. | ||
Copyright (C) 2012-2014,2016-2017,2021-2022 Genome Research Ltd. | ||
|
||
Author: Heng Li <[email protected]> | ||
|
||
|
@@ -540,7 +540,7 @@ static int bcf_cgp_align_score(bam_pileup1_t *p, bcf_callaux_t *bca, | |
} | ||
|
||
// used for adjusting indelQ below | ||
l = (int)(100. * sc / (qend - qbeg) + .499) * bca->indel_bias; | ||
l = (int)((100. * sc / (qend - qbeg) + .499) * bca->indel_bias_inverted); | ||
*score = sc<<8 | MIN(255, l); | ||
|
||
rep_ele *reps, *elt, *tmp; | ||
|
@@ -623,8 +623,14 @@ static int bcf_cgp_compute_indelQ(int n, int *n_plp, bam_pileup1_t **plp, | |
seqQ = est_seqQ(bca, types[sc[0]&0x3f], l_run); | ||
} | ||
tmp = sc[0]>>6 & 0xff; | ||
|
||
// Don't know how this indelQ reduction threshold of 111 was derived, | ||
// but it does not function well for longer reads that span multiple | ||
// events. | ||
// | ||
// reduce indelQ | ||
indelQ = tmp > 111? 0 : (int)((1. - tmp/111.) * indelQ + .499); | ||
if ( !bca->no_indelQ_tweaks ) | ||
indelQ = tmp > 111? 0 : (int)((1. - tmp/111.) * indelQ + .499); | ||
|
||
// Doesn't really help accuracy, but permits -h to take | ||
// affect still. | ||
|
@@ -633,7 +639,7 @@ static int bcf_cgp_compute_indelQ(int n, int *n_plp, bam_pileup1_t **plp, | |
if (seqQ > 255) seqQ = 255; | ||
p->aux = (sc[0]&0x3f)<<16 | seqQ<<8 | indelQ; // use 22 bits in total | ||
sumq[sc[0]&0x3f] += indelQ < seqQ? indelQ : seqQ; | ||
// fprintf(stderr, "pos=%d read=%d:%d name=%s call=%d indelQ=%d seqQ=%d\n", pos, s, i, bam1_qname(p->b), types[sc[0]&0x3f], indelQ, seqQ); | ||
// fprintf(stderr, " read=%d:%d name=%s call=%d indelQ=%d seqQ=%d\n", s, i, bam_get_qname(p->b), types[sc[0]&0x3f], indelQ, seqQ); | ||
} | ||
} | ||
// determine bca->indel_types[] and bca->inscns | ||
|
@@ -922,7 +928,7 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, | |
fprintf(stderr, "pos=%d type=%d read=%d:%d name=%s " | ||
"qbeg=%d tbeg=%d score=%d\n", | ||
pos, types[t], s, i, bam_get_qname(p->b), | ||
qbeg, tbeg, sc); | ||
qbeg, tbeg, score[K*n_types + t]); | ||
#endif | ||
} | ||
} | ||
|
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should describe what it's doing as well as what the overall intention is.
From what I understand (this has taken a good hour and I thought it was bugged initially):
Score is top 18-bits total score, 8 bits normalised score, 6 bits type.
So score>>6 & 0xff is normalised score.
The ?: is scaling score from score(tmp=0) down to 0 (tmp>=111). I think high score is bad, but this means high scores get mapped to 0 while low scores say as they are, which feels back to front?
Regardless, it's basically taking into account the normalised per-base score rather than the total alignment score. This is important as not all alignments are the same length and so the total score varies. (This variation is more likely on short reads than long reads, as it's much more likely you're near the end of a read when it's short)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please suggest wording you'd be happy with
That is correct.
Yes. It takes the normalized score of the best alignment, higher score means worse alignment. If it's too high (>111), the indel is considered an artefact. If lower, the indelQ is scaled linearly so that perfect alignment (score=0) leaves the indelQ untouched.