Search in sources :

Example 1 with GeneFusionData

use of com.hartwig.hmftools.patientreporter.report.data.GeneFusionData 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 GeneFusionData

use of com.hartwig.hmftools.patientreporter.report.data.GeneFusionData 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 GeneFusionData

use of com.hartwig.hmftools.patientreporter.report.data.GeneFusionData in project hmftools by hartwigmedical.

the class CivicAnalyzer method civicFusionAlterations.

@NotNull
private static List<Alteration> civicFusionAlterations(@NotNull final List<GeneFusionData> fusions, @NotNull final Set<String> relevantDoids) {
    LOGGER.info("  Fetching civic fusion alterations...");
    final List<Alteration> alterations = Lists.newArrayList();
    for (final GeneFusionData fusion : fusions) {
        alterations.addAll(queryCivicAlteration(fusion.geneStartEntrezIds(), variantList -> Alteration.from(fusion, variantList, relevantDoids), "  Failed to get civic variants for fusion: " + fusion.geneStart() + " - " + fusion.geneEnd()));
        alterations.addAll(queryCivicAlteration(fusion.geneEndEntrezIds(), variantList -> Alteration.from(fusion, variantList, relevantDoids), "  Failed to get civic variants for fusion: " + fusion.geneStart() + " - " + fusion.geneEnd()));
    }
    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) Alteration(com.hartwig.hmftools.patientreporter.report.data.Alteration) GeneFusionData(com.hartwig.hmftools.patientreporter.report.data.GeneFusionData) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

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 VariantReport (com.hartwig.hmftools.patientreporter.variants.VariantReport)3 GeneCopyNumber (com.hartwig.hmftools.common.gene.GeneCopyNumber)2 ImmutableSampleReport (com.hartwig.hmftools.patientreporter.ImmutableSampleReport)2 SampleReport (com.hartwig.hmftools.patientreporter.SampleReport)2 NotNull (org.jetbrains.annotations.NotNull)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 PurityAdjuster (com.hartwig.hmftools.common.purple.PurityAdjuster)1 FittedPurity (com.hartwig.hmftools.common.purple.purity.FittedPurity)1