Fix contact on sorting of AFCalcResults
-- The thing that must be sorted is the pre-theta^N list, which is not checked in the routine that applies the theta^N prior.
This commit is contained in:
parent
eaffb814d3
commit
0fb8274507
|
|
@ -285,9 +285,13 @@ import java.util.*;
|
||||||
// sort the results, so the most likely allele is first
|
// sort the results, so the most likely allele is first
|
||||||
Collections.sort(sorted, compareAFCalcResultsByPNonRef);
|
Collections.sort(sorted, compareAFCalcResultsByPNonRef);
|
||||||
|
|
||||||
|
double lastPosteriorGt0 = sorted.get(0).getLog10PosteriorOfAFGT0();
|
||||||
final double log10SingleAllelePriorOfAFGt0 = conditionalPNonRefResults.get(0).getLog10PriorOfAFGT0();
|
final double log10SingleAllelePriorOfAFGt0 = conditionalPNonRefResults.get(0).getLog10PriorOfAFGT0();
|
||||||
|
|
||||||
for ( int i = 0; i < sorted.size(); i++ ) {
|
for ( int i = 0; i < sorted.size(); i++ ) {
|
||||||
|
if ( sorted.get(i).getLog10PosteriorOfAFGT0() > lastPosteriorGt0 )
|
||||||
|
throw new IllegalStateException("pNonRefResults not sorted: lastPosteriorGt0 " + lastPosteriorGt0 + " but current is " + sorted.get(i).getLog10PosteriorOfAFGT0());
|
||||||
|
|
||||||
final double log10PriorAFGt0 = (i + 1) * log10SingleAllelePriorOfAFGt0;
|
final double log10PriorAFGt0 = (i + 1) * log10SingleAllelePriorOfAFGt0;
|
||||||
final double log10PriorAFEq0 = Math.log10(1 - Math.pow(10, log10PriorAFGt0));
|
final double log10PriorAFEq0 = Math.log10(1 - Math.pow(10, log10PriorAFGt0));
|
||||||
final double[] thetaTONPriors = new double[] { log10PriorAFEq0, log10PriorAFGt0 };
|
final double[] thetaTONPriors = new double[] { log10PriorAFEq0, log10PriorAFGt0 };
|
||||||
|
|
@ -313,7 +317,6 @@ import java.util.*;
|
||||||
*
|
*
|
||||||
* @param sortedResultsWithThetaNPriors the pNonRef result for each allele independently
|
* @param sortedResultsWithThetaNPriors the pNonRef result for each allele independently
|
||||||
*/
|
*/
|
||||||
@Requires("sortedByPosteriorGT(sortedResultsWithThetaNPriors)")
|
|
||||||
protected AFCalcResult combineIndependentPNonRefs(final VariantContext vc,
|
protected AFCalcResult combineIndependentPNonRefs(final VariantContext vc,
|
||||||
final List<AFCalcResult> sortedResultsWithThetaNPriors) {
|
final List<AFCalcResult> sortedResultsWithThetaNPriors) {
|
||||||
int nEvaluations = 0;
|
int nEvaluations = 0;
|
||||||
|
|
@ -374,14 +377,4 @@ import java.util.*;
|
||||||
MathUtils.normalizeFromLog10(log10PriorsOfAC, true),
|
MathUtils.normalizeFromLog10(log10PriorsOfAC, true),
|
||||||
log10pNonRefByAllele, sortedResultsWithThetaNPriors);
|
log10pNonRefByAllele, sortedResultsWithThetaNPriors);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean sortedByPosteriorGT(final List<AFCalcResult> sortedVCs) {
|
|
||||||
double lastPosteriorGt0 = sortedVCs.get(0).getLog10PosteriorOfAFGT0();
|
|
||||||
for ( final AFCalcResult vc : sortedVCs ) {
|
|
||||||
if ( vc.getLog10PosteriorOfAFGT0() > lastPosteriorGt0 )
|
|
||||||
return false;
|
|
||||||
lastPosteriorGt0 = vc.getLog10PosteriorOfAFGT0();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue