Search in sources :

Example 16 with AllelicPanelOfNormals

use of org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals in project gatk by broadinstitute.

the class PerformJointSegmentation method doWork.

@Override
public Object doWork() {
    ParamUtils.isPositive(initialNumAFStates, "Must have at least one allele-fraction state.");
    ParamUtils.isPositive(initialNumCRStates, "Must have at least one copy-ratio state.");
    final AllelicPanelOfNormals allelicPoN = allelicPoNFile != null ? AllelicPanelOfNormals.read(allelicPoNFile) : AllelicPanelOfNormals.EMPTY_PON;
    final AllelicCountCollection acc = new AllelicCountCollection(snpCountsFile);
    final ReadCountCollection rcc;
    try {
        rcc = ReadCountCollectionUtils.parse(new File(coverageFile));
    } catch (final IOException ex) {
        throw new UserException.BadInput("could not read input file");
    }
    final JointAFCRSegmenter jointSegmenter = JointAFCRSegmenter.createJointSegmenter(initialNumCRStates, rcc, initialNumAFStates, acc, allelicPoN);
    final List<Pair<SimpleInterval, AFCRHiddenState>> segmentation = jointSegmenter.findSegments();
    final List<ACNVModeledSegment> segments = segmentation.stream().map(pair -> new ACNVModeledSegment(pair.getLeft(), errorlessPosterior(pair.getRight().getLog2CopyRatio()), errorlessPosterior(pair.getRight().getMinorAlleleFraction()))).collect(Collectors.toList());
    //TODO: make more reasonable output for ACNV 2.0
    SegmentUtils.writeACNVModeledSegmentFile(outputSegmentsFile, segments, new Genome(rcc, acc.getCounts()));
    return "SUCCESS";
}
Also used : DocumentedFeature(org.broadinstitute.barclay.help.DocumentedFeature) ExomeStandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.ExomeStandardArgumentDefinitions) CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) Arrays(java.util.Arrays) CommandLineProgram(org.broadinstitute.hellbender.cmdline.CommandLineProgram) CopyNumberProgramGroup(org.broadinstitute.hellbender.cmdline.programgroups.CopyNumberProgramGroup) Argument(org.broadinstitute.barclay.argparser.Argument) org.broadinstitute.hellbender.tools.exome(org.broadinstitute.hellbender.tools.exome) IOException(java.io.IOException) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) ParamUtils(org.broadinstitute.hellbender.utils.param.ParamUtils) File(java.io.File) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) UserException(org.broadinstitute.hellbender.exceptions.UserException) PosteriorSummary(org.broadinstitute.hellbender.utils.mcmc.PosteriorSummary) AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) DecileCollection(org.broadinstitute.hellbender.utils.mcmc.DecileCollection) IOException(java.io.IOException) AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) UserException(org.broadinstitute.hellbender.exceptions.UserException) File(java.io.File) Pair(org.apache.commons.lang3.tuple.Pair)

Example 17 with AllelicPanelOfNormals

use of org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals in project gatk-protected by broadinstitute.

the class CreateAllelicPanelOfNormals method doWork.

@Override
protected Object doWork() {
    validateArguments();
    if (!new HDF5Library().load(null)) {
        //Note: passing null means using the default temp dir.
        throw new UserException.HardwareFeatureException("Cannot load the required HDF5 library. " + "HDF5 is currently supported on x86-64 architecture and Linux or OSX systems.");
    }
    logger.info("Starting allelic panel of normals creation...");
    final AllelicPanelOfNormals allelicPoN = new AllelicPanelOfNormalsCreator(inputFiles).create(siteFrequencyThreshold);
    logger.info("Allelic panel of normals created.");
    logger.info("Writing allelic panel of normals to output HDF5 file...");
    allelicPoN.write(outputFile, HDF5File.OpenMode.CREATE);
    logger.info("Allelic panel of normals written to " + outputFile + ".");
    if (outputTSVFile != null) {
        allelicPoN.write(outputTSVFile);
        logger.info("Allelic panel of normals written as tab-separated values to " + outputTSVFile + ".");
    }
    return "SUCCESS";
}
Also used : AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) HDF5Library(org.broadinstitute.hdf5.HDF5Library) AllelicPanelOfNormalsCreator(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormalsCreator)

Example 18 with AllelicPanelOfNormals

use of org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals in project gatk by broadinstitute.

the class AlleleFractionModellerUnitTest method testMCMCWithAllelicPoN.

/**
     * Test MCMC inference on simulated data using an allelic PoN.  Note that these MCMC tests were written to use
     * simulated hets before the allelic PoN was introduced.  Rather than generate a simulated PoN on the fly,
     * we simply use a fixed simulated PoN loaded from a file and check that its MLE hyperparameters are "sampled"
     * correctly by simply taking the MLE PoN values---i.e., the PoN does not actually cover the simulated sites and
     * hence is not used to correct reference bias in the simulated data in any way.
     * This latter functionality is tested on fixed data loaded from files in
     * {@link AlleleFractionModellerUnitTest#testBiasCorrection} instead.
     */
@Test
public void testMCMCWithAllelicPoN() {
    final double meanBiasSimulated = 1.2;
    final double biasVarianceSimulated = 0.04;
    // PoN generated with alpha = 65
    final double meanBiasOfPoN = 1.083;
    // PoN generated with beta = 60
    final double biasVarianceOfPoN = 0.0181;
    final AllelicPanelOfNormals allelicPoN = new AllelicPanelOfNormals(new AllelicCountCollection(ALLELIC_PON_NORMAL_COUNTS_FILE));
    testMCMC(meanBiasSimulated, biasVarianceSimulated, meanBiasOfPoN, biasVarianceOfPoN, allelicPoN);
}
Also used : AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 19 with AllelicPanelOfNormals

use of org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals in project gatk by broadinstitute.

the class AlleleFractionModellerUnitTest method dataBiasCorrection.

@DataProvider(name = "biasCorrection")
public Object[][] dataBiasCorrection() {
    LoggingUtils.setLoggingLevel(Log.LogLevel.INFO);
    final AllelicCountCollection sampleNormal = new AllelicCountCollection(SAMPLE_NORMAL_FILE);
    final AllelicCountCollection sampleWithBadSNPs = new AllelicCountCollection(SAMPLE_WITH_BAD_SNPS_FILE);
    final AllelicCountCollection sampleWithEvent = new AllelicCountCollection(SAMPLE_WITH_EVENT_FILE);
    final AllelicPanelOfNormals allelicPoNNormal = new AllelicPanelOfNormals(new AllelicCountCollection(ALLELIC_PON_NORMAL_COUNTS_FILE));
    final AllelicPanelOfNormals allelicPoNWithBadSNPs = new AllelicPanelOfNormals(new AllelicCountCollection(ALLELIC_PON_WITH_BAD_SNPS_COUNTS_FILE));
    final double minorFractionExpectedInMiddleSegmentNormal = 0.5;
    final double minorFractionExpectedInMiddleSegmentWithBadSNPsAndNormalPoN = 0.4;
    final double minorFractionExpectedInMiddleSegmentWithEvent = 0.33;
    return new Object[][] { { sampleNormal, allelicPoNNormal, minorFractionExpectedInMiddleSegmentNormal }, { sampleWithBadSNPs, allelicPoNNormal, minorFractionExpectedInMiddleSegmentWithBadSNPsAndNormalPoN }, { sampleWithEvent, allelicPoNNormal, minorFractionExpectedInMiddleSegmentWithEvent }, { sampleWithBadSNPs, allelicPoNWithBadSNPs, minorFractionExpectedInMiddleSegmentNormal } };
}
Also used : AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) DataProvider(org.testng.annotations.DataProvider)

Example 20 with AllelicPanelOfNormals

use of org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals in project gatk-protected by broadinstitute.

the class PerformJointSegmentation method doWork.

@Override
public Object doWork() {
    ParamUtils.isPositive(initialNumAFStates, "Must have at least one allele-fraction state.");
    ParamUtils.isPositive(initialNumCRStates, "Must have at least one copy-ratio state.");
    final AllelicPanelOfNormals allelicPoN = allelicPoNFile != null ? AllelicPanelOfNormals.read(allelicPoNFile) : AllelicPanelOfNormals.EMPTY_PON;
    final AllelicCountCollection acc = new AllelicCountCollection(snpCountsFile);
    final ReadCountCollection rcc;
    try {
        rcc = ReadCountCollectionUtils.parse(new File(coverageFile));
    } catch (final IOException ex) {
        throw new UserException.BadInput("could not read input file");
    }
    final JointAFCRSegmenter jointSegmenter = JointAFCRSegmenter.createJointSegmenter(initialNumCRStates, rcc, initialNumAFStates, acc, allelicPoN);
    final List<Pair<SimpleInterval, AFCRHiddenState>> segmentation = jointSegmenter.findSegments();
    final List<ACNVModeledSegment> segments = segmentation.stream().map(pair -> new ACNVModeledSegment(pair.getLeft(), errorlessPosterior(pair.getRight().getLog2CopyRatio()), errorlessPosterior(pair.getRight().getMinorAlleleFraction()))).collect(Collectors.toList());
    //TODO: make more reasonable output for ACNV 2.0
    SegmentUtils.writeACNVModeledSegmentFile(outputSegmentsFile, segments, new Genome(rcc, acc.getCounts()));
    return "SUCCESS";
}
Also used : DocumentedFeature(org.broadinstitute.barclay.help.DocumentedFeature) ExomeStandardArgumentDefinitions(org.broadinstitute.hellbender.cmdline.ExomeStandardArgumentDefinitions) CommandLineProgramProperties(org.broadinstitute.barclay.argparser.CommandLineProgramProperties) Arrays(java.util.Arrays) CommandLineProgram(org.broadinstitute.hellbender.cmdline.CommandLineProgram) CopyNumberProgramGroup(org.broadinstitute.hellbender.cmdline.programgroups.CopyNumberProgramGroup) Argument(org.broadinstitute.barclay.argparser.Argument) org.broadinstitute.hellbender.tools.exome(org.broadinstitute.hellbender.tools.exome) IOException(java.io.IOException) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) ParamUtils(org.broadinstitute.hellbender.utils.param.ParamUtils) File(java.io.File) List(java.util.List) Pair(org.apache.commons.lang3.tuple.Pair) UserException(org.broadinstitute.hellbender.exceptions.UserException) PosteriorSummary(org.broadinstitute.hellbender.utils.mcmc.PosteriorSummary) AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) DecileCollection(org.broadinstitute.hellbender.utils.mcmc.DecileCollection) IOException(java.io.IOException) AllelicPanelOfNormals(org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) UserException(org.broadinstitute.hellbender.exceptions.UserException) File(java.io.File) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

AllelicPanelOfNormals (org.broadinstitute.hellbender.tools.pon.allelic.AllelicPanelOfNormals)20 AllelicCountCollection (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection)12 File (java.io.File)10 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)8 Test (org.testng.annotations.Test)8 HDF5Library (org.broadinstitute.hdf5.HDF5Library)6 Arrays (java.util.Arrays)4 List (java.util.List)4 Collectors (java.util.stream.Collectors)4 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)4 PosteriorSummary (org.broadinstitute.hellbender.utils.mcmc.PosteriorSummary)4 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)4 DataProvider (org.testng.annotations.DataProvider)4 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 Log (htsjdk.samtools.util.Log)2 IOException (java.io.IOException)2 Map (java.util.Map)2 Pair (org.apache.commons.lang3.tuple.Pair)2 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)2 Argument (org.broadinstitute.barclay.argparser.Argument)2