Search in sources :

Example 6 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class StructuralVariantPloidyFactoryTest method testBothLegsValid.

@Test
public void testBothLegsValid() {
    final StructuralVariantLeg start = createLeg(1001, 1, 0.25);
    final StructuralVariantLeg end = createLeg(2001, -1, 0.25);
    final PurpleCopyNumber left = copyNumber(1, 1000, 4);
    final PurpleCopyNumber middle = copyNumber(1001, 2000, 3);
    final PurpleCopyNumber right = copyNumber(2001, 3000, 4);
    final StructuralVariantLegs legs = ImmutableStructuralVariantLegs.builder().start(start).end(end).build();
    final ListMultimap<String, PurpleCopyNumber> copyNumbers = copyNumbers(left, middle, right);
    final List<StructuralVariantLegPloidy> ploidies = PURE_PLOIDY_FACTORY.create(legs, copyNumbers);
    assertEquals(2, ploidies.size());
    for (StructuralVariantLegPloidy ploidy : ploidies) {
        assertEquals(1d, ploidy.averageImpliedPloidy(), EPSILON);
        assertEquals(2d, ploidy.weight(), EPSILON);
    }
}
Also used : StructuralVariantLeg(com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Test(org.junit.Test) PurpleDatamodelTest(com.hartwig.hmftools.common.purple.PurpleDatamodelTest)

Example 7 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class StructuralVariantPloidyFactoryTest method testExcludeInfiniteVAF.

@Test
public void testExcludeInfiniteVAF() {
    final StructuralVariantLeg leg = createLeg(1001, -1, 1);
    final PurpleCopyNumber left = copyNumber(1, 1000, 3);
    assertFalse(PURE_PLOIDY_FACTORY.create(leg, GenomeRegionSelectorFactory.create(singleton(left))).isPresent());
}
Also used : StructuralVariantLeg(com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Test(org.junit.Test) PurpleDatamodelTest(com.hartwig.hmftools.common.purple.PurpleDatamodelTest)

Example 8 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class StructuralVariantPloidyFactoryTest method testSelectCorrectOrAlternativeCopyNumberForLeg.

@Test
public void testSelectCorrectOrAlternativeCopyNumberForLeg() {
    final StructuralVariantLeg positiveLeg = createLeg(1001, 1, 0.25);
    final StructuralVariantLeg negativeLeg = createLeg(2001, -1, 0.25);
    final PurpleCopyNumber left = copyNumber(1, 1000, 4);
    final PurpleCopyNumber middle = copyNumber(1001, 2000, 3);
    final PurpleCopyNumber right = copyNumber(2001, 3000, 4);
    assertPloidy(1, false, PURE_PLOIDY_FACTORY.create(positiveLeg, GenomeRegionSelectorFactory.create(singleton(left))));
    assertPloidy(1, true, PURE_PLOIDY_FACTORY.create(positiveLeg, GenomeRegionSelectorFactory.create(singleton(middle))));
    assertPloidy(1, true, PURE_PLOIDY_FACTORY.create(negativeLeg, GenomeRegionSelectorFactory.create(singleton(middle))));
    assertPloidy(1, false, PURE_PLOIDY_FACTORY.create(negativeLeg, GenomeRegionSelectorFactory.create(singleton(right))));
}
Also used : StructuralVariantLeg(com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Test(org.junit.Test) PurpleDatamodelTest(com.hartwig.hmftools.common.purple.PurpleDatamodelTest)

Example 9 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class EnrichedStructuralVariantFactory method enrich.

@NotNull
public static List<EnrichedStructuralVariant> enrich(@NotNull final List<StructuralVariant> variants, @NotNull final PurityAdjuster purityAdjuster, @NotNull final Multimap<String, PurpleCopyNumber> copyNumbers) {
    final StructuralVariantLegPloidyFactory<PurpleCopyNumber> ploidyFactory = new StructuralVariantLegPloidyFactory<>(purityAdjuster, PurpleCopyNumber::averageTumorCopyNumber);
    final List<EnrichedStructuralVariant> result = Lists.newArrayList();
    for (final StructuralVariant variant : variants) {
        final ImmutableEnrichedStructuralVariant.Builder builder = ImmutableEnrichedStructuralVariant.builder().from(variant);
        final ImmutableEnrichedStructuralVariantLeg.Builder startBuilder = ImmutableEnrichedStructuralVariantLeg.builder().from(variant.start());
        final ImmutableEnrichedStructuralVariantLeg.Builder endBuilder = ImmutableEnrichedStructuralVariantLeg.builder().from(variant.end());
        final List<StructuralVariantLegPloidy> ploidies = ploidyFactory.create(variant, copyNumbers);
        if (!ploidies.isEmpty()) {
            Double roundedPloidy = round(ploidies.get(0).averageImpliedPloidy());
            builder.ploidy(roundedPloidy);
        }
        if (ploidies.size() == 2) {
            final StructuralVariantLegPloidy start = ploidies.get(0);
            final StructuralVariantLegPloidy end = ploidies.get(1);
            startBuilder.adjustedAlleleFrequency(round(adjustedVAF(purityAdjuster, start)));
            startBuilder.adjustedCopyNumber(round(adjustedCopyNumber(start)));
            startBuilder.adjustedCopyNumberChange(round(adjustedCopyNumberChange(start)));
            endBuilder.adjustedAlleleFrequency(round(adjustedVAF(purityAdjuster, end)));
            endBuilder.adjustedCopyNumber(round(adjustedCopyNumber(end)));
            endBuilder.adjustedCopyNumberChange(round(adjustedCopyNumberChange(end)));
        }
        result.add(builder.start(startBuilder.build()).end(endBuilder.build()).build());
    }
    return result;
}
Also used : StructuralVariantLegPloidy(com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidy) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) StructuralVariantLegPloidyFactory(com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidyFactory) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class FittedPurityScoreFactory method polyclonalProportion.

public static double polyclonalProportion(@NotNull final Collection<PurpleCopyNumber> regions) {
    int polyclonalCount = 0;
    int totalCount = 0;
    for (final PurpleCopyNumber region : regions) {
        totalCount += region.bafCount();
        if (isPolyclonal(region.averageTumorCopyNumber())) {
            polyclonalCount += region.bafCount();
        }
    }
    return totalCount == 0 ? 0 : 1d * polyclonalCount / totalCount;
}
Also used : PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)

Aggregations

PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)20 NotNull (org.jetbrains.annotations.NotNull)9 PurpleDatamodelTest (com.hartwig.hmftools.common.purple.PurpleDatamodelTest)6 StructuralVariantLeg (com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg)6 Test (org.junit.Test)6 PurityAdjuster (com.hartwig.hmftools.common.purple.PurityAdjuster)5 PurityContext (com.hartwig.hmftools.common.purple.purity.PurityContext)4 ImmutablePurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.ImmutablePurpleCopyNumber)3 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)2 FittedPurity (com.hartwig.hmftools.common.purple.purity.FittedPurity)2 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)2 DatabaseAccess (com.hartwig.hmftools.patientdb.dao.DatabaseAccess)2 VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)2 CommandLine (org.apache.commons.cli.CommandLine)2 Options (org.apache.commons.cli.Options)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ProductionRunContextFactory (com.hartwig.hmftools.common.context.ProductionRunContextFactory)1 RunContext (com.hartwig.hmftools.common.context.RunContext)1 TumorLocationDoidMapping (com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping)1 Lims (com.hartwig.hmftools.common.lims.Lims)1