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);
}
}
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());
}
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))));
}
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;
}
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;
}
Aggregations