TsgDrivers { @NotNull static DriverCatalog geneDriver(@NotNull final DndsDriverGeneLikelihood likelihood, @NotNull final List<SomaticVariant> geneVariants, @NotNull final Map<VariantType, Long> standardCounts, @NotNull final Map<VariantType, Long> biallelicCounts, @Nullable GeneCopyNumber geneCopyNumber) { geneVariants.sort(new TsgImpactComparator()); final Map<DriverImpact, Long> variantCounts = DriverCatalogFactory.driverImpactCount(geneVariants); long missenseVariants = variantCounts.getOrDefault(DriverImpact.MISSENSE, 0L); long nonsenseVariants = variantCounts.getOrDefault(DriverImpact.NONSENSE, 0L); long spliceVariants = variantCounts.getOrDefault(DriverImpact.SPLICE, 0L); long inframeVariants = variantCounts.getOrDefault(DriverImpact.INFRAME, 0L); long frameshiftVariants = variantCounts.getOrDefault(DriverImpact.FRAMESHIFT, 0L); final ImmutableDriverCatalog.Builder builder = ImmutableDriverCatalog.builder() .chromosome(geneVariants.get(0).chromosome()) .chromosomeBand(geneCopyNumber == null ? Strings.EMPTY : geneCopyNumber.chromosomeBand()) .gene(likelihood.gene()) .driver(DriverType.MUTATION) .category(DriverCategory.TSG) .driverLikelihood(1) .dndsLikelihood(0.0) .missense(missenseVariants) .nonsense(nonsenseVariants) .splice(spliceVariants) .inframe(inframeVariants) .frameshift(frameshiftVariants) .biallelic(geneVariants.stream().anyMatch(SomaticVariant::biallelic)) .minCopyNumber(geneCopyNumber == null ? 0 : geneCopyNumber.minCopyNumber()) .maxCopyNumber(geneCopyNumber == null ? 0 : geneCopyNumber.maxCopyNumber()) .likelihoodMethod(LikelihoodMethod.DNDS); if (geneVariants.stream().anyMatch(SomaticVariant::isHotspot)) { return builder.likelihoodMethod(LikelihoodMethod.HOTSPOT).build(); } if (geneVariants.stream().anyMatch(x -> x.biallelic() && !DriverImpact.isMissense(x))) { return builder.likelihoodMethod(LikelihoodMethod.BIALLELIC).build(); } final DriverImpact firstImpact = DriverImpact.select(geneVariants.get(0)); final DndsDriverImpactLikelihood firstImpactLikelihood = likelihood.select(firstImpact); final long firstVariantTypeCount = variantCount(geneVariants.get(0).biallelic(), geneVariants.get(0), standardCounts, biallelicCounts); long nonBiallelicMissenseCount = standardCounts.getOrDefault(VariantType.SNP, 0L); if (geneVariants.size() == 1) { double singleHit = singleHit(firstVariantTypeCount, firstImpactLikelihood); double substituteFirst = firstImpact != DriverImpact.MISSENSE ? singleHit(nonBiallelicMissenseCount, likelihood.missense()) : singleHit; return builder.driverLikelihood(Math.max(singleHit, substituteFirst)).build(); } final DriverImpact secondImpact = DriverImpact.select(geneVariants.get(1)); final DndsDriverImpactLikelihood secondImpactLikelihood = likelihood.select(secondImpact); final long secondVariantTypeCount = variantCount(geneVariants.get(1).biallelic(), geneVariants.get(1), standardCounts, biallelicCounts); double multiHit = multiHit(firstVariantTypeCount, secondVariantTypeCount, firstImpactLikelihood, secondImpactLikelihood); double substituteFirst = firstImpact == DriverImpact.MISSENSE ? multiHit : multiHit(nonBiallelicMissenseCount, secondVariantTypeCount, likelihood.missense(), secondImpactLikelihood); double substituteSecond = secondImpact == DriverImpact.MISSENSE ? multiHit : multiHit(firstVariantTypeCount, nonBiallelicMissenseCount, firstImpactLikelihood, likelihood.missense()); double substituteBoth = firstImpact == DriverImpact.MISSENSE || secondImpact == DriverImpact.MISSENSE ? multiHit : multiHit(nonBiallelicMissenseCount, nonBiallelicMissenseCount, likelihood.missense(), likelihood.missense()); double combinedResult = Math.max(Math.max(substituteFirst, substituteSecond), substituteBoth); return builder.driverLikelihood(combinedResult).build(); } TsgDrivers(DriverGenePanel genePanel);   }
@Test public void testHotspotFirst() { Map<VariantType, Long> counts = countMap(5161, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(hotspot, biallelic, missense), counts, counts, null); assertEquals(LikelihoodMethod.HOTSPOT, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }
@Test public void testBiallelicSecond() { Map<VariantType, Long> counts = countMap(5161, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(biallelic, missense), counts, counts, null); assertEquals(LikelihoodMethod.BIALLELIC, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }
@Test public void testSingleMissense() { Map<VariantType, Long> counts = countMap(351610, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(missense), counts, counts, null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertEquals(0.33, victim.driverLikelihood(), 0.01); }
@Test public void testMultiMissense() { Map<VariantType, Long> counts = countMap(351610, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(missense, missense), counts, counts, null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertEquals(0.97, victim.driverLikelihood(), 0.01); }
@Test public void testSingleNonsense() { Map<VariantType, Long> counts = countMap(351610, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(nonsense), counts, counts, null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertEquals(0.74, victim.driverLikelihood(), 0.01); }
@Test public void testMixed() { Map<VariantType, Long> counts = countMap(351610, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(missense, nonsense), counts, counts, null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }
@Test public void testIndel() { Map<VariantType, Long> counts = countMap(351610, 10000); DriverCatalog victim = TsgDrivers.geneDriver(geneLikelihood, Lists.newArrayList(indel), counts, counts, null); assertEquals(LikelihoodMethod.DNDS, victim.likelihoodMethod()); assertEquals(1, victim.driverLikelihood(), 0.01); }