Search in sources :

Example 6 with PurityAdjuster

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

the class LoadStructuralVariants method enrichStructuralVariants.

@NotNull
private static List<EnrichedStructuralVariant> enrichStructuralVariants(@NotNull List<StructuralVariant> variants, @NotNull DatabaseAccess dbAccess, @NotNull String tumorSample) {
    final PurityContext purityContext = dbAccess.readPurityContext(tumorSample);
    if (purityContext == null) {
        LOGGER.warn("Unable to retrieve purple data. Enrichment may be incomplete.");
    }
    final PurityAdjuster purityAdjuster = purityContext == null ? new PurityAdjuster(Gender.FEMALE, 1, 1) : new PurityAdjuster(purityContext.gender(), purityContext.bestFit().purity(), purityContext.bestFit().normFactor());
    final List<PurpleCopyNumber> copyNumberList = dbAccess.readCopynumbers(tumorSample);
    final Multimap<String, PurpleCopyNumber> copyNumbers = Multimaps.index(copyNumberList, PurpleCopyNumber::chromosome);
    return EnrichedStructuralVariantFactory.enrich(variants, purityAdjuster, copyNumbers);
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) PurityContext(com.hartwig.hmftools.common.purple.purity.PurityContext) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with PurityAdjuster

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

the class StructuralVariantPloidyFactoryTest method testPurityAdjustedPloidy.

@Test
public void testPurityAdjustedPloidy() {
    final StructuralVariantLeg leg = createLeg(1001, 1, 0.5);
    final List<PurpleCopyNumber> copyNumbers = Lists.newArrayList(copyNumber(1, 1000, 2), copyNumber(1001, 200, 1));
    Optional<ModifiableStructuralVariantLegPloidy> purePloidy = PURE_PLOIDY_FACTORY.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
    assertPloidy(1d, purePloidy);
    final PurityAdjuster diluted = new PurityAdjuster(Gender.FEMALE, 0.8, 1);
    final StructuralVariantLegPloidyFactory<PurpleCopyNumber> dilutedFactory = new StructuralVariantLegPloidyFactory<>(diluted, PurpleCopyNumber::averageTumorCopyNumber);
    Optional<ModifiableStructuralVariantLegPloidy> dilutedPloidy = dilutedFactory.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
    assertPloidy(1.25d, dilutedPloidy);
    final PurityAdjuster male = new PurityAdjuster(Gender.MALE, 0.8, 1);
    final StructuralVariantLegPloidyFactory<PurpleCopyNumber> maleFactory = new StructuralVariantLegPloidyFactory<>(male, PurpleCopyNumber::averageTumorCopyNumber);
    Optional<ModifiableStructuralVariantLegPloidy> malePloidy = maleFactory.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
    assertPloidy(1.125d, malePloidy);
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) 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 PurityAdjuster

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

the class ClonalityTest method testClonality.

@Test
public void testClonality() {
    final String chromosome = "1";
    final PurityAdjuster purityAdjuster = new PurityAdjuster(Gender.FEMALE, 0.3, 1);
    assertEquals(Clonality.SUBCLONAL, Clonality.fromSample(purityAdjuster, chromosome, 3, create(4, 100)));
    assertEquals(Clonality.CLONAL, Clonality.fromSample(purityAdjuster, chromosome, 3, create(5, 100)));
    assertEquals(Clonality.CLONAL, Clonality.fromSample(purityAdjuster, chromosome, 3, create(60, 100)));
    assertEquals(Clonality.INCONSISTENT, Clonality.fromSample(purityAdjuster, chromosome, 3, create(61, 100)));
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) Test(org.junit.Test)

Aggregations

PurityAdjuster (com.hartwig.hmftools.common.purple.PurityAdjuster)8 PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)5 NotNull (org.jetbrains.annotations.NotNull)4 PurityContext (com.hartwig.hmftools.common.purple.purity.PurityContext)2 ImmutableVariantReport (com.hartwig.hmftools.patientreporter.variants.ImmutableVariantReport)2 VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)2 Test (org.junit.Test)2 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)1 ImmutableGeneCopyNumber (com.hartwig.hmftools.common.gene.ImmutableGeneCopyNumber)1 PurpleDatamodelTest (com.hartwig.hmftools.common.purple.PurpleDatamodelTest)1 FittedPurity (com.hartwig.hmftools.common.purple.purity.FittedPurity)1 ImmutableFittedPurity (com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurity)1 FittedRegion (com.hartwig.hmftools.common.purple.region.FittedRegion)1 GenomeRegion (com.hartwig.hmftools.common.region.GenomeRegion)1 ClonalityFactory (com.hartwig.hmftools.common.variant.ClonalityFactory)1 EnrichedSomaticVariant (com.hartwig.hmftools.common.variant.EnrichedSomaticVariant)1 EnrichedSomaticVariantFactory (com.hartwig.hmftools.common.variant.EnrichedSomaticVariantFactory)1 PurityAdjustedSomaticVariant (com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariant)1 PurityAdjustedSomaticVariantFactory (com.hartwig.hmftools.common.variant.PurityAdjustedSomaticVariantFactory)1 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)1