use of com.hartwig.hmftools.patientreporter.copynumber.PurpleAnalysis 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());
}
use of com.hartwig.hmftools.patientreporter.copynumber.PurpleAnalysis 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);
}
Aggregations