use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendDiploidTest method testTooBigTowardsCentromere.
@Test
public void testTooBigTowardsCentromere() {
final FittedRegion somaticLeft = createValidSomatic(1, 10000, 3.0, 50, SegmentSupport.BND);
final FittedRegion dubious1 = createDubiousRegion(10001, 11000, 2.0, 21);
final FittedRegion dubious2 = createDubiousRegion(11001, 12000, 2.0, 21);
final FittedRegion dubious3 = createDubiousRegion(12001, 20000, 2.0, 21);
final FittedRegion somaticRight = createValidSomatic(20001, 30000, 3.0, 40, SegmentSupport.CENTROMERE);
final List<CombinedRegion> result = PURE_VICTIM.extendDiploid(Lists.newArrayList(somaticLeft, dubious1, dubious2, dubious3, somaticRight));
assertEquals(3, result.size());
assertRegion(1, 10000, 3, result.get(0));
assertRegion(10001, 20000, 2, result.get(1));
assertRegion(20001, 30000, 3, result.get(2));
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendDiploidTest method testMultipleDubiousRegionsGetIncluded.
@Test
public void testMultipleDubiousRegionsGetIncluded() {
final FittedRegion somaticLeft = createValidSomatic(1, 10000, 3.0, 50, SegmentSupport.BND);
final FittedRegion dubious1 = createDubiousRegion(10001, 11000, 2.0, 20);
final FittedRegion dubious2 = createDubiousRegion(11001, 12000, 2.0, 9);
final FittedRegion dubious3 = createDubiousRegion(12001, 20000, 2.0, 20);
final FittedRegion somaticRight = createValidSomatic(20001, 30000, 3.0, 40, SegmentSupport.NONE);
final List<CombinedRegion> result = PURE_VICTIM.extendDiploid(Lists.newArrayList(somaticLeft, dubious1, dubious2, dubious3, somaticRight));
assertEquals(1, result.size());
assertRegion(1, 30000, 3, result.get(0));
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion 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();
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendDiploid method merge.
private boolean merge(@NotNull final List<CombinedRegion> regions, @NotNull final Direction direction, int targetIndex) {
final CombinedRegion target = regions.get(targetIndex);
final FittedRegion neighbour = regions.get(direction.moveIndex(targetIndex)).region();
if (Extend.doNotExtend(target, neighbour)) {
return false;
}
final boolean isNeighbourDubious = isDubious(neighbour);
if (isNeighbourDubious) {
int minTumorCount = nextBigBreakIsCentromereOrTelomere(regions, direction, targetIndex) ? minTumorCountAtCentromere : this.minTumorCount;
if (inTolerance(target.region(), neighbour)) {
target.extendWithBAFWeightedAverage(neighbour);
return true;
} else if (pushThroughDubiousRegion(minTumorCount, regions, direction, targetIndex)) {
target.extend(neighbour);
return true;
} else {
return false;
}
}
final boolean isNeighbourValid = isValid(neighbour);
if (!isNeighbourValid) {
target.extend(neighbour);
return true;
} else if (inTolerance(target.region(), neighbour)) {
target.extendWithBAFWeightedAverage(neighbour);
return true;
}
return false;
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendDiploid method nextIndex.
private static int nextIndex(@NotNull final List<CombinedRegion> regions) {
int indexOfLargestBaf = -1;
int indexOfLargestLength = -1;
int indexOfTumorRatioCount = -1;
int largestBAFCount = 0;
long largestBases = 0;
long largestTumorRatioCount = 0;
for (int i = 0; i < regions.size(); i++) {
final CombinedRegion combined = regions.get(i);
final FittedRegion region = combined.region();
if (!combined.isProcessed() && region.status().equals(GermlineStatus.DIPLOID)) {
if (region.bafCount() > largestBAFCount) {
largestBAFCount = region.bafCount();
indexOfLargestBaf = i;
}
if (region.observedTumorRatioCount() > largestTumorRatioCount) {
largestTumorRatioCount = region.observedTumorRatioCount();
indexOfTumorRatioCount = i;
}
if (region.bases() > largestBases) {
largestBases = region.bases();
indexOfLargestLength = i;
}
}
}
return indexOfLargestBaf > -1 ? indexOfLargestBaf : (indexOfTumorRatioCount > -1 ? indexOfTumorRatioCount : indexOfLargestLength);
}
Aggregations