use of com.hartwig.hmftools.common.amber.AmberBAF in project hmftools by hartwigmedical.
the class ObservedRegionFactory method combine.
@NotNull
public List<ObservedRegion> combine(@NotNull final List<PurpleSegment> regions, @NotNull final Multimap<String, AmberBAF> bafs, @NotNull final Multimap<String, CobaltRatio> ratios, @NotNull final Multimap<String, GCProfile> gcProfiles) {
final List<ObservedRegion> result = Lists.newArrayList();
final GenomePositionSelector<CobaltRatio> cobaltSelector = GenomePositionSelectorFactory.create(ratios);
final GenomePositionSelector<AmberBAF> bafSelector = GenomePositionSelectorFactory.create(bafs);
final GenomeRegionSelector<GCProfile> gcSelector = GenomeRegionSelectorFactory.create(gcProfiles);
for (final PurpleSegment region : regions) {
final BAFAccumulator baf = new BAFAccumulator();
final CobaltAccumulator cobalt = new CobaltAccumulator(windowSize, region);
final GCAccumulator gc = new GCAccumulator(region);
bafSelector.select(region, baf);
cobaltSelector.select(region, cobalt);
gcSelector.select(region, gc);
double tumorRatio = cobalt.tumorMeanRatio();
double normalRatio = cobalt.referenceMeanRatio();
final EnrichedRegion copyNumber = ImmutableEnrichedRegion.builder().from(region).bafCount(baf.count()).observedBAF(baf.medianBaf()).observedTumorRatio(tumorRatio).observedNormalRatio(normalRatio).ratioSupport(region.ratioSupport()).support(region.support()).observedTumorRatioCount(cobalt.tumorCount()).gcContent(gc.averageGCContent()).status(statusFactory.status(region, normalRatio, tumorRatio)).svCluster(region.svCluster()).build();
result.add(copyNumber);
}
return result;
}
use of com.hartwig.hmftools.common.amber.AmberBAF in project hmftools by hartwigmedical.
the class BAFFactory method create.
@NotNull
List<AmberBAF> create(@NotNull final List<Pileup> normalPileup, @NotNull final List<Pileup> tumorPileup) {
final GenomePositionSelector<Pileup> tumorSelector = GenomePositionSelectorFactory.create(tumorPileup);
int medianDepth = medianReadCount(normalPileup);
int minDepth = (int) Math.round(medianDepth * minDepthPercentage);
int maxDepth = (int) Math.round(medianDepth * maxDepthPercentage);
final List<AmberBAF> result = Lists.newArrayList();
for (Pileup normal : normalPileup) {
final int readCount = normal.readCount();
final int altCount = maxMismatchReadCount(normal);
if (isValidPileup(normal) && between(readCount, minDepth, maxDepth) && isHeterozygousRef(normal.referenceCount(), readCount) && isHeterozygousAlt(altCount, readCount)) {
final Character alt = alt(altCount, normal);
tumorSelector.select(normal).filter(BAFFactory::isValidPileup).map(x -> create(alt, normal, x)).filter(BAFFactory::isValidBAF).ifPresent(result::add);
}
}
return result;
}
use of com.hartwig.hmftools.common.amber.AmberBAF in project hmftools by hartwigmedical.
the class BAFFactoryTest method testNoTumorReadCount.
@Test
public void testNoTumorReadCount() {
final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t0\t*\t*");
final List<AmberBAF> result = VICTIM.create(Collections.singletonList(GOOD_NORMAL), Collections.singletonList(tumor));
assertEquals(0, result.size());
}
use of com.hartwig.hmftools.common.amber.AmberBAF in project hmftools by hartwigmedical.
the class BAFFactoryTest method testDepths.
@Test
public void testDepths() {
final Pileup normal = PileupFile.fromString("seq2\t156\tA\t11\t.$......+2AG.+2AG.+2AGGG\t<975;:<<<<<");
final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t31\t.$......+2AG.+2AG.+2AGGG\t<975;:<<<<<");
assertNotEquals(normal.readCount(), tumor.readCount());
final AmberBAF victim = BAFFactory.create('A', normal, tumor);
assertEquals(normal.readCount(), victim.normalDepth());
assertEquals(tumor.readCount(), victim.tumorDepth());
}
use of com.hartwig.hmftools.common.amber.AmberBAF in project hmftools by hartwigmedical.
the class BAFFactoryTest method testWorking.
@Test
public void testWorking() {
final Pileup tumor = PileupFile.fromString("seq2\t156\tA\t10\t.GGGGGGGGG\t<975;:<<<<<");
final List<AmberBAF> result = VICTIM.create(Collections.singletonList(GOOD_NORMAL), Collections.singletonList(tumor));
assertEquals(1, result.size());
AmberBAF baf = result.get(0);
assertEquals(10, baf.normalDepth());
assertEquals(0.5, baf.normalBAF(), EPSILON);
assertEquals(10, baf.tumorDepth());
assertEquals(0.9, baf.tumorBAF(), EPSILON);
}
Aggregations