1. VCF: don't print slod if it's never set

2. UG: don't print slod if lods are infinite (todo: figure out a good guess instead)
3. UG: if probF=0 for 2 alt alleles are both 0 (because of precision), use log values to discriminate



git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2116 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-11-23 02:55:43 +00:00
parent 753cb100a3
commit dfe7d69471
4 changed files with 36 additions and 28 deletions

View File

@ -63,7 +63,6 @@ public abstract class JointEstimateGenotypeCalculationModel extends GenotypeCalc
} }
protected void initializeVerboseWriter(PrintWriter verboseWriter) { protected void initializeVerboseWriter(PrintWriter verboseWriter) {
// by default, no initialization is done
StringBuilder header = new StringBuilder("AFINFO\tLOC\tMAF\tF\tNullAFpriors\t"); StringBuilder header = new StringBuilder("AFINFO\tLOC\tMAF\tF\tNullAFpriors\t");
for ( char altAllele : BaseUtils.BASES ) { for ( char altAllele : BaseUtils.BASES ) {
char base = Character.toLowerCase(altAllele); char base = Character.toLowerCase(altAllele);
@ -229,7 +228,8 @@ public abstract class JointEstimateGenotypeCalculationModel extends GenotypeCalc
for ( char altAllele : BaseUtils.BASES ) { for ( char altAllele : BaseUtils.BASES ) {
if ( altAllele != ref ) { if ( altAllele != ref ) {
int baseIndex = BaseUtils.simpleBaseToBaseIndex(altAllele); int baseIndex = BaseUtils.simpleBaseToBaseIndex(altAllele);
if ( PofFs[baseIndex] > maxConfidence ) { if ( PofFs[baseIndex] > maxConfidence ||
(MathUtils.compareDoubles(PofFs[baseIndex], maxConfidence) == 0 && log10PofDgivenAFi[baseIndex][0] < log10PofDgivenAFi[indexOfMax][0]) ) {
indexOfMax = baseIndex; indexOfMax = baseIndex;
baseOfMax = altAllele; baseOfMax = altAllele;
maxConfidence = PofFs[baseIndex]; maxConfidence = PofFs[baseIndex];
@ -273,31 +273,38 @@ public abstract class JointEstimateGenotypeCalculationModel extends GenotypeCalc
double overallLog10PofF = Math.log10(PofFs[indexOfMax]); double overallLog10PofF = Math.log10(PofFs[indexOfMax]);
double lod = overallLog10PofF - overallLog10PofNull; double lod = overallLog10PofF - overallLog10PofNull;
// the forward lod // I'm not sure what to do when the numbers are so small as to make the lod infinite.
initialize(ref, contexts, StratifiedContext.FORWARD); // For now, we'll just not compute strand bias...
calculateAlleleFrequencyPosteriors(ref, frequencyEstimationPoints, contexts, StratifiedContext.FORWARD); if ( !Double.isInfinite(lod) ) {
calculatePofFs(ref, frequencyEstimationPoints);
double forwardLog10PofNull = Math.log10(alleleFrequencyPosteriors[indexOfMax][0]);
double forwardLog10PofF = Math.log10(PofFs[indexOfMax]);
// the reverse lod // the forward lod
initialize(ref, contexts, StratifiedContext.REVERSE); initialize(ref, contexts, StratifiedContext.FORWARD);
calculateAlleleFrequencyPosteriors(ref, frequencyEstimationPoints, contexts, StratifiedContext.REVERSE); calculateAlleleFrequencyPosteriors(ref, frequencyEstimationPoints, contexts, StratifiedContext.FORWARD);
calculatePofFs(ref, frequencyEstimationPoints); calculatePofFs(ref, frequencyEstimationPoints);
double reverseLog10PofNull = Math.log10(alleleFrequencyPosteriors[indexOfMax][0]); double forwardLog10PofNull = Math.log10(alleleFrequencyPosteriors[indexOfMax][0]);
double reverseLog10PofF = Math.log10(PofFs[indexOfMax]); double forwardLog10PofF = Math.log10(PofFs[indexOfMax]);
if ( Double.isInfinite(lod) )
lod = -1.0 * log10PofDgivenAFi[indexOfMax][0];
double forwardLod = forwardLog10PofF + reverseLog10PofNull - overallLog10PofNull; // the reverse lod
double reverseLod = reverseLog10PofF + forwardLog10PofNull - overallLog10PofNull; initialize(ref, contexts, StratifiedContext.REVERSE);
//logger.debug("forward lod=" + forwardLod + ", reverse lod=" + reverseLod); calculateAlleleFrequencyPosteriors(ref, frequencyEstimationPoints, contexts, StratifiedContext.REVERSE);
calculatePofFs(ref, frequencyEstimationPoints);
double reverseLog10PofNull = Math.log10(alleleFrequencyPosteriors[indexOfMax][0]);
double reverseLog10PofF = Math.log10(PofFs[indexOfMax]);
// strand score is max bias between forward and reverse strands double forwardLod = forwardLog10PofF + reverseLog10PofNull - overallLog10PofNull;
double strandScore = Math.max(forwardLod - lod, reverseLod - lod); double reverseLod = reverseLog10PofF + forwardLog10PofNull - overallLog10PofNull;
// rescale by a factor of 10 //logger.debug("forward lod=" + forwardLod + ", reverse lod=" + reverseLod);
strandScore *= 10.0;
//logger.debug(String.format("SLOD=%f", strandScore));
((SLODBacked)locusdata).setSLOD(strandScore); // strand score is max bias between forward and reverse strands
double strandScore = Math.max(forwardLod - lod, reverseLod - lod);
// rescale by a factor of 10
strandScore *= 10.0;
//logger.debug(String.format("SLOD=%f", strandScore));
((SLODBacked)locusdata).setSLOD(strandScore);
}
} }
} }

View File

@ -11,9 +11,9 @@ public interface SLODBacked {
/** /**
* *
* @return returns the strand lod for this genotype * @return returns the strand lod for this genotype or null if not set
*/ */
public double getSLOD(); public Double getSLOD();
/** /**
* *

View File

@ -19,7 +19,7 @@ public class VCFGenotypeLocusData implements GenotypeLocusData, ConfidenceBacked
private double mConfidence = 0.0; private double mConfidence = 0.0;
// the strand score lod // the strand score lod
private double mSLOD = 0.0; private Double mSLOD = null;
// the allele frequency field // the allele frequency field
private double mAlleleFrequency = 0.0; private double mAlleleFrequency = 0.0;
@ -103,7 +103,7 @@ public class VCFGenotypeLocusData implements GenotypeLocusData, ConfidenceBacked
* *
* @return the strand lod * @return the strand lod
*/ */
public double getSLOD() { public Double getSLOD() {
return mSLOD; return mSLOD;
} }

View File

@ -187,7 +187,8 @@ public class VCFGenotypeWriterAdapter implements GenotypeWriter {
private static Map<String, String> getInfoFields(VCFGenotypeLocusData locusdata, VCFParameters params) { private static Map<String, String> getInfoFields(VCFGenotypeLocusData locusdata, VCFParameters params) {
Map<String, String> infoFields = new HashMap<String, String>(); Map<String, String> infoFields = new HashMap<String, String>();
if ( locusdata != null ) { if ( locusdata != null ) {
infoFields.put("SB", String.format("%.2f", locusdata.getSLOD())); if ( locusdata.getSLOD() != null )
infoFields.put("SB", String.format("%.2f", locusdata.getSLOD()));
infoFields.put("AF", String.format("%.2f", locusdata.getAlleleFrequency())); infoFields.put("AF", String.format("%.2f", locusdata.getAlleleFrequency()));
Map<String, String> otherFields = locusdata.getFields(); Map<String, String> otherFields = locusdata.getFields();
if ( otherFields != null ) { if ( otherFields != null ) {