Search in sources :

Example 1 with AlleleFractionState

use of org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState in project gatk by broadinstitute.

the class AllelicCNV method calculateAllelicBias.

//use AlleleFractionInitializer to determine mean of global allelic-bias distribution given SNP segmentation file
private double calculateAllelicBias(final Genome genome, final File snpSegmentFile) {
    final SegmentedGenome segmentedGenomeForSNPSegmentation = new SegmentedGenome(snpSegmentFile, genome);
    final AlleleFractionData data = new AlleleFractionData(segmentedGenomeForSNPSegmentation);
    final AlleleFractionState initialState = new AlleleFractionInitializer(data).getInitializedState();
    return initialState.meanBias();
}
Also used : AlleleFractionState(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState) AlleleFractionData(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionData) AlleleFractionInitializer(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionInitializer)

Example 2 with AlleleFractionState

use of org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState in project gatk-protected by broadinstitute.

the class AllelicCNV method calculateAllelicBias.

//use AlleleFractionInitializer to determine mean of global allelic-bias distribution given SNP segmentation file
private double calculateAllelicBias(final Genome genome, final File snpSegmentFile) {
    final SegmentedGenome segmentedGenomeForSNPSegmentation = new SegmentedGenome(snpSegmentFile, genome);
    final AlleleFractionData data = new AlleleFractionData(segmentedGenomeForSNPSegmentation);
    final AlleleFractionState initialState = new AlleleFractionInitializer(data).getInitializedState();
    return initialState.meanBias();
}
Also used : AlleleFractionState(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState) AlleleFractionData(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionData) AlleleFractionInitializer(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionInitializer)

Example 3 with AlleleFractionState

use of org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState in project gatk-protected by broadinstitute.

the class CalculatePulldownPhasePosteriorsIntegrationTest method testCalculatePhasePosteriors.

/**
     * Uses {@link AlleleFractionSimulatedData} to test recovery of phase indicators.  Phase with highest posterior
     * probability is compared to the true phase; we require that
     * {@link CalculatePulldownPhasePosteriorsIntegrationTest#FRACTION_OF_INDICATORS_CORRECT_THRESHOLD} of the
     * indicators are recovered correctly.
     */
@Test
public void testCalculatePhasePosteriors() {
    final double averageHetsPerSegment = 100;
    final int numSegments = 100;
    final int averageDepth = 100;
    final double biasMean = 1.1;
    final double biasVariance = 0.01;
    final double outlierProbability = 0.02;
    final AlleleFractionSimulatedData simulatedData = new AlleleFractionSimulatedData(averageHetsPerSegment, numSegments, averageDepth, biasMean, biasVariance, outlierProbability);
    final SegmentedGenome segmentedGenome = simulatedData.getSegmentedGenome();
    final AlleleFractionState trueState = simulatedData.getTrueState();
    final AlleleFractionSimulatedData.PhaseIndicators truePhases = simulatedData.getTruePhases();
    final AllelicCountCollection counts = new AllelicCountCollection();
    //note that chromosomes are in lexicographical order
    segmentedGenome.getGenome().getSNPs().targets().stream().forEach(counts::add);
    final AllelicCountWithPhasePosteriorsCollection countsWithPhasePosteriors = CalculatePulldownPhasePosteriors.calculatePhasePosteriors(counts, segmentedGenome.getSegments(), trueState, AllelicPanelOfNormals.EMPTY_PON);
    int numIndicatorsCorrect = 0;
    //order is ALT_MINOR, REF_MINOR, OUTLIER
    final Iterator<AlleleFractionIndicator> phaseIterator = truePhases.iterator();
    final Iterator<AllelicCountWithPhasePosteriors> countWithPhasePosteriorsIterator = countsWithPhasePosteriors.getCounts().iterator();
    while (phaseIterator.hasNext() && countWithPhasePosteriorsIterator.hasNext()) {
        final AlleleFractionIndicator truePhase = phaseIterator.next();
        final AllelicCountWithPhasePosteriors countWithPhasePosteriors = countWithPhasePosteriorsIterator.next();
        final List<Double> phaseProbabilities = Arrays.asList(countWithPhasePosteriors.getAltMinorProb(), countWithPhasePosteriors.getRefMinorProb(), countWithPhasePosteriors.getOutlierProb());
        final int indexOfMaxProbPhase = phaseProbabilities.indexOf(Collections.max(phaseProbabilities));
        final AlleleFractionIndicator maxProbPhase = AlleleFractionIndicator.values()[indexOfMaxProbPhase];
        if (maxProbPhase.equals(truePhase)) {
            numIndicatorsCorrect++;
        }
    }
    final double fractionOfIndicatorsCorrect = (double) numIndicatorsCorrect / countsWithPhasePosteriors.getCounts().size();
    Assert.assertTrue(fractionOfIndicatorsCorrect >= FRACTION_OF_INDICATORS_CORRECT_THRESHOLD);
}
Also used : AllelicCountWithPhasePosteriorsCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountWithPhasePosteriorsCollection) AlleleFractionIndicator(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionIndicator) AllelicCountWithPhasePosteriors(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountWithPhasePosteriors) AlleleFractionState(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState) AlleleFractionSimulatedData(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionSimulatedData) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Example 4 with AlleleFractionState

use of org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState in project gatk by broadinstitute.

the class CalculatePulldownPhasePosteriorsIntegrationTest method testCalculatePhasePosteriors.

/**
     * Uses {@link AlleleFractionSimulatedData} to test recovery of phase indicators.  Phase with highest posterior
     * probability is compared to the true phase; we require that
     * {@link CalculatePulldownPhasePosteriorsIntegrationTest#FRACTION_OF_INDICATORS_CORRECT_THRESHOLD} of the
     * indicators are recovered correctly.
     */
@Test
public void testCalculatePhasePosteriors() {
    final double averageHetsPerSegment = 100;
    final int numSegments = 100;
    final int averageDepth = 100;
    final double biasMean = 1.1;
    final double biasVariance = 0.01;
    final double outlierProbability = 0.02;
    final AlleleFractionSimulatedData simulatedData = new AlleleFractionSimulatedData(averageHetsPerSegment, numSegments, averageDepth, biasMean, biasVariance, outlierProbability);
    final SegmentedGenome segmentedGenome = simulatedData.getSegmentedGenome();
    final AlleleFractionState trueState = simulatedData.getTrueState();
    final AlleleFractionSimulatedData.PhaseIndicators truePhases = simulatedData.getTruePhases();
    final AllelicCountCollection counts = new AllelicCountCollection();
    //note that chromosomes are in lexicographical order
    segmentedGenome.getGenome().getSNPs().targets().stream().forEach(counts::add);
    final AllelicCountWithPhasePosteriorsCollection countsWithPhasePosteriors = CalculatePulldownPhasePosteriors.calculatePhasePosteriors(counts, segmentedGenome.getSegments(), trueState, AllelicPanelOfNormals.EMPTY_PON);
    int numIndicatorsCorrect = 0;
    //order is ALT_MINOR, REF_MINOR, OUTLIER
    final Iterator<AlleleFractionIndicator> phaseIterator = truePhases.iterator();
    final Iterator<AllelicCountWithPhasePosteriors> countWithPhasePosteriorsIterator = countsWithPhasePosteriors.getCounts().iterator();
    while (phaseIterator.hasNext() && countWithPhasePosteriorsIterator.hasNext()) {
        final AlleleFractionIndicator truePhase = phaseIterator.next();
        final AllelicCountWithPhasePosteriors countWithPhasePosteriors = countWithPhasePosteriorsIterator.next();
        final List<Double> phaseProbabilities = Arrays.asList(countWithPhasePosteriors.getAltMinorProb(), countWithPhasePosteriors.getRefMinorProb(), countWithPhasePosteriors.getOutlierProb());
        final int indexOfMaxProbPhase = phaseProbabilities.indexOf(Collections.max(phaseProbabilities));
        final AlleleFractionIndicator maxProbPhase = AlleleFractionIndicator.values()[indexOfMaxProbPhase];
        if (maxProbPhase.equals(truePhase)) {
            numIndicatorsCorrect++;
        }
    }
    final double fractionOfIndicatorsCorrect = (double) numIndicatorsCorrect / countsWithPhasePosteriors.getCounts().size();
    Assert.assertTrue(fractionOfIndicatorsCorrect >= FRACTION_OF_INDICATORS_CORRECT_THRESHOLD);
}
Also used : AllelicCountWithPhasePosteriorsCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountWithPhasePosteriorsCollection) AlleleFractionIndicator(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionIndicator) AllelicCountWithPhasePosteriors(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountWithPhasePosteriors) AlleleFractionState(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState) AlleleFractionSimulatedData(org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionSimulatedData) AllelicCountCollection(org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection) Test(org.testng.annotations.Test) CommandLineProgramTest(org.broadinstitute.hellbender.CommandLineProgramTest)

Aggregations

AlleleFractionState (org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionState)4 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)2 AlleleFractionData (org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionData)2 AlleleFractionIndicator (org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionIndicator)2 AlleleFractionInitializer (org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionInitializer)2 AlleleFractionSimulatedData (org.broadinstitute.hellbender.tools.exome.allelefraction.AlleleFractionSimulatedData)2 AllelicCountCollection (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountCollection)2 AllelicCountWithPhasePosteriors (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountWithPhasePosteriors)2 AllelicCountWithPhasePosteriorsCollection (org.broadinstitute.hellbender.tools.exome.alleliccount.AllelicCountWithPhasePosteriorsCollection)2 Test (org.testng.annotations.Test)2