Search in sources :

Example 1 with VariantReport

use of com.hartwig.hmftools.patientreporter.variants.VariantReport in project hmftools by hartwigmedical.

the class PDFWriterTest method canGenerateSequenceReport.

@Test
public void canGenerateSequenceReport() throws DRException, IOException {
    final double pathologyTumorPercentage = 0.6;
    final double impliedTumorPurity = 0.58;
    final int mutationalLoad = 361;
    final double microsatelliteIndicator = 2.1;
    final HmfReporterData reporterData = testHmfReporterData();
    final BaseReporterData baseReporterData = testBaseReporterData();
    final FittedPurity fittedPurity = createFittedPurity(impliedTumorPurity);
    final List<VariantReport> variants = createTestVariants(new PurityAdjuster(Gender.MALE, fittedPurity));
    final List<GeneCopyNumber> copyNumbers = createTestCopyNumbers();
    final List<GeneDisruptionData> disruptions = createTestDisruptions();
    final List<GeneFusionData> fusions = createTestFusions();
    final SampleReport sampleReport = testSampleReport(pathologyTumorPercentage);
    final List<Alteration> alterations = RUN_CIVIC_ANALYSIS ? PatientReporterTestUtil.runCivicAnalysis(variants, copyNumbers, disruptions, fusions, reporterData.panelGeneModel(), sampleReport.cancerType()) : mockedAlterations();
    final SequencedPatientReport patientReport = ImmutableSequencedPatientReport.of(sampleReport, variants, mutationalLoad, microsatelliteIndicator, copyNumbers, disruptions, fusions, PatientReportFormat.formatPercent(impliedTumorPurity), alterations, Resources.getResource("circos" + File.separator + "circos_example.png").getPath(), Optional.of("this is a test report and does not relate to any real CPCT patient"), baseReporterData.signaturePath());
    final JasperReportBuilder mainReport = PDFWriter.generatePatientReport(patientReport, reporterData);
    assertNotNull(mainReport);
    final JasperReportBuilder evidenceReport = EvidenceReport.generate(patientReport);
    assertNotNull(evidenceReport);
    if (SHOW_AND_PRINT) {
        mainReport.show().print();
    }
    if (WRITE_TO_PDF) {
        mainReport.toPdf(new FileOutputStream(REPORT_BASE_DIR + File.separator + "test_report.pdf"));
        evidenceReport.toPdf(new FileOutputStream(REPORT_BASE_DIR + File.separator + "test_evidence_report.pdf"));
    }
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) ImmutableSequencedPatientReport(com.hartwig.hmftools.patientreporter.ImmutableSequencedPatientReport) SequencedPatientReport(com.hartwig.hmftools.patientreporter.SequencedPatientReport) NotSequencedPatientReport(com.hartwig.hmftools.patientreporter.NotSequencedPatientReport) ImmutableNotSequencedPatientReport(com.hartwig.hmftools.patientreporter.ImmutableNotSequencedPatientReport) PatientReporterTestUtil.testBaseReporterData(com.hartwig.hmftools.patientreporter.PatientReporterTestUtil.testBaseReporterData) BaseReporterData(com.hartwig.hmftools.patientreporter.BaseReporterData) ImmutableSampleReport(com.hartwig.hmftools.patientreporter.ImmutableSampleReport) SampleReport(com.hartwig.hmftools.patientreporter.SampleReport) GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) ImmutableGeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.ImmutableGeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) ImmutableVariantReport(com.hartwig.hmftools.patientreporter.variants.ImmutableVariantReport) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) JasperReportBuilder(net.sf.dynamicreports.jasper.builder.JasperReportBuilder) HmfReporterData(com.hartwig.hmftools.patientreporter.HmfReporterData) PatientReporterTestUtil.testHmfReporterData(com.hartwig.hmftools.patientreporter.PatientReporterTestUtil.testHmfReporterData) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) ImmutableGeneFusionData(com.hartwig.hmftools.patientreporter.report.data.ImmutableGeneFusionData) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) ImmutableGeneCopyNumber(com.hartwig.hmftools.common.gene.ImmutableGeneCopyNumber) FileOutputStream(java.io.FileOutputStream) ImmutableFittedPurity(com.hartwig.hmftools.common.purple.purity.ImmutableFittedPurity) FittedPurity(com.hartwig.hmftools.common.purple.purity.FittedPurity) Test(org.junit.Test)

Example 2 with VariantReport

use of com.hartwig.hmftools.patientreporter.variants.VariantReport in project hmftools by hartwigmedical.

the class PatientReporter method run.

@NotNull
public SequencedPatientReport run(@NotNull final String runDirectory, @Nullable final String comments) throws IOException {
    final RunContext run = ProductionRunContextFactory.fromRunDirectory(runDirectory);
    final GenomeAnalysis genomeAnalysis = analyseGenomeData(run.tumorSample(), runDirectory);
    assert run.isSomaticRun() && run.tumorSample().equals(genomeAnalysis.sample());
    final String tumorSample = genomeAnalysis.sample();
    final VariantAnalysis variantAnalysis = genomeAnalysis.variantAnalysis();
    final PurpleAnalysis purpleAnalysis = genomeAnalysis.purpleAnalysis();
    final StructuralVariantAnalysis structuralVariantAnalysis = genomeAnalysis.structuralVariantAnalysis();
    final List<GeneFusionData> reportableFusions = structuralVariantAnalysis.reportableFusions().stream().sorted(fusionComparator()).map(GeneFusionData::from).collect(Collectors.toList());
    final List<GeneDisruptionData> reportableDisruptions = structuralVariantAnalysis.reportableDisruptions().stream().sorted(disruptionComparator(reporterData().panelGeneModel().transcriptMap())).map(GeneDisruptionData::from).collect(Collectors.toList());
    final int passedVariantCount = variantAnalysis.passedVariants().size();
    final int mutationalLoad = variantAnalysis.mutationalLoad();
    final int consequentialVariantCount = variantAnalysis.consequentialVariants().size();
    final int structuralVariantCount = structuralVariantAnalysis.annotations().size();
    final String cancerType = PatientReporterHelper.extractCancerType(baseReporterData().patientsCancerTypes(), tumorSample);
    final TumorLocationDoidMapping doidMapping = TumorLocationDoidMapping.fromResource("/tumor_location_doid_mapping.csv");
    final List<Alteration> alterations = civicAnalyzer().run(variantAnalysis.findings(), purpleAnalysis.reportableGeneCopyNumbers(), reportableDisruptions, reportableFusions, reporterData().panelGeneModel(), doidMapping.doidsForTumorType(cancerType));
    LOGGER.info(" Printing analysis results:");
    LOGGER.info("  Number of passed variants : " + Integer.toString(passedVariantCount));
    LOGGER.info("  Number of missense variants (mutational load) : " + Integer.toString(mutationalLoad));
    LOGGER.info("  Number of consequential variants to report : " + Integer.toString(consequentialVariantCount));
    LOGGER.info(" Determined copy number stats for " + Integer.toString(purpleAnalysis.genePanelSize()) + " genes which led to " + Integer.toString(purpleAnalysis.reportableGeneCopyNumbers().size()) + " copy numbers.");
    LOGGER.info("  Number of unreported structural variants : " + Integer.toString(structuralVariantCount));
    LOGGER.info("  Number of gene fusions to report : " + Integer.toString(reportableFusions.size()));
    LOGGER.info("  Number of gene disruptions to report : " + Integer.toString(reportableDisruptions.size()));
    LOGGER.info("  Number of CIViC alterations to report : " + alterations.size());
    LOGGER.info("  Microsatellite analysis results: " + variantAnalysis.indelsPerMb() + " indels per MB");
    final Lims lims = baseReporterData().limsModel();
    final Double tumorPercentage = lims.tumorPercentageForSample(tumorSample);
    final List<VariantReport> purpleEnrichedVariants = purpleAnalysis.enrichSomaticVariants(variantAnalysis.findings());
    final String sampleRecipient = baseReporterData().centerModel().getAddresseeStringForSample(tumorSample);
    final SampleReport sampleReport = ImmutableSampleReport.of(tumorSample, cancerType, tumorPercentage, lims.arrivalDateForSample(tumorSample), lims.arrivalDateForSample(run.refSample()), lims.labProceduresForSample(tumorSample), sampleRecipient);
    return ImmutableSequencedPatientReport.of(sampleReport, purpleEnrichedVariants, mutationalLoad, variantAnalysis.indelsPerMb(), purpleAnalysis.reportableGeneCopyNumbers(), reportableDisruptions, reportableFusions, purpleAnalysis.purityString(), alterations, PatientReporterHelper.findCircosPlotPath(runDirectory, tumorSample), Optional.ofNullable(comments), baseReporterData().signaturePath());
}
Also used : ImmutableSampleReport(com.hartwig.hmftools.patientreporter.ImmutableSampleReport) SampleReport(com.hartwig.hmftools.patientreporter.SampleReport) StructuralVariantAnalysis(com.hartwig.hmftools.svannotation.analysis.StructuralVariantAnalysis) GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) Lims(com.hartwig.hmftools.common.lims.Lims) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) 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) RunContext(com.hartwig.hmftools.common.context.RunContext) TumorLocationDoidMapping(com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with VariantReport

use of com.hartwig.hmftools.patientreporter.variants.VariantReport in project hmftools by hartwigmedical.

the class CivicAnalyzer method civicVariantAlterations.

@NotNull
private static List<Alteration> civicVariantAlterations(@NotNull final List<VariantReport> reportedVariants, @NotNull final Collection<HmfGenomeRegion> geneRegions, @NotNull final Set<String> relevantDoids) {
    LOGGER.info("  Fetching civic variant alterations...");
    final List<Alteration> alterations = Lists.newArrayList();
    final CivicApiWrapper civicApi = new CivicApiWrapper();
    for (final HmfGenomeRegion region : geneRegions) {
        final List<VariantReport> reportedVariantsInGene = reportedVariants.stream().filter(variantReport -> region.gene().equals(variantReport.gene())).collect(Collectors.toList());
        if (!reportedVariantsInGene.isEmpty()) {
            for (final VariantReport variantReport : reportedVariantsInGene) {
                alterations.addAll(queryCivicAlteration(region.entrezId(), variantList -> Alteration.from(variantReport, variantList, relevantDoids), "  Failed to get civic variants for variant: " + variantReport.variant().chromosomePosition()));
            }
        }
    }
    civicApi.releaseResources();
    return alterations;
}
Also used : GeneDisruptionData(com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) GeneModel(com.hartwig.hmftools.common.gene.GeneModel) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) List(java.util.List) Lists(com.google.common.collect.Lists) Logger(org.apache.logging.log4j.Logger) CivicVariantWithEvidence(com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) Observable(io.reactivex.Observable) GeneCopyNumber(com.hartwig.hmftools.common.gene.GeneCopyNumber) NotNull(org.jetbrains.annotations.NotNull) LogManager(org.apache.logging.log4j.LogManager) DiseaseOntologyApiWrapper(com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) CivicApiWrapper(com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper) HmfGenomeRegion(com.hartwig.hmftools.common.region.hmfslicer.HmfGenomeRegion) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with VariantReport

use of com.hartwig.hmftools.patientreporter.variants.VariantReport in project hmftools by hartwigmedical.

the class PurpleAnalysis method enrichSomaticVariants.

@NotNull
public List<VariantReport> enrichSomaticVariants(@NotNull final List<VariantReport> variants) {
    final List<VariantReport> result = Lists.newArrayList();
    final PurityAdjuster purityAdjuster = new PurityAdjuster(gender(), fittedPurity());
    final GenomeRegionSelector<PurpleCopyNumber> copyNumberSelector = GenomeRegionSelectorFactory.create(copyNumbers());
    for (final VariantReport variantReport : variants) {
        final Optional<PurpleCopyNumber> optionalCopyNumber = copyNumberSelector.select(variantReport.variant());
        if (optionalCopyNumber.isPresent()) {
            final PurpleCopyNumber copyNumber = optionalCopyNumber.get();
            double adjustedVAF = Math.min(1, purityAdjuster.purityAdjustedVAF(copyNumber.chromosome(), copyNumber.averageTumorCopyNumber(), variantReport.alleleFrequency()));
            result.add(ImmutableVariantReport.builder().from(variantReport).baf(copyNumber.descriptiveBAF()).impliedVAF(adjustedVAF).build());
        } else {
            result.add(variantReport);
        }
    }
    return result;
}
Also used : PurityAdjuster(com.hartwig.hmftools.common.purple.PurityAdjuster) VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) ImmutableVariantReport(com.hartwig.hmftools.patientreporter.variants.ImmutableVariantReport) PurpleCopyNumber(com.hartwig.hmftools.common.purple.copynumber.PurpleCopyNumber) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with VariantReport

use of com.hartwig.hmftools.patientreporter.variants.VariantReport in project hmftools by hartwigmedical.

the class VariantDataSource method fromVariants.

@NotNull
public static JRDataSource fromVariants(@NotNull final List<VariantReport> variantReports, @NotNull DrupFilter drupFilter) {
    final DRDataSource variantDataSource = new DRDataSource(GENE_FIELD.getName(), POSITION_FIELD.getName(), VARIANT_FIELD.getName(), DEPTH_VAF_FIELD.getName(), COSMIC_FIELD.getName(), COSMIC_NR_FIELD.getName(), HGVS_CODING_FIELD.getName(), HGVS_PROTEIN_FIELD.getName(), CONSEQUENCE_FIELD.getName(), PLOIDY_TAF_FIELD.getName());
    for (final VariantReport variantReport : variantReports) {
        final String displayGene = drupFilter.test(variantReport) ? variantReport.gene() + " *" : variantReport.gene();
        variantDataSource.add(displayGene, variantReport.variant().chromosomePosition(), variantReport.variantField(), variantReport.depthVafField(), variantReport.cosmicID(), stripCosmicIdentifier(variantReport.cosmicID()), variantReport.hgvsCoding(), variantReport.hgvsProtein(), variantReport.consequence(), variantReport.ploidyTafField());
    }
    return variantDataSource;
}
Also used : VariantReport(com.hartwig.hmftools.patientreporter.variants.VariantReport) DRDataSource(net.sf.dynamicreports.report.datasource.DRDataSource) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)6 NotNull (org.jetbrains.annotations.NotNull)5 Alteration (com.hartwig.hmftools.patientreporter.report.data.Alteration)3 GeneDisruptionData (com.hartwig.hmftools.patientreporter.report.data.GeneDisruptionData)3 GeneFusionData (com.hartwig.hmftools.patientreporter.report.data.GeneFusionData)3 ImmutableVariantReport (com.hartwig.hmftools.patientreporter.variants.ImmutableVariantReport)3 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)2 PurityAdjuster (com.hartwig.hmftools.common.purple.PurityAdjuster)2 ImmutableSampleReport (com.hartwig.hmftools.patientreporter.ImmutableSampleReport)2 SampleReport (com.hartwig.hmftools.patientreporter.SampleReport)2 Lists (com.google.common.collect.Lists)1 Sets (com.google.common.collect.Sets)1 CivicApiWrapper (com.hartwig.hmftools.apiclients.civic.api.CivicApiWrapper)1 CivicVariantWithEvidence (com.hartwig.hmftools.apiclients.civic.data.CivicVariantWithEvidence)1 DiseaseOntologyApiWrapper (com.hartwig.hmftools.apiclients.diseaseontology.api.DiseaseOntologyApiWrapper)1 RunContext (com.hartwig.hmftools.common.context.RunContext)1 TumorLocationDoidMapping (com.hartwig.hmftools.common.ecrf.doid.TumorLocationDoidMapping)1 GeneModel (com.hartwig.hmftools.common.gene.GeneModel)1 ImmutableGeneCopyNumber (com.hartwig.hmftools.common.gene.ImmutableGeneCopyNumber)1 Lims (com.hartwig.hmftools.common.lims.Lims)1