Search in sources :

Example 1 with AmberBAF

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;
}
Also used : CobaltRatio(com.hartwig.hmftools.common.cobalt.CobaltRatio) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) PurpleSegment(com.hartwig.hmftools.common.purple.segment.PurpleSegment) GCProfile(com.hartwig.hmftools.common.gc.GCProfile) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with AmberBAF

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;
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) ImmutableAmberBAF(com.hartwig.hmftools.common.amber.ImmutableAmberBAF) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with AmberBAF

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());
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Example 4 with AmberBAF

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());
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Example 5 with AmberBAF

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);
}
Also used : Pileup(com.hartwig.hmftools.common.pileup.Pileup) AmberBAF(com.hartwig.hmftools.common.amber.AmberBAF) Test(org.junit.Test)

Aggregations

AmberBAF (com.hartwig.hmftools.common.amber.AmberBAF)6 Pileup (com.hartwig.hmftools.common.pileup.Pileup)5 Test (org.junit.Test)4 NotNull (org.jetbrains.annotations.NotNull)2 ImmutableAmberBAF (com.hartwig.hmftools.common.amber.ImmutableAmberBAF)1 CobaltRatio (com.hartwig.hmftools.common.cobalt.CobaltRatio)1 GCProfile (com.hartwig.hmftools.common.gc.GCProfile)1 PurpleSegment (com.hartwig.hmftools.common.purple.segment.PurpleSegment)1