Normalize by the event type counts, not the total genotype counts: more useful normalization.
This commit is contained in:
parent
b56754606b
commit
ad7c2a08d4
|
|
@ -173,23 +173,33 @@ public class ConcordanceMetrics {
|
|||
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;
|
||||
for ( GenotypeType evalType : Arrays.asList(GenotypeType.HOM_REF,GenotypeType.HOM_VAR,GenotypeType.HET) ) {
|
||||
for ( GenotypeType compType : GenotypeType.values() ) {
|
||||
nGeno += genotypeCounts[evalType.ordinal()][compType.ordinal()];
|
||||
}
|
||||
nGeno += getnEvalGenotypes(evalType);
|
||||
}
|
||||
|
||||
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;
|
||||
for ( GenotypeType compType : Arrays.asList(GenotypeType.HOM_REF,GenotypeType.HOM_VAR,GenotypeType.HET) ) {
|
||||
for ( GenotypeType evalType : GenotypeType.values() ) {
|
||||
nGeno += genotypeCounts[evalType.ordinal()][compType.ordinal()];
|
||||
}
|
||||
nGeno += getnCompGenotypes(compType);
|
||||
}
|
||||
return nGeno;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,21 +114,19 @@ public class GenotypeConcordance extends RodWalker<Pair<VariantContext,VariantCo
|
|||
concordanceEvalProportions.set(entry.getKey(),"Sample",entry.getKey());
|
||||
concordanceCompProportions.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 compType : GenotypeType.values() ) {
|
||||
String colKey = String.format("%s_%s",evalType.toString(),compType.toString());
|
||||
int count = table.get(evalType, compType);
|
||||
concordanceCounts.set(entry.getKey(),colKey,count);
|
||||
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 )
|
||||
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);
|
||||
concordanceCompProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/nComp);
|
||||
concordanceEvalProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledEvalGenotypes());
|
||||
concordanceCompProportions.set(entry.getKey(),"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledCompGenotypes());
|
||||
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);
|
||||
concordanceCounts.set(rowKey,"Sample",rowKey);
|
||||
ConcordanceMetrics.GenotypeConcordanceTable table = metrics.getOverallGenotypeConcordance();
|
||||
int nEval = table.getnEvalGenotypes();
|
||||
int nComp = table.getnCompGenotypes();
|
||||
for ( GenotypeType evalType : GenotypeType.values() ) {
|
||||
for ( GenotypeType compType : GenotypeType.values() ) {
|
||||
String colKey = String.format("%s_%s",evalType.toString(),compType.toString());
|
||||
int count = table.get(evalType,compType);
|
||||
concordanceCounts.set(rowKey,colKey,count);
|
||||
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 )
|
||||
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);
|
||||
concordanceCompProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/nComp);
|
||||
concordanceEvalProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledEvalGenotypes());
|
||||
concordanceCompProportions.set(rowKey,"Mismatching_Alleles", ( (double) table.getnMismatchingAlt() )/table.getnCalledCompGenotypes());
|
||||
concordanceCounts.set(rowKey,"Mismatching_Alleles",table.getnMismatchingAlt());
|
||||
|
||||
for ( Map.Entry<String,Double> nrsEntry : metrics.getPerSampleNRS().entrySet() ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue