Normalize by the event type counts, not the total genotype counts: more useful normalization.

This commit is contained in:
Chris Hartl 2013-01-09 09:12:41 -05:00
parent b56754606b
commit ad7c2a08d4
2 changed files with 26 additions and 20 deletions

View File

@ -173,23 +173,33 @@ public class ConcordanceMetrics {
return nMismatchingAlt; return nMismatchingAlt;
} }
public int getnEvalGenotypes() { public int getnEvalGenotypes(GenotypeType type) {
int nGeno = 0;
for ( GenotypeType comptype : GenotypeType.values() )
nGeno += genotypeCounts[type.ordinal()][comptype.ordinal()];
return nGeno;
}
public int getnCalledEvalGenotypes() {
int nGeno = 0; int nGeno = 0;
for ( GenotypeType evalType : Arrays.asList(GenotypeType.HOM_REF,GenotypeType.HOM_VAR,GenotypeType.HET) ) { for ( GenotypeType evalType : Arrays.asList(GenotypeType.HOM_REF,GenotypeType.HOM_VAR,GenotypeType.HET) ) {
for ( GenotypeType compType : GenotypeType.values() ) { nGeno += getnEvalGenotypes(evalType);
nGeno += genotypeCounts[evalType.ordinal()][compType.ordinal()];
}
} }
return nGeno + nMismatchingAlt; return nGeno + nMismatchingAlt;
} }
public int getnCompGenotypes() { public int getnCompGenotypes(GenotypeType type) {
int nGeno = 0;
for ( GenotypeType evaltype : GenotypeType.values() )
nGeno += genotypeCounts[evaltype.ordinal()][type.ordinal()];
return nGeno;
}
public int getnCalledCompGenotypes() {
int nGeno = 0; int nGeno = 0;
for ( GenotypeType compType : Arrays.asList(GenotypeType.HOM_REF,GenotypeType.HOM_VAR,GenotypeType.HET) ) { for ( GenotypeType compType : Arrays.asList(GenotypeType.HOM_REF,GenotypeType.HOM_VAR,GenotypeType.HET) ) {
for ( GenotypeType evalType : GenotypeType.values() ) { nGeno += getnCompGenotypes(compType);
nGeno += genotypeCounts[evalType.ordinal()][compType.ordinal()];
}
} }
return nGeno; return nGeno;
} }

View File

@ -114,21 +114,19 @@ public class GenotypeConcordance extends RodWalker<Pair<VariantContext,VariantCo
concordanceEvalProportions.set(entry.getKey(),"Sample",entry.getKey()); concordanceEvalProportions.set(entry.getKey(),"Sample",entry.getKey());
concordanceCompProportions.set(entry.getKey(),"Sample",entry.getKey()); concordanceCompProportions.set(entry.getKey(),"Sample",entry.getKey());
concordanceCounts.set(entry.getKey(),"Sample",entry.getKey()); concordanceCounts.set(entry.getKey(),"Sample",entry.getKey());
int nEval = table.getnEvalGenotypes();
int nComp = table.getnCompGenotypes();
for ( GenotypeType evalType : GenotypeType.values() ) { for ( GenotypeType evalType : GenotypeType.values() ) {
for ( GenotypeType compType : GenotypeType.values() ) { for ( GenotypeType compType : GenotypeType.values() ) {
String colKey = String.format("%s_%s",evalType.toString(),compType.toString()); String colKey = String.format("%s_%s",evalType.toString(),compType.toString());
int count = table.get(evalType, compType); int count = table.get(evalType, compType);
concordanceCounts.set(entry.getKey(),colKey,count); concordanceCounts.set(entry.getKey(),colKey,count);
if ( evalType == GenotypeType.HET || evalType == GenotypeType.HOM_REF || evalType == GenotypeType.HOM_VAR) if ( evalType == GenotypeType.HET || evalType == GenotypeType.HOM_REF || evalType == GenotypeType.HOM_VAR)
concordanceEvalProportions.set(entry.getKey(),colKey,( (double) count)/nEval); concordanceEvalProportions.set(entry.getKey(),colKey,( (double) count)/table.getnEvalGenotypes(evalType));
if ( compType == GenotypeType.HET || compType == GenotypeType.HOM_VAR || compType == GenotypeType.HOM_REF ) if ( compType == GenotypeType.HET || compType == GenotypeType.HOM_VAR || compType == GenotypeType.HOM_REF )
concordanceCompProportions.set(entry.getKey(),colKey,( (double) count)/nComp); concordanceCompProportions.set(entry.getKey(),colKey,( (double) count)/table.getnCompGenotypes(compType));
} }
} }
concordanceEvalProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/nEval); concordanceEvalProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledEvalGenotypes());
concordanceCompProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/nComp); concordanceCompProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledCompGenotypes());
concordanceCounts.set(entry.getKey(),"Mismatching_Alleles",table.getnMismatchingAlt()); concordanceCounts.set(entry.getKey(),"Mismatching_Alleles",table.getnMismatchingAlt());
} }
@ -137,21 +135,19 @@ public class GenotypeConcordance extends RodWalker<Pair<VariantContext,VariantCo
concordanceEvalProportions.set(rowKey,"Sample",rowKey); concordanceEvalProportions.set(rowKey,"Sample",rowKey);
concordanceCounts.set(rowKey,"Sample",rowKey); concordanceCounts.set(rowKey,"Sample",rowKey);
ConcordanceMetrics.GenotypeConcordanceTable table = metrics.getOverallGenotypeConcordance(); ConcordanceMetrics.GenotypeConcordanceTable table = metrics.getOverallGenotypeConcordance();
int nEval = table.getnEvalGenotypes();
int nComp = table.getnCompGenotypes();
for ( GenotypeType evalType : GenotypeType.values() ) { for ( GenotypeType evalType : GenotypeType.values() ) {
for ( GenotypeType compType : GenotypeType.values() ) { for ( GenotypeType compType : GenotypeType.values() ) {
String colKey = String.format("%s_%s",evalType.toString(),compType.toString()); String colKey = String.format("%s_%s",evalType.toString(),compType.toString());
int count = table.get(evalType,compType); int count = table.get(evalType,compType);
concordanceCounts.set(rowKey,colKey,count); concordanceCounts.set(rowKey,colKey,count);
if ( evalType == GenotypeType.HET || evalType == GenotypeType.HOM_REF || evalType == GenotypeType.HOM_VAR) if ( evalType == GenotypeType.HET || evalType == GenotypeType.HOM_REF || evalType == GenotypeType.HOM_VAR)
concordanceEvalProportions.set(rowKey,colKey,( (double) count)/nEval); concordanceEvalProportions.set(rowKey,colKey,( (double) count)/table.getnEvalGenotypes(evalType));
if ( compType == GenotypeType.HET || compType == GenotypeType.HOM_VAR || compType == GenotypeType.HOM_REF ) if ( compType == GenotypeType.HET || compType == GenotypeType.HOM_VAR || compType == GenotypeType.HOM_REF )
concordanceCompProportions.set(rowKey,colKey,( (double) count)/nComp); concordanceCompProportions.set(rowKey,colKey,( (double) count)/table.getnCompGenotypes(compType));
} }
} }
concordanceEvalProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/nEval); concordanceEvalProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledEvalGenotypes());
concordanceCompProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/nComp); concordanceCompProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledCompGenotypes());
concordanceCounts.set(rowKey,"Mismatching_Alleles",table.getnMismatchingAlt()); concordanceCounts.set(rowKey,"Mismatching_Alleles",table.getnMismatchingAlt());
for ( Map.Entry<String,Double> nrsEntry : metrics.getPerSampleNRS().entrySet() ) { for ( Map.Entry<String,Double> nrsEntry : metrics.getPerSampleNRS().entrySet() ) {