Search in sources :

Example 1 with FittedPurityScore

use of com.hartwig.hmftools.common.purple.purity.FittedPurityScore in project hmftools by hartwigmedical.

the class PurityDAO method write.

void write(@NotNull final String sample, @NotNull final PurityContext purity, @NotNull final PurpleQC checks) {
    final FittedPurity bestFit = purity.bestFit();
    final FittedPurityScore score = purity.score();
    Timestamp timestamp = new Timestamp(new Date().getTime());
    context.delete(PURITY).where(PURITY.SAMPLEID.eq(sample)).execute();
    context.insertInto(PURITY, PURITY.VERSION, PURITY.SAMPLEID, PURITY.PURITY_, PURITY.GENDER, PURITY.STATUS, PURITY.QCSTATUS, PURITY.NORMFACTOR, PURITY.SCORE, PURITY.PLOIDY, PURITY.DIPLOIDPROPORTION, PURITY.MINDIPLOIDPROPORTION, PURITY.MAXDIPLOIDPROPORTION, PURITY.MINPURITY, PURITY.MAXPURITY, PURITY.MINPLOIDY, PURITY.MAXPLOIDY, PURITY.POLYCLONALPROPORTION, PURITY.MODIFIED).values(purity.version(), sample, bestFit.purity(), purity.gender().toString(), purity.status().toString(), checks.status().toString(), bestFit.normFactor(), bestFit.score(), bestFit.ploidy(), bestFit.diploidProportion(), score.minDiploidProportion(), score.maxDiploidProportion(), score.minPurity(), score.maxPurity(), score.minPloidy(), score.maxPloidy(), purity.polyClonalProportion(), timestamp).execute();
}
Also used : ImmutableFittedPurity(com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurity) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) FittedPurityScore(com.hartwig.hmftools.common.purple.purity.FittedPurityScore) ImmutableFittedPurityScore(com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurityScore) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 2 with FittedPurityScore

use of com.hartwig.hmftools.common.purple.purity.FittedPurityScore in project hmftools by hartwigmedical.

the class PurityDAO method readPurityContext.

@Nullable
PurityContext readPurityContext(@NotNull final String sample) {
    @Nullable Record result = context.select().from(PURITY).where(PURITY.SAMPLEID.eq(sample)).fetchOne();
    if (result == null) {
        return null;
    }
    final FittedPurity purity = ImmutableFittedPurity.builder().purity(result.getValue(PURITY.PURITY_)).normFactor(result.getValue(PURITY.NORMFACTOR)).score(result.getValue(PURITY.SCORE)).diploidProportion(result.getValue(PURITY.DIPLOIDPROPORTION)).ploidy(result.getValue(PURITY.PLOIDY)).build();
    final FittedPurityScore score = ImmutableFittedPurityScore.builder().minPurity(result.getValue(PURITY.MINPURITY)).maxPurity(result.getValue(PURITY.MAXPURITY)).minPloidy(result.getValue(PURITY.MINPLOIDY)).maxPloidy(result.getValue(PURITY.MAXPLOIDY)).minDiploidProportion(result.getValue(PURITY.MINDIPLOIDPROPORTION)).maxDiploidProportion(result.getValue(PURITY.MAXDIPLOIDPROPORTION)).build();
    return ImmutablePurityContext.builder().bestFit(purity).score(score).version(result.getValue(PURITY.VERSION)).gender(Gender.valueOf(result.getValue(PURITY.GENDER))).polyClonalProportion(result.getValue(PURITY.POLYCLONALPROPORTION)).status(FittedPurityStatus.valueOf(result.getValue(PURITY.STATUS))).build();
}
Also used : Record(org.jooq.Record) ImmutableFittedPurity(com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurity) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) FittedPurityScore(com.hartwig.hmftools.common.purple.purity.FittedPurityScore) ImmutableFittedPurityScore(com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurityScore) Nullable(org.jetbrains.annotations.Nullable) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with FittedPurityScore

use of com.hartwig.hmftools.common.purple.purity.FittedPurityScore in project hmftools by hartwigmedical.

the class PatientReporter method analyseGenomeData.

@NotNull
private GenomeAnalysis analyseGenomeData(@NotNull final String sample, @NotNull final String runDirectory) throws IOException {
    LOGGER.info(" Loading somatic snv and indels...");
    final List<SomaticVariant> variants = PatientReporterHelper.loadPassedSomaticVariants(sample, runDirectory);
    LOGGER.info("  " + variants.size() + " somatic passed snps, mnps and indels loaded for sample " + sample);
    LOGGER.info(" Analyzing somatic snp/mnp and indels....");
    final VariantAnalysis variantAnalysis = variantAnalyzer().run(variants);
    LOGGER.info(" Loading purity numbers...");
    final PurityContext context = PatientReporterHelper.loadPurity(runDirectory, sample);
    if (context.status().equals(FittedPurityStatus.NO_TUMOR)) {
        LOGGER.warn("PURPLE DID NOT DETECT A TUMOR. Proceed with utmost caution!");
    }
    final FittedPurity purity = context.bestFit();
    final FittedPurityScore purityScore = context.score();
    final List<PurpleCopyNumber> purpleCopyNumbers = PatientReporterHelper.loadPurpleCopyNumbers(runDirectory, sample);
    final List<GeneCopyNumber> panelGeneCopyNumbers = PatientReporterHelper.loadPurpleGeneCopyNumbers(runDirectory, sample).stream().filter(x -> reporterData().panelGeneModel().panel().contains(x.gene())).collect(Collectors.toList());
    LOGGER.info("  " + purpleCopyNumbers.size() + " purple copy number regions loaded for sample " + sample);
    LOGGER.info(" Analyzing purple somatic copy numbers...");
    final PurpleAnalysis purpleAnalysis = ImmutablePurpleAnalysis.builder().gender(context.gender()).status(context.status()).fittedPurity(purity).fittedScorePurity(purityScore).copyNumbers(purpleCopyNumbers).panelGeneCopyNumbers(panelGeneCopyNumbers).build();
    final Path structuralVariantVCF = PatientReporterHelper.findStructuralVariantVCF(runDirectory);
    LOGGER.info(" Loading structural variants...");
    final List<StructuralVariant> structuralVariants = StructuralVariantFileLoader.fromFile(structuralVariantVCF.toString(), true);
    LOGGER.info(" Enriching structural variants with purple data.");
    final List<EnrichedStructuralVariant> enrichedStructuralVariants = purpleAnalysis.enrichStructuralVariants(structuralVariants);
    LOGGER.info(" Analysing structural variants...");
    final StructuralVariantAnalysis structuralVariantAnalysis = structuralVariantAnalyzer().run(enrichedStructuralVariants, false);
    return ImmutableGenomeAnalysis.of(sample, variantAnalysis, purpleAnalysis, structuralVariantAnalysis);
}
Also used : ProductionRunContextFactory(com.hartwig.hmftools.common.context.ProductionRunContextFactory) StructuralVariantAnalyzer(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalyzer) ImmutableSampleReport(com.hartwig.hmftools.patientreporter.ImmutableSampleReport) ImmutablePurpleAnalysis(com.hartwig.hmftools.patientreporter.copynumber.ImmutablePurpleAnalysis) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) SampleReport(com.hartwig.hmftools.patientreporter.SampleReport) HmfReporterData(com.hartwig.hmftools.patientreporter.HmfReporterData) AlterationAnalyzer(com.hartwig.hmftools.patientreporter.civic.AlterationAnalyzer) StructuralVariant(com.hartwig.hmftools.common.variant.structural.StructuralVariant) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) VariantAnalyzer(com.hartwig.hmftools.patientreporter.variants.VariantAnalyzer) Lims(com.hartwig.hmftools.common.lims.Lims) Value(org.immutables.value.Value) Map(java.util.Map) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) Path(java.nio.file.Path) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) EnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant) GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) GeneDisruption(com.hartwig.hmftools.svannotation.annotations.GeneDisruption) SomaticVariant(com.hartwig.hmftools.common.variant.SomaticVariant) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) ImmutableSequencedPatientReport(com.hartwig.hmftools.patientreporter.ImmutableSequencedPatientReport) PurpleAnalysis(com.hartwig.hmftools.patientreporter.copynumber.PurpleAnalysis) SequencedPatientReport(com.hartwig.hmftools.patientreporter.SequencedPatientReport) FittedPurityScore(com.hartwig.hmftools.common.purple.purity.FittedPurityScore) IOException(java.io.IOException) VariantAnalysis(com.hartwig.hmftools.patientreporter.variants.VariantAnalysis) BaseReporterData(com.hartwig.hmftools.patientreporter.BaseReporterData) Collectors(java.util.stream.Collectors) Transcript(com.hartwig.hmftools.svannotation.annotations.Transcript) RunContext(com.hartwig.hmftools.common.context.RunContext) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) TumorLocationDoidMapping(com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping) Logger(org.apache.logging.log4j.Logger) PurityContext(com.hartwig.hmftools.common.purple.purity.PurityContext) GeneFusion(com.hartwig.hmftools.svannotation.annotations.GeneFusion) Optional(java.util.Optional) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) StructuralVariantAnalysis(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalysis) Comparator(java.util.Comparator) StructuralVariantFileLoader(com.hartwig.hmftools.common.variant.structural.StructuralVariantFileLoader) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) FittedPurityStatus(com.hartwig.hmftools.common.purple.purity.FittedPurityStatus) Path(java.nio.file.Path) SomaticVariant(com.hartwig.hmftools.common.variant.SomaticVariant) EnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant) StructuralVariantAnalysis(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalysis) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) StructuralVariant(com.hartwig.hmftools.common.variant.structural.StructuralVariant) EnrichedStructuralVariant(com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) PurityContext(com.hartwig.hmftools.common.purple.purity.PurityContext) ImmutablePurpleAnalysis(com.hartwig.hmftools.patientreporter.copynumber.ImmutablePurpleAnalysis) PurpleAnalysis(com.hartwig.hmftools.patientreporter.copynumber.PurpleAnalysis) VariantAnalysis(com.hartwig.hmftools.patientreporter.variants.VariantAnalysis) StructuralVariantAnalysis(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalysis) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) FittedPurityScore(com.hartwig.hmftools.common.purple.purity.FittedPurityScore) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FittedPurity (com.hartwig.hmftools.common.purple.purity.FittedPurity)3 FittedPurityScore (com.hartwig.hmftools.common.purple.purity.FittedPurityScore)3 ImmutableFittedPurity (com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurity)2 ImmutableFittedPurityScore (com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurityScore)2 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 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)1 Lims (com.hartwig.hmftools.common.lims.Lims)1 PurpleCopyNumber (com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber)1 FittedPurityStatus (com.hartwig.hmftools.common.purple.purity.FittedPurityStatus)1 PurityContext (com.hartwig.hmftools.common.purple.purity.PurityContext)1 HmfGenomeRegion (com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion)1 SomaticVariant (com.hartwig.hmftools.common.variant.SomaticVariant)1 EnrichedStructuralVariant (com.hartwig.hmftools.common.variant.structural.EnrichedStructuralVariant)1 StructuralVariant (com.hartwig.hmftools.common.variant.structural.StructuralVariant)1 StructuralVariantFileLoader (com.hartwig.hmftools.common.variant.structural.StructuralVariantFileLoader)1 BaseReporterData (com.hartwig.hmftools.patientreporter.BaseReporterData)1 HmfReporterData (com.hartwig.hmftools.patientreporter.HmfReporterData)1 ImmutableSampleReport (com.hartwig.hmftools.patientreporter.ImmutableSampleReport)1