Search in sources :

Example 16 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class CopyNumberDAO method read.

@NotNull
public List<PurpleCopyNumber> read(@NotNull final String sample) {
    List<PurpleCopyNumber> copyNumbers = Lists.newArrayList();
    Result<Record> result = context.select().from(COPYNUMBER).where(COPYNUMBER.SAMPLEID.eq(sample)).fetch();
    for (Record record : result) {
        copyNumbers.add(ImmutablePurpleCopyNumber.builder().chromosome(record.getValue(COPYNUMBER.CHROMOSOME)).start(record.getValue(COPYNUMBER.START)).end(record.getValue(COPYNUMBER.END)).bafCount(record.getValue(COPYNUMBER.BAFCOUNT)).method(CopyNumberMethod.valueOf(record.getValue(COPYNUMBER.COPYNUMBERMETHOD))).segmentStartSupport(SegmentSupport.valueOf(record.getValue(COPYNUMBER.SEGMENTSTARTSUPPORT))).segmentEndSupport(SegmentSupport.valueOf(record.getValue(COPYNUMBER.SEGMENTENDSUPPORT))).averageActualBAF(record.getValue(COPYNUMBER.ACTUALBAF)).averageObservedBAF(record.getValue(COPYNUMBER.OBSERVEDBAF)).averageTumorCopyNumber(record.getValue(COPYNUMBER.COPYNUMBER_)).build());
    }
    Collections.sort(copyNumbers);
    return copyNumbers;
}
Also used : Record(org.jooq.Record) ImmutablePurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.ImmutablePurpleCopyNumber) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class StructuralVariantPloidyFactoryTest method testPurityAdjustedPloidy.

@Test
public void testPurityAdjustedPloidy() {
    final StructuralVariantLeg leg = createLeg(1001, 1, 0.5);
    final List<PurpleCopyNumber> copyNumbers = Lists.newArrayList(copyNumber(1, 1000, 2), copyNumber(1001, 200, 1));
    Optional<ModifiableStructuralVariantLegPloidy> purePloidy = PURE_PLOIDY_FACTORY.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
    assertPloidy(1d, purePloidy);
    final PurityAdjuster diluted = new PurityAdjuster(Gender.FEMALE, 0.8, 1);
    final StructuralVariantLegPloidyFactory<PurpleCopyNumber> dilutedFactory = new StructuralVariantLegPloidyFactory<>(diluted, PurpleCopyNumber::averageTumorCopyNumber);
    Optional<ModifiableStructuralVariantLegPloidy> dilutedPloidy = dilutedFactory.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
    assertPloidy(1.25d, dilutedPloidy);
    final PurityAdjuster male = new PurityAdjuster(Gender.MALE, 0.8, 1);
    final StructuralVariantLegPloidyFactory<PurpleCopyNumber> maleFactory = new StructuralVariantLegPloidyFactory<>(male, PurpleCopyNumber::averageTumorCopyNumber);
    Optional<ModifiableStructuralVariantLegPloidy> malePloidy = maleFactory.create(leg, GenomeRegionSelectorFactory.create(copyNumbers));
    assertPloidy(1.125d, malePloidy);
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) StructuralVariantLeg(com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Test(org.junit.Test) PurpleDatamodelTest(com.hartwig.hmftools.common.purple.PurpleDatamodelTest)

Example 18 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class StructuralVariantPloidyFactoryTest method testExcludeNegativeAndZeroCopyNumbers.

@Test
public void testExcludeNegativeAndZeroCopyNumbers() {
    final StructuralVariantLeg positiveLeg = createLeg(1001, 1, 0.25);
    final StructuralVariantLeg negativeLeg = createLeg(2001, -1, 0.25);
    final PurpleCopyNumber left = copyNumber(1, 1000, -0.01);
    final PurpleCopyNumber right = copyNumber(2001, 3000, 0);
    assertFalse(PURE_PLOIDY_FACTORY.create(positiveLeg, GenomeRegionSelectorFactory.create(singleton(left))).isPresent());
    assertFalse(PURE_PLOIDY_FACTORY.create(negativeLeg, GenomeRegionSelectorFactory.create(singleton(right))).isPresent());
}
Also used : StructuralVariantLeg(com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Test(org.junit.Test) PurpleDatamodelTest(com.hartwig.hmftools.common.purple.PurpleDatamodelTest)

Example 19 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class StructuralVariantPloidyFactoryTest method testSingleValidLeg.

@Test
public void testSingleValidLeg() {
    final StructuralVariantLeg start = createLeg(1001, 1, 0.25);
    final PurpleCopyNumber left = copyNumber(1, 1000, 4);
    final PurpleCopyNumber middle = copyNumber(1001, 2000, 3);
    final PurpleCopyNumber right = copyNumber(2001, 3000, 4);
    final StructuralVariantLegs legs = ImmutableStructuralVariantLegs.builder().start(start).end(Optional.empty()).build();
    final ListMultimap<String, PurpleCopyNumber> copyNumbers = copyNumbers(left, middle, right);
    final List<StructuralVariantLegPloidy> ploidies = PURE_PLOIDY_FACTORY.create(legs, copyNumbers);
    assertEquals(1, ploidies.size());
    for (StructuralVariantLegPloidy ploidy : ploidies) {
        assertEquals(1d, ploidy.averageImpliedPloidy(), EPSILON);
        assertEquals(1d, ploidy.weight(), EPSILON);
    }
}
Also used : StructuralVariantLeg(com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Test(org.junit.Test) PurpleDatamodelTest(com.hartwig.hmftools.common.purple.PurpleDatamodelTest)

Example 20 with PurpleCopyNumber

use of com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber in project hmftools by hartwigmedical.

the class CopyNumberDAO method writeCopyNumber.

void writeCopyNumber(@NotNull final String sample, @NotNull List<PurpleCopyNumber> copyNumbers) {
    Timestamp timestamp = new Timestamp(new Date().getTime());
    context.delete(COPYNUMBER).where(COPYNUMBER.SAMPLEID.eq(sample)).execute();
    for (List<PurpleCopyNumber> splitCopyNumbers : Iterables.partition(copyNumbers, DB_BATCH_INSERT_SIZE)) {
        InsertValuesStep12 inserter = context.insertInto(COPYNUMBER, COPYNUMBER.SAMPLEID, COPYNUMBER.CHROMOSOME, COPYNUMBER.START, COPYNUMBER.END, COPYNUMBER.COPYNUMBERMETHOD, COPYNUMBER.SEGMENTSTARTSUPPORT, COPYNUMBER.SEGMENTENDSUPPORT, COPYNUMBER.BAFCOUNT, COPYNUMBER.OBSERVEDBAF, COPYNUMBER.ACTUALBAF, COPYNUMBER.COPYNUMBER_, COPYNUMBER.MODIFIED);
        splitCopyNumbers.forEach(x -> addCopynumberRecord(timestamp, inserter, sample, x));
        inserter.execute();
    }
}
Also used : InsertValuesStep12(org.jooq.InsertValuesStep12) Timestamp(java.sql.Timestamp) ImmutablePurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.ImmutablePurpleCopyNumber) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) Date(java.util.Date)

Aggregations

PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)20 NotNull (org.jetbrains.annotations.NotNull)9 PurpleDatamodelTest (com.hartwig.hmftools.common.purple.PurpleDatamodelTest)6 StructuralVariantLeg (com.hartwig.hmftools.common.variant.structural.StructuralVariantLeg)6 Test (org.junit.Test)6 PurityAdjuster (com.hartwig.hmftools.common.purple.PurityAdjuster)5 PurityContext (com.hartwig.hmftools.common.purple.purity.PurityContext)4 ImmutablePurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.ImmutablePurpleCopyNumber)3 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)2 FittedPurity (com.hartwig.hmftools.common.purple.purity.FittedPurity)2 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)2 DatabaseAccess (com.hartwig.hmftools.patientdb.dao.DatabaseAccess)2 VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)2 CommandLine (org.apache.commons.cli.CommandLine)2 Options (org.apache.commons.cli.Options)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ProductionRunContextFactory (com.hartwig.hmftools.common.context.ProductionRunContextFactory)1 RunContext (com.hartwig.hmftools.common.context.RunContext)1 TumorLocationDoidMapping (com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping)1 Lims (com.hartwig.hmftools.common.lims.Lims)1