Search in sources :

Example 1 with StructuralVariantLegPloidyFactory

use of com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidyFactory 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)

Aggregations

PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)1 StructuralVariantLegPloidy (com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidy)1 StructuralVariantLegPloidyFactory (com.hartwig.hmftools.common.purple.copynumber.sv.StructuralVariantLegPloidyFactory)1 NotNull (org.jetbrains.annotations.NotNull)1