use of org.broadinstitute.hellbender.tools.exome.ACNVModeledSegment in project gatk by broadinstitute.
the class CNLOHCaller method calculateESmnObjective.
// Returns a single number that is the total likelihood. Note that it does this for the given rho, even though
// the entire responsibility 4d array (list of 3d, where list is per segment, then each array is KxMxN)
// is passed in.
//
// HACK: All rhos have to be passed in with the index of interest. Under the hood, all other values of rho are ignored.
private double calculateESmnObjective(final double rho, List<ACNVModeledSegment> segments, final List<double[][][]> responsibilitiesForSegsAsList, final int[] mVals, final int[] nVals, final double lambda, final int rhoIndex) {
// We will want to sum an entire matrix that is S x M x N for the given rho.
final double[][][] eSMN = new double[responsibilitiesForSegsAsList.size()][mVals.length][nVals.length];
// Populate eSMN
for (int s = 0; s < responsibilitiesForSegsAsList.size(); s++) {
final ACNVModeledSegment seg = segments.get(s);
final double mafMode = seg.getMinorAlleleFractionPosteriorSummary().getCenter();
final double mafLow = seg.getMinorAlleleFractionPosteriorSummary().getLower();
final double mafHigh = seg.getMinorAlleleFractionPosteriorSummary().getUpper();
final double crMode = Math.pow(2, seg.getSegmentMeanPosteriorSummary().getCenter()) - segmentMeanBiasInCR;
final double crLow = Math.pow(2, seg.getSegmentMeanPosteriorSummary().getLower()) - segmentMeanBiasInCR;
final double crHigh = Math.pow(2, seg.getSegmentMeanPosteriorSummary().getUpper()) - segmentMeanBiasInCR;
for (int m = 0; m < mVals.length; m++) {
for (int n = 0; n < nVals.length; n++) {
final double mafLikelihood = calculateFmaf(rho, mVals[m], nVals[n], mafMode, mafLow, mafHigh, normalNumCopies);
final double crLikelihood = calculateFcr(rho, mVals[m], nVals[n], lambda, crMode, crLow, crHigh, segmentMeanVarianceInCR, normalNumCopies);
if (((rho > 1) || (rho < 0)) || ((rho > 0) && (rho < rhoThreshold))) {
eSMN[s][m][n] = MIN_L;
} else {
eSMN[s][m][n] = responsibilitiesForSegsAsList.get(s)[rhoIndex][m][n] * Math.log(mafLikelihood * crLikelihood);
}
}
}
}
return GATKProtectedMathUtils.sum(eSMN);
}
use of org.broadinstitute.hellbender.tools.exome.ACNVModeledSegment in project gatk-protected by broadinstitute.
the class PerformJointSegmentationIntegrationTest method testCommandLine.
// checks that segmentation output is created -- only the unit test checks correctness of results
@Test
public void testCommandLine() throws IOException {
final File tnCoverageFile = LOG2_TN_COVERAGE_FILE;
final File snpFile = ALLELIC_COUNTS_FILE;
final File outputSegmentFile = createTempFile("segments", ".seg");
final int initialNumCRStates = 3;
final int initialNumAFStates = 3;
final String[] arguments = { "-" + ExomeStandardArgumentDefinitions.TANGENT_NORMALIZED_COUNTS_FILE_SHORT_NAME, tnCoverageFile.getAbsolutePath(), "-" + ExomeStandardArgumentDefinitions.TUMOR_ALLELIC_COUNTS_FILE_SHORT_NAME, snpFile.getAbsolutePath(), "-" + PerformJointSegmentation.INITIAL_NUM_COPY_RATIO_STATES_SHORT_NAME, Integer.toString(initialNumCRStates), "-" + PerformJointSegmentation.INITIAL_NUM_ALLELE_FRACTION_STATES_SHORT_NAME, Integer.toString(initialNumAFStates), "-" + ExomeStandardArgumentDefinitions.SEGMENT_FILE_SHORT_NAME, outputSegmentFile.getAbsolutePath() };
runCommandLine(arguments);
final List<ACNVModeledSegment> segments = SegmentUtils.readACNVModeledSegmentFile(outputSegmentFile);
}
use of org.broadinstitute.hellbender.tools.exome.ACNVModeledSegment in project gatk by broadinstitute.
the class AllelicSplitCallerModelStateUnitTest method testBasicInit.
@Test
public void testBasicInit() {
final ACNVModeledSegment acnvModeledSegment = new ACNVModeledSegment(new SimpleInterval("1", 1000, 1500), new PosteriorSummary(-4000, -4001, -4002), new PosteriorSummary(-4000, -4001, -4002));
final List<ACNVModeledSegment> tempList = new ArrayList<>();
tempList.add(acnvModeledSegment);
final AllelicBalanceCallerModelState state = AllelicBalanceCallerModelState.createInitialCNLOHCallerModelState(0.2, tempList, HomoSapiensConstants.DEFAULT_PLOIDY, CNLOHCaller.NUM_RHOS);
Assert.assertNotNull(state);
Assert.assertNotNull(state.getEffectivePis());
Assert.assertTrue(state.getEffectivePis().length > 0);
Assert.assertTrue(state.getmVals().length > 0);
Assert.assertTrue(state.getnVals().length > 0);
Assert.assertEquals(MathUtils.sum(state.getEffectivePis()), 1.0, 1e-10);
}
use of org.broadinstitute.hellbender.tools.exome.ACNVModeledSegment in project gatk-protected by broadinstitute.
the class ACSModeledSegmentUtilsUnitTest method testConversion.
@Test
public void testConversion() {
final List<ACNVModeledSegment> segs = SegmentUtils.readACNVModeledSegmentFile(new File(TEST_FILE_PATH));
final Genome genome = new Genome(AlleleFractionSimulatedData.TRIVIAL_TARGETS, Collections.emptyList());
final List<ACSModeledSegment> acsSegs = segs.stream().map(seg -> ACSModeledSegmentUtils.convertACNVSegmentToACSSegment(seg, 2.0, genome, true)).collect(Collectors.toList());
for (int i = 0; i < segs.size(); i++) {
Assert.assertEquals(acsSegs.get(i).getTau() / 2.0, segs.get(i).getSegmentMeanInCRSpace(), 1e-10);
}
}
use of org.broadinstitute.hellbender.tools.exome.ACNVModeledSegment in project gatk-protected by broadinstitute.
the class AllelicSplitCallerModelStateUnitTest method testSerializationRoundTrip.
@Test
public void testSerializationRoundTrip() {
final ACNVModeledSegment acnvModeledSegment = new ACNVModeledSegment(new SimpleInterval("1", 1000, 1500), new PosteriorSummary(-4000, -4001, -4002), new PosteriorSummary(-4000, -4001, -4002));
final List<ACNVModeledSegment> tempList = new ArrayList<>();
tempList.add(acnvModeledSegment);
final AllelicBalanceCallerModelState state = AllelicBalanceCallerModelState.createInitialCNLOHCallerModelState(0.2, tempList, HomoSapiensConstants.DEFAULT_PLOIDY, CNLOHCaller.NUM_RHOS);
SparkTestUtils.roundTripInKryo(state, AllelicBalanceCallerModelState.class, SparkContextFactory.getTestSparkContext().getConf());
}
Aggregations