Search in sources :

Example 1 with GermlinePloidyAnnotatedTargetCollection

use of org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection in project gatk-protected by broadinstitute.

the class GermlineCNVCaller method runPipeline.

/**
     * The main routine
     *
     * @param ctx a nullable Spark context
     */
@Override
protected void runPipeline(@Nullable JavaSparkContext ctx) {
    final TargetCollection<Target> optionalTargetsCollections = optionalTargets.readTargetCollection(true);
    if (optionalTargetsCollections == null) {
        logger.info("No target file was provided: using all targets in the combined read counts table");
    }
    logger.info("Parsing the read counts table...");
    final ReadCountCollection readCounts = loadReadCountCollection(optionalTargetsCollections);
    logger.info("Parsing the sample sex genotypes table...");
    final SexGenotypeDataCollection sexGenotypeDataCollection = loadSexGenotypeDataCollection();
    logger.info("Parsing the germline contig ploidy annotation table...");
    final GermlinePloidyAnnotatedTargetCollection ploidyAnnotatedTargetCollection = loadGermlinePloidyAnnotatedTargetCollection(readCounts);
    logger.info("Parsing the copy number transition prior table and initializing the caches...");
    final IntegerCopyNumberTransitionProbabilityCacheCollection transitionProbabilityCacheCollection = createIntegerCopyNumberTransitionProbabilityCacheCollection();
    final IntegerCopyNumberExpectationsCalculator integerCopyNumberExpectationsCalculator = new IntegerCopyNumberExpectationsCalculator(transitionProbabilityCacheCollection, params.getMinLearningReadCount());
    final CoverageModelParameters model = getCoverageModelParameters();
    Utils.validateArg(model != null || !jobType.equals(JobType.CALL_ONLY), "Model parameters are not given; can not run the tool in the CALL_ONLY mode.");
    logger.info("Initializing the EM algorithm workspace...");
    final IntegerCopyNumberReferenceStateFactory referenceStateFactory = new IntegerCopyNumberReferenceStateFactory(ploidyAnnotatedTargetCollection);
    final CoverageModelEMWorkspace<IntegerCopyNumberState> workspace = new CoverageModelEMWorkspace<>(readCounts, ploidyAnnotatedTargetCollection, sexGenotypeDataCollection, integerCopyNumberExpectationsCalculator, params, model, referenceStateFactory, ctx);
    final CoverageModelEMAlgorithm<IntegerCopyNumberState> algo = new CoverageModelEMAlgorithm<>(params, workspace);
    switch(jobType) {
        case LEARN_AND_CALL:
            algo.runExpectationMaximization();
            logger.info("Saving the model to disk...");
            workspace.writeModel(new File(outputPath, FINAL_MODEL_SUBDIR).getAbsolutePath());
            break;
        case CALL_ONLY:
            algo.runExpectation();
            break;
        default:
            throw new UnsupportedOperationException(String.format("\"%s\" is not recognized as a supported job type", jobType.name()));
    }
    logger.info("Saving posteriors to disk...");
    workspace.writePosteriors(new File(outputPath, FINAL_POSTERIORS_SUBDIR).getAbsolutePath(), CoverageModelEMWorkspace.PosteriorVerbosityLevel.EXTENDED);
}
Also used : CoverageModelEMAlgorithm(org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelEMAlgorithm) SexGenotypeDataCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.SexGenotypeDataCollection) IntegerCopyNumberState(org.broadinstitute.hellbender.tools.exome.germlinehmm.IntegerCopyNumberState) CoverageModelEMWorkspace(org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelEMWorkspace) GermlinePloidyAnnotatedTargetCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection) IntegerCopyNumberTransitionProbabilityCacheCollection(org.broadinstitute.hellbender.tools.exome.germlinehmm.IntegerCopyNumberTransitionProbabilityCacheCollection) CoverageModelParameters(org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelParameters)

Example 2 with GermlinePloidyAnnotatedTargetCollection

use of org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection in project gatk-protected by broadinstitute.

the class GermlineCNVCallerIntegrationTest method init.

@BeforeSuite
public void init() throws IOException {
    LEARNING_SEX_GENOTYPES_DATA = new SexGenotypeDataCollection(TEST_LEARNING_SAMPLE_SEX_GENOTYPES_FILE);
    CALLING_SEX_GENOTYPES_DATA = new SexGenotypeDataCollection(TEST_CALLING_SAMPLE_SEX_GENOTYPES_FILE);
    GERMLINE_PLOIDY_ANNOTATIONS = new GermlinePloidyAnnotatedTargetCollection(ContigGermlinePloidyAnnotationTableReader.readContigGermlinePloidyAnnotationsFromFile(TEST_CONTIG_PLOIDY_ANNOTATIONS_FILE), TargetTableReader.readTargetFile(TEST_TARGETS_FILE));
}
Also used : SexGenotypeDataCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.SexGenotypeDataCollection) GermlinePloidyAnnotatedTargetCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 3 with GermlinePloidyAnnotatedTargetCollection

use of org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection in project gatk by broadinstitute.

the class GermlineCNVCallerIntegrationTest method init.

@BeforeSuite
public void init() throws IOException {
    LEARNING_SEX_GENOTYPES_DATA = new SexGenotypeDataCollection(TEST_LEARNING_SAMPLE_SEX_GENOTYPES_FILE);
    CALLING_SEX_GENOTYPES_DATA = new SexGenotypeDataCollection(TEST_CALLING_SAMPLE_SEX_GENOTYPES_FILE);
    GERMLINE_PLOIDY_ANNOTATIONS = new GermlinePloidyAnnotatedTargetCollection(ContigGermlinePloidyAnnotationTableReader.readContigGermlinePloidyAnnotationsFromFile(TEST_CONTIG_PLOIDY_ANNOTATIONS_FILE), TargetTableReader.readTargetFile(TEST_TARGETS_FILE));
}
Also used : SexGenotypeDataCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.SexGenotypeDataCollection) GermlinePloidyAnnotatedTargetCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection) BeforeSuite(org.testng.annotations.BeforeSuite)

Example 4 with GermlinePloidyAnnotatedTargetCollection

use of org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection in project gatk by broadinstitute.

the class GermlineCNVCaller method runPipeline.

/**
     * The main routine
     *
     * @param ctx a nullable Spark context
     */
@Override
protected void runPipeline(@Nullable JavaSparkContext ctx) {
    final TargetCollection<Target> optionalTargetsCollections = optionalTargets.readTargetCollection(true);
    if (optionalTargetsCollections == null) {
        logger.info("No target file was provided: using all targets in the combined read counts table");
    }
    logger.info("Parsing the read counts table...");
    final ReadCountCollection readCounts = loadReadCountCollection(optionalTargetsCollections);
    logger.info("Parsing the sample sex genotypes table...");
    final SexGenotypeDataCollection sexGenotypeDataCollection = loadSexGenotypeDataCollection();
    logger.info("Parsing the germline contig ploidy annotation table...");
    final GermlinePloidyAnnotatedTargetCollection ploidyAnnotatedTargetCollection = loadGermlinePloidyAnnotatedTargetCollection(readCounts);
    logger.info("Parsing the copy number transition prior table and initializing the caches...");
    final IntegerCopyNumberTransitionProbabilityCacheCollection transitionProbabilityCacheCollection = createIntegerCopyNumberTransitionProbabilityCacheCollection();
    final IntegerCopyNumberExpectationsCalculator integerCopyNumberExpectationsCalculator = new IntegerCopyNumberExpectationsCalculator(transitionProbabilityCacheCollection, params.getMinLearningReadCount());
    final CoverageModelParameters model = getCoverageModelParameters();
    Utils.validateArg(model != null || !jobType.equals(JobType.CALL_ONLY), "Model parameters are not given; can not run the tool in the CALL_ONLY mode.");
    logger.info("Initializing the EM algorithm workspace...");
    final IntegerCopyNumberReferenceStateFactory referenceStateFactory = new IntegerCopyNumberReferenceStateFactory(ploidyAnnotatedTargetCollection);
    final CoverageModelEMWorkspace<IntegerCopyNumberState> workspace = new CoverageModelEMWorkspace<>(readCounts, ploidyAnnotatedTargetCollection, sexGenotypeDataCollection, integerCopyNumberExpectationsCalculator, params, model, referenceStateFactory, ctx);
    final CoverageModelEMAlgorithm<IntegerCopyNumberState> algo = new CoverageModelEMAlgorithm<>(params, workspace);
    switch(jobType) {
        case LEARN_AND_CALL:
            algo.runExpectationMaximization();
            logger.info("Saving the model to disk...");
            workspace.writeModel(new File(outputPath, FINAL_MODEL_SUBDIR).getAbsolutePath());
            break;
        case CALL_ONLY:
            algo.runExpectation();
            break;
        default:
            throw new UnsupportedOperationException(String.format("\"%s\" is not recognized as a supported job type", jobType.name()));
    }
    logger.info("Saving posteriors to disk...");
    workspace.writePosteriors(new File(outputPath, FINAL_POSTERIORS_SUBDIR).getAbsolutePath(), CoverageModelEMWorkspace.PosteriorVerbosityLevel.EXTENDED);
}
Also used : CoverageModelEMAlgorithm(org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelEMAlgorithm) SexGenotypeDataCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.SexGenotypeDataCollection) IntegerCopyNumberState(org.broadinstitute.hellbender.tools.exome.germlinehmm.IntegerCopyNumberState) CoverageModelEMWorkspace(org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelEMWorkspace) GermlinePloidyAnnotatedTargetCollection(org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection) IntegerCopyNumberTransitionProbabilityCacheCollection(org.broadinstitute.hellbender.tools.exome.germlinehmm.IntegerCopyNumberTransitionProbabilityCacheCollection) CoverageModelParameters(org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelParameters)

Aggregations

GermlinePloidyAnnotatedTargetCollection (org.broadinstitute.hellbender.tools.exome.sexgenotyper.GermlinePloidyAnnotatedTargetCollection)4 SexGenotypeDataCollection (org.broadinstitute.hellbender.tools.exome.sexgenotyper.SexGenotypeDataCollection)4 CoverageModelEMAlgorithm (org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelEMAlgorithm)2 CoverageModelEMWorkspace (org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelEMWorkspace)2 CoverageModelParameters (org.broadinstitute.hellbender.tools.coveragemodel.CoverageModelParameters)2 IntegerCopyNumberState (org.broadinstitute.hellbender.tools.exome.germlinehmm.IntegerCopyNumberState)2 IntegerCopyNumberTransitionProbabilityCacheCollection (org.broadinstitute.hellbender.tools.exome.germlinehmm.IntegerCopyNumberTransitionProbabilityCacheCollection)2 BeforeSuite (org.testng.annotations.BeforeSuite)2