use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendGermline method reduce.
@NotNull
private static CombinedRegion reduce(@NotNull final CombinedRegion parent, long start, long end) {
assert (start >= parent.start());
assert (end <= parent.end());
int bafCount = 0;
int observedTumorRatioCount = 0;
for (FittedRegion fittedRegion : parent.regions()) {
if (fittedRegion.start() >= start && fittedRegion.end() <= end) {
bafCount += fittedRegion.bafCount();
observedTumorRatioCount += fittedRegion.observedTumorRatioCount();
}
}
final ModifiableFittedRegion smallerRegion = ModifiableFittedRegion.create().from(parent.region()).setStart(start).setEnd(end).setBafCount(bafCount).setObservedTumorRatioCount(observedTumorRatioCount);
CombinedRegion result = new CombinedRegion(parent.isBafWeighted(), smallerRegion);
result.setCopyNumberMethod(parent.copyNumberMethod());
for (FittedRegion fittedRegion : parent.regions()) {
if (fittedRegion.start() >= start && fittedRegion.end() <= end) {
result.extend(fittedRegion);
}
}
return result;
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendGermline method extractChildren.
@NotNull
private List<CombinedRegion> extractChildren(@NotNull final EnumSet<GermlineStatus> eligibleStatus, @NotNull final CombinedRegion parent, @Nullable final CombinedRegion neighbour) {
final List<CombinedRegion> children = Lists.newArrayList();
double baf = parent.tumorBAF();
double copyNumber = parent.tumorCopyNumber();
for (int i = 0; i < parent.regions().size(); i++) {
final FittedRegion child = parent.regions().get(i);
final FittedRegion next = i + 1 == parent.regions().size() ? (neighbour == null ? null : neighbour.regions().get(0)) : parent.regions().get(i + 1);
if (eligibleStatus.contains(child.status())) {
if (child.status().equals(GermlineStatus.AMPLIFICATION)) {
final double lowerBound = lowerBound(child);
if (isValidAmplification(copyNumber, lowerBound, child, next)) {
children.add(createChild(child, lowerBound, baf));
}
}
if (child.status().equals(GermlineStatus.HET_DELETION)) {
final double upperBound = upperBound(child);
if (Doubles.lessThan(upperBound, Math.min(0.5, copyNumber))) {
children.add(createChild(child, upperBound, baf));
}
}
if (child.status().equals(GermlineStatus.HOM_DELETION)) {
children.add(createChild(child, child.refNormalisedCopyNumber(), baf));
}
}
}
return extendRight(children);
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendDiploid method pushThroughDubiousRegion.
private boolean pushThroughDubiousRegion(int minTumorCount, @NotNull final List<CombinedRegion> regions, @NotNull final Direction direction, int targetIndex) {
int dubiousCount = 0;
final CombinedRegion target = regions.get(targetIndex);
for (int i = direction.moveIndex(targetIndex); i >= 0 && i < regions.size(); i = direction.moveIndex(i)) {
final FittedRegion neighbour = regions.get(i).region();
// JOBA: Coming from left to right, EXCLUDE neighbour from decision on break.
if (neighbour.start() > target.start()) {
if (neighbour.support() == SegmentSupport.CENTROMERE) {
return dubiousCount < minTumorCount;
}
if (neighbour.support().isSV()) {
return false;
}
}
if (isDubious(neighbour)) {
dubiousCount += neighbour.observedTumorRatioCount();
if (dubiousCount >= minTumorCount) {
return false;
}
}
if (isValid(neighbour)) {
return inTolerance(target.region(), neighbour);
}
// JOBA: Coming from right to left, INCLUDE neighbour from decision on break.
if (neighbour.start() < target.start()) {
if (neighbour.support() == SegmentSupport.CENTROMERE) {
return dubiousCount < minTumorCount;
}
if (neighbour.support().isSV()) {
return false;
}
}
}
return dubiousCount < minTumorCount;
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class ExtendDiploid method extendDiploid.
@NotNull
List<CombinedRegion> extendDiploid(@NotNull final Collection<FittedRegion> fittedRegions) {
final boolean bafWeighted = fittedRegions.stream().anyMatch(x -> x.bafCount() >= MIN_BAF_COUNT_TO_WEIGH_WITH_BAF);
final List<CombinedRegion> regions = Lists.newLinkedList();
for (FittedRegion fittedRegion : fittedRegions) {
regions.add(new CombinedRegion(bafWeighted, fittedRegion));
}
int highestConfidenceIndex = nextIndex(regions);
while (highestConfidenceIndex > -1) {
final CombinedRegion highestConfidence = regions.get(highestConfidenceIndex);
highestConfidence.setCopyNumberMethod(CopyNumberMethod.BAF_WEIGHTED);
LOGGER.debug("Selected region {}", toString(highestConfidence.region()));
extendRight(regions, highestConfidenceIndex);
extendLeft(regions, highestConfidenceIndex);
LOGGER.debug("Completed region {}", toString(highestConfidence.region()));
highestConfidenceIndex = nextIndex(regions);
}
return regions;
}
use of com.hartwig.hmftools.common.purple.region.FittedRegion in project hmftools by hartwigmedical.
the class StructuralVariantImpliedTest method copyNumber.
@NotNull
private static CombinedRegion copyNumber(long start, long end, double copyNumber, SegmentSupport support) {
final FittedRegion region = PurpleDatamodelTest.createDefaultFittedRegion(CHROMOSOME, start, end).tumorCopyNumber(copyNumber).tumorBAF(0.5).support(support).build();
final CombinedRegion result = new CombinedRegion(true, region);
if (Doubles.positive(copyNumber)) {
result.setCopyNumberMethod(CopyNumberMethod.BAF_WEIGHTED);
}
return result;
}
Aggregations