-
Notifications
You must be signed in to change notification settings - Fork 594
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
Bug fix in flow allele filtering #8775
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ funcotator_tmp | |
|
||
#Test generated dot files | ||
test*.dot | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
package org.broadinstitute.hellbender.tools.walkers.haplotypecaller; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import htsjdk.samtools.TextCigarCodec; | ||
import htsjdk.variant.variantcontext.Allele; | ||
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.AlleleFiltering; | ||
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.AlleleFilteringHC; | ||
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.HaplotypeCallerArgumentCollection; | ||
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.HaplotypeCallerGenotypingEngine; | ||
import org.broadinstitute.hellbender.utils.SimpleInterval; | ||
import org.broadinstitute.hellbender.utils.genotyper.*; | ||
import org.broadinstitute.hellbender.utils.haplotype.Event; | ||
import org.broadinstitute.hellbender.utils.haplotype.EventMap; | ||
import org.broadinstitute.hellbender.utils.haplotype.Haplotype; | ||
import org.broadinstitute.hellbender.utils.read.ArtificialReadUtils; | ||
|
@@ -298,5 +301,96 @@ public void testNotFilterLoneWeakAllele(){ | |
|
||
} | ||
|
||
@Test //check that we filter strong allele with high SOR | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this test might test what you want here. I would recommend adding a unit test to the AlleleFiltering.identifyBadAlleles() (made package protected and marked with @VisibleForTesting) and constructing a specific case that triggers this bug and explaining that its capturing the state where the SOR and Qual based filtering sorting are out of step and you are still fitlering appropriately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jamesemery - good idea, added test! |
||
public void testFilterDistantHindelSor() { | ||
|
||
// create haplotypes | ||
List<Haplotype> haplotypeList = new ArrayList<>(); | ||
final byte[] fullReferenceWithPadding = "CAGGCATG".getBytes(); | ||
Haplotype haplotype = new Haplotype(fullReferenceWithPadding, true, 0, TextCigarCodec.decode("8M")); | ||
haplotype.setGenomeLocation(new SimpleInterval("chr", 100, 108)); | ||
haplotype.setEventMap(EventMap.fromHaplotype(haplotype, fullReferenceWithPadding, 0)); | ||
haplotypeList.add(haplotype); | ||
|
||
haplotype = new Haplotype("CAGGCATTG".getBytes(), false, 0, TextCigarCodec.decode("7M1I1M")); | ||
haplotype.setGenomeLocation(new SimpleInterval("chr", 100, 109)); | ||
|
||
haplotype.setEventMap(EventMap.fromHaplotype(haplotype, fullReferenceWithPadding, 0)); | ||
haplotypeList.add(haplotype); | ||
haplotype = new Haplotype("CAGGCATTTG".getBytes(), false, 0, TextCigarCodec.decode("7M2I1M")); | ||
haplotype.setGenomeLocation(new SimpleInterval("chr", 100, 110)); | ||
|
||
haplotype.setEventMap(EventMap.fromHaplotype(haplotype, fullReferenceWithPadding, 0)); | ||
haplotypeList.add(haplotype); | ||
|
||
AlleleList<Haplotype> haplotypes = new IndexedAlleleList<>(haplotypeList); | ||
SampleList samples = new IndexedSampleList(Arrays.asList("sm1")); | ||
|
||
List<GATKRead> readList = new ArrayList<>(30); | ||
Map<String, List<GATKRead>> ebs = new HashMap<>(); | ||
ebs.put("sm1", readList); | ||
|
||
for (int i = 0; i < 40; i++) { | ||
readList.add(ArtificialReadUtils.createArtificialRead("20M")); | ||
} | ||
|
||
|
||
double[][] values = { | ||
{ 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, | ||
0, 3, 0, 3, 0, | ||
3 }, | ||
{ 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, 3, 0, | ||
3, 0, 3, 0, 3, | ||
0 }, | ||
{ 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0,0,10,0,0,0,10,0,0,0} | ||
}; | ||
for (int i = 0; i < 40; i++) { | ||
if (i % 4 == 0) { | ||
readList.get(i).setIsReverseStrand(true); | ||
} | ||
} | ||
|
||
AlleleLikelihoods<GATKRead, Haplotype> lks = new AlleleLikelihoods<>(samples, haplotypes, ebs); | ||
LikelihoodMatrix<GATKRead, Haplotype> lkm = lks.sampleMatrix(0); | ||
for (int i = 0; i < lks.numberOfAlleles(); i++) { | ||
for (int j = 0; j < lkm.evidenceCount(); j++) { | ||
lkm.set(i, j, values[i][j]); | ||
} | ||
} | ||
|
||
HaplotypeCallerArgumentCollection hcArgs = new HaplotypeCallerArgumentCollection(); | ||
HaplotypeCallerGenotypingEngine genotypingEngine = new HaplotypeCallerGenotypingEngine(hcArgs, samples, | ||
!hcArgs.doNotRunPhysicalPhasing, false); | ||
|
||
AlleleFiltering alleleFiltering = new AlleleFilteringHC(hcArgs, null, genotypingEngine); | ||
AlleleLikelihoods<GATKRead, Haplotype> filtered_lks = alleleFiltering.filterAlleles(lks, 0, new HashSet<>()); | ||
Assert.assertEquals(filtered_lks.alleles(), haplotypeList.subList(0, 2)); | ||
} | ||
|
||
@Test | ||
public void testIdentifyBadAlleles(){ | ||
Event a = new Event("chr1", 10, Allele.create("A",true), Allele.create("T", false)); | ||
Event b = new Event("chr1", 10, Allele.create("T",true), Allele.create("G", false)); | ||
Event c = new Event("chr1", 10, Allele.create("C", true), Allele.create("G", false)); | ||
|
||
List<Event> events = List.of(a,b,c); | ||
List<Integer> rpls = List.of(10,20,0); | ||
List<Double> sors = List.of(0.0,1.0,3.5); | ||
HaplotypeCallerGenotypingEngine ge = new HaplotypeCallerGenotypingEngine(new HaplotypeCallerArgumentCollection(), | ||
SampleList.singletonSampleList("test"), false, false); | ||
AlleleFiltering af = new AlleleFilteringHC(null, null,ge); | ||
List<Event> badAlleles = af.identifyBadAlleles(rpls, sors, events, 30, 3); | ||
Assert.assertEquals(badAlleles, List.of(b, a, c)); | ||
rpls = List.of(-100, -200, 0); | ||
sors = List.of(0.0,1.0,3.5); | ||
badAlleles = af.identifyBadAlleles(rpls, sors, events, 30, 3); | ||
Assert.assertEquals(badAlleles, List.of(c)); | ||
|
||
rpls = List.of(-100, -200, -300); | ||
sors = List.of(0.0,1.0,3.5); | ||
badAlleles = af.identifyBadAlleles(rpls, sors, events, 30, 3); | ||
Assert.assertEquals(badAlleles, List.of(c)); | ||
|
||
|
||
} | ||
} |
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.
ahh thats a nasty issue i see...