InheritanceModeAnnotator { public Map<SubModeOfInheritance, List<VariantEvaluation>> computeCompatibleInheritanceSubModes(List<VariantEvaluation> variantEvaluations) { List<GenotypeCalls> genotypeCalls = buildGenotypeCalls(variantEvaluations); try { Map<SubModeOfInheritance, ImmutableList<GenotypeCalls>> compatibilityCalls = mendelChecker.checkMendelianInheritanceSub(genotypeCalls); logger.debug("{}", compatibilityCalls); return variantsGroupedByCompatibleSubMode(compatibilityCalls); } catch (IncompatiblePedigreeException e) { logger.error("Problem with annotating VariantContext for Mendelian inheritance.", e); } return Collections.emptyMap(); } InheritanceModeAnnotator(Pedigree pedigree, InheritanceModeOptions inheritanceModeOptions); Pedigree getPedigree(); InheritanceModeOptions getInheritanceModeOptions(); Set<ModeOfInheritance> getDefinedModes(); Map<ModeOfInheritance, List<VariantEvaluation>> computeCompatibleInheritanceModes(List<VariantEvaluation> variantEvaluations); Map<SubModeOfInheritance, List<VariantEvaluation>> computeCompatibleInheritanceSubModes(List<VariantEvaluation> variantEvaluations);  }
@Test public void testCompHetAutosomalRecessiveIndividualSubModes() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildUnPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); Pedigree pedigree = singleAffectedSample("Cain"); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.defaults()); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<SubModeOfInheritance, List<VariantEvaluation>> expected = ImmutableMap.of( SubModeOfInheritance.AUTOSOMAL_DOMINANT, ImmutableList.of(alleleOne, alleleTwo), SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, ImmutableList.of(alleleOne, alleleTwo) ); assertThat(results, equalTo(expected)); }
@Test public void testCompHetAutosomalRecessiveFamily() { List<Allele> alleles = buildAlleles("A", "T"); Genotype proband = buildUnPhasedSampleGenotype("Cain", alleles.get(0), alleles.get(1)); Genotype brother = buildUnPhasedSampleGenotype("Abel", alleles.get(0), alleles.get(0)); Genotype mother = buildUnPhasedSampleGenotype("Eve", alleles.get(0), alleles.get(1)); Genotype father = buildUnPhasedSampleGenotype("Adam", alleles.get(0), alleles.get(0)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband, brother, mother, father); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); List<Allele> alleles2 = buildAlleles("A", "C"); Genotype proband2 = buildUnPhasedSampleGenotype("Cain", alleles2.get(0), alleles2.get(1)); Genotype brother2 = buildUnPhasedSampleGenotype("Abel", alleles2.get(0), alleles2.get(1)); Genotype mother2 = buildUnPhasedSampleGenotype("Eve", alleles2.get(0), alleles2.get(0)); Genotype father2 = buildUnPhasedSampleGenotype("Adam", alleles2.get(0), alleles2.get(1)); VariantContext variantContext2 = buildVariantContext(1, 12355, alleles2, proband2, brother2, mother2, father2); VariantEvaluation alleleTwo = filteredVariant(1, 12355, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext2); Individual probandIndividual = Individual.builder().id("Cain").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.AFFECTED).build(); Individual brotherIndividual = Individual.builder().id("Abel").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Individual motherIndividual = Individual.builder().id("Eve").fatherId("").motherId("").sex(Sex.FEMALE).status(Status.UNAFFECTED).build(); Individual fatherIndividual = Individual.builder().id("Adam").fatherId("").motherId("").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Pedigree pedigree = Pedigree.of(probandIndividual, motherIndividual, fatherIndividual, brotherIndividual); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.defaults()); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<SubModeOfInheritance, Set<VariantEvaluation>> expected = ImmutableMap.of( SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, ImmutableSet.of(alleleOne, alleleTwo) ); for (Map.Entry<SubModeOfInheritance, Set<VariantEvaluation>> entry : expected.entrySet()) { assertThat(expected.keySet().contains(entry.getKey()), is(true)); List<VariantEvaluation> resultValue = results.get(entry.getKey()); assertThat(entry.getValue(), equalTo(new HashSet<>(resultValue))); } }
@Disabled @Test public void testCompHetAutosomalRecessiveFamilyTwoAlts() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildUnPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); Genotype brother = buildUnPhasedSampleGenotype("Abel", alleles.get(0), alleles.get(2)); Genotype mother = buildUnPhasedSampleGenotype("Eve", alleles.get(0), alleles.get(1)); Genotype father = buildUnPhasedSampleGenotype("Adam", alleles.get(0), alleles.get(2)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband, brother, mother, father); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); Individual probandIndividual = Individual.builder().id("Cain").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.AFFECTED).build(); Individual brotherIndividual = Individual.builder().id("Abel").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Individual motherIndividual = Individual.builder().id("Eve").fatherId("").motherId("").sex(Sex.FEMALE).status(Status.UNAFFECTED).build(); Individual fatherIndividual = Individual.builder().id("Adam").fatherId("").motherId("").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Pedigree pedigree = Pedigree.of(probandIndividual, motherIndividual, fatherIndividual, brotherIndividual); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.defaults()); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<SubModeOfInheritance, List<VariantEvaluation>> expected = ImmutableMap.of( SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, ImmutableList.of(alleleOne, alleleTwo) ); assertThat(results, equalTo(expected)); }
@Disabled @Test public void testAutosomalDominantHetAltFamily() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); Genotype brother = buildPhasedSampleGenotype("Abel", alleles.get(1), alleles.get(1)); Genotype mother = buildPhasedSampleGenotype("Eve", alleles.get(0), alleles.get(1)); Genotype father = buildPhasedSampleGenotype("Adam", alleles.get(0), alleles.get(1)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband, brother, mother, father); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.fail(FilterType.FREQUENCY_FILTER), variantContext); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); Individual probandIndividual = Individual.builder().id("Cain").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.AFFECTED).build(); Individual brotherIndividual = Individual.builder().id("Abel").fatherId("Adam").motherId("Eve").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Individual motherIndividual = Individual.builder().id("Eve").fatherId("").motherId("").sex(Sex.FEMALE).status(Status.UNAFFECTED).build(); Individual fatherIndividual = Individual.builder().id("Adam").fatherId("").motherId("").sex(Sex.MALE).status(Status.UNAFFECTED).build(); Pedigree pedigree = Pedigree.of(probandIndividual, motherIndividual, fatherIndividual, brotherIndividual); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.defaults()); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<ModeOfInheritance, List<VariantEvaluation>> expected = ImmutableMap.of( ModeOfInheritance.AUTOSOMAL_DOMINANT, ImmutableList.of(alleleTwo) ); assertThat(results, equalTo(expected)); }
@Test public void testAutosomalDominantHetAltIndividual() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); Pedigree pedigree = singleAffectedSample("Cain"); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.defaults()); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<SubModeOfInheritance, List<VariantEvaluation>> expected = ImmutableMap.of( SubModeOfInheritance.AUTOSOMAL_DOMINANT, ImmutableList.of(alleleOne, alleleTwo), SubModeOfInheritance.AUTOSOMAL_RECESSIVE_COMP_HET, ImmutableList.of(alleleOne, alleleTwo) ); assertThat(results, equalTo(expected)); }
@Test public void testAutosomalDominantHetAltIndividualWithSubModeOfInheritanceFrequencies() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); float alleleOneMaxFreq = 1.0f; alleleOne.setFrequencyData(FrequencyData.of(Frequency.of(FrequencySource.LOCAL, alleleOneMaxFreq))); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); alleleTwo.setFrequencyData(FrequencyData.of(Frequency.of(FrequencySource.LOCAL, alleleOneMaxFreq / 2f))); Pedigree pedigree = singleAffectedSample("Cain"); ImmutableMap<SubModeOfInheritance, Float> maxMafMap = ImmutableMap.of( SubModeOfInheritance.AUTOSOMAL_DOMINANT, alleleOneMaxFreq - 0.1f ); InheritanceModeOptions inheritanceModeOptions = InheritanceModeOptions.of(maxMafMap); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, inheritanceModeOptions); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<SubModeOfInheritance, List<VariantEvaluation>> expected = ImmutableMap.of( SubModeOfInheritance.AUTOSOMAL_DOMINANT, ImmutableList.of(alleleTwo) ); assertThat(results, equalTo(expected)); }
@Test public void testAutosomalDominantHetAltIndividualWithEmptyMaxFrequencies() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); alleleOne.setFrequencyData(FrequencyData.of(Frequency.of(FrequencySource.LOCAL, 1f))); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); Pedigree pedigree = singleAffectedSample("Cain"); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.empty()); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); assertThat(results.isEmpty(), equalTo(true)); }
@Test public void testAutosomalDominantHetAltIndividualWithJustAnyMaxFrequencies() { List<Allele> alleles = buildAlleles("A", "T", "C"); Genotype proband = buildPhasedSampleGenotype("Cain", alleles.get(1), alleles.get(2)); VariantContext variantContext = buildVariantContext(1, 12345, alleles, proband); VariantEvaluation alleleOne = filteredVariant(1, 12345, "A", "T", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); alleleOne.setFrequencyData(FrequencyData.of(Frequency.of(FrequencySource.LOCAL, 1f))); VariantEvaluation alleleTwo = filteredVariant(1, 12345, "A", "C", FilterResult.pass(FilterType.FREQUENCY_FILTER), variantContext); Pedigree pedigree = singleAffectedSample("Cain"); ImmutableMap<SubModeOfInheritance, Float> modeMaxMafs = ImmutableMap.of(SubModeOfInheritance.ANY, 2.0f); InheritanceModeAnnotator instance = new InheritanceModeAnnotator(pedigree, InheritanceModeOptions.of(modeMaxMafs)); Map<SubModeOfInheritance, List<VariantEvaluation>> results = instance.computeCompatibleInheritanceSubModes(ImmutableList.of(alleleOne, alleleTwo)); Map<SubModeOfInheritance, List<VariantEvaluation>> expected = ImmutableMap.of( SubModeOfInheritance.ANY, ImmutableList.of(alleleOne, alleleTwo) ); assertThat(results, equalTo(expected)); }