use of com.hartwig.hmftools.common.purple.region.ObservedRegion in project hmftools by hartwigmedical.
the class FittedPurityFactory method fitPurity.
private void fitPurity(@NotNull final Collection<ObservedRegion> observedRegions) throws ExecutionException, InterruptedException {
int totalBAFCount = 0;
final List<ObservedRegion> filteredRegions = Lists.newArrayList();
for (final ObservedRegion region : observedRegions) {
final Chromosome chromosome = HumanChromosome.valueOf(region);
if (region.bafCount() > 0 && positiveOrZero(region.observedTumorRatio()) && chromosome.isAutosome() && region.status() == GermlineStatus.DIPLOID && Doubles.lessOrEqual(region.observedTumorRatio(), MAX_TUMOR_RATIO_TO_FIT)) {
totalBAFCount += region.bafCount();
filteredRegions.add(region);
}
}
List<Future<List<FittedPurity>>> futures = Lists.newArrayList();
for (double purity = minPurity; lessOrEqual(purity, maxPurity); purity += purityIncrements) {
futures.add(executorService.submit(callableFitPurity(purity, totalBAFCount, filteredRegions)));
}
for (Future<List<FittedPurity>> future : futures) {
List<FittedPurity> fittedPurities = future.get();
if (!fittedPurities.isEmpty()) {
bestScoringPerPurity.add(fittedPurities.get(0));
}
}
Collections.sort(bestScoringPerPurity);
}
use of com.hartwig.hmftools.common.purple.region.ObservedRegion in project hmftools by hartwigmedical.
the class FittedPurityFactory method fitPurity.
@NotNull
private FittedPurity fitPurity(final double purity, final double normFactor, final double totalBafCount, @NotNull final Collection<ObservedRegion> observedRegions) {
ImmutableFittedPurity.Builder builder = ImmutableFittedPurity.builder().purity(purity).normFactor(normFactor);
double ploidyPenalty = 0;
double modelDeviation = 0;
double diploidProportion = 0;
double averagePloidy = 0;
for (final ObservedRegion enrichedRegion : observedRegions) {
final FittedRegion fittedRegion = fittedRegionFactory.fitRegion(purity, normFactor, enrichedRegion);
ploidyPenalty += enrichedRegion.bafCount() / totalBafCount * fittedRegion.ploidyPenalty();
modelDeviation += enrichedRegion.bafCount() / totalBafCount * fittedRegion.deviation();
averagePloidy += fittedRegion.tumorCopyNumber() * fittedRegion.bafCount() / totalBafCount;
if (fittedRegion.modelPloidy() == 2) {
diploidProportion += enrichedRegion.bafCount() / totalBafCount;
}
}
return builder.score(ploidyPenalty * modelDeviation).diploidProportion(diploidProportion).ploidy(averagePloidy).build();
}
Aggregations