A few improvements to pooled concordance calcluations. Now will show you FN with the -V option. BasicGenotype now prints out a reasonable representaiton wiwth toString

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2320 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
depristo 2009-12-10 23:09:10 +00:00
parent f64a4c66ac
commit 8f7554d44f
3 changed files with 24 additions and 9 deletions

View File

@ -90,19 +90,19 @@ public abstract class ChipConcordance extends BasicVariantAnalysis {
// don't procede if we have no truth data and no call // don't procede if we have no truth data and no call
if ( eval != null || chips.size() > 0 ) if ( eval != null || chips.size() > 0 )
inc(chips, eval, ref); return inc(chips, eval, ref);
else
return null; return null;
} }
public void inc(Map<String, Genotype> chips, Variation eval, char ref) { public String inc(Map<String, Genotype> chips, Variation eval, char ref) {
// each implementing class can decide whether the Variation is valid // each implementing class can decide whether the Variation is valid
assertVariationIsValid(eval); assertVariationIsValid(eval);
// This shouldn't happen, but let's check anyways to be safe // This shouldn't happen, but let's check anyways to be safe
if (BaseUtils.simpleBaseToBaseIndex(ref) == -1) if (BaseUtils.simpleBaseToBaseIndex(ref) == -1)
return; return null;
// create a hash of samples to their Genotypes // create a hash of samples to their Genotypes
List<Genotype> evals = (eval != null ? ((VariantBackedByGenotype)eval).getGenotypes() : new ArrayList<Genotype>()); List<Genotype> evals = (eval != null ? ((VariantBackedByGenotype)eval).getGenotypes() : new ArrayList<Genotype>());
@ -124,12 +124,17 @@ public abstract class ChipConcordance extends BasicVariantAnalysis {
} }
// now we can finally update our truth tables with the truth vs. calls data // now we can finally update our truth tables with the truth vs. calls data
StringBuilder s = new StringBuilder();
for (int i = 0; i < truthTables.length; i++) { for (int i = 0; i < truthTables.length; i++) {
if ( chipEvals[i] != null ) { if ( chipEvals[i] != null ) {
ConcordanceTruthTable table = truthTables[i]; ConcordanceTruthTable table = truthTables[i];
table.addEntry(chipEvals[i], eval, ref); String x = table.addEntry(chipEvals[i], eval, ref);
if ( x != null ) s.append(x);
} }
} }
String toReturn = s.toString();
return toReturn.equals("") ? null : toReturn;
} }
public List<String> done() { public List<String> done() {

View File

@ -17,7 +17,6 @@ import java.util.*;
* the Broad Institute nor MIT can be responsible for its use, misuse, or functionality. * the Broad Institute nor MIT can be responsible for its use, misuse, or functionality.
*/ */
public class ConcordanceTruthTable { public class ConcordanceTruthTable {
private static final int TRUE_POSITIVE = 0; private static final int TRUE_POSITIVE = 0;
private static final int TRUE_NEGATIVE = 1; private static final int TRUE_NEGATIVE = 1;
private static final int FALSE_POSITIVE = 2; private static final int FALSE_POSITIVE = 2;
@ -83,7 +82,8 @@ public class ConcordanceTruthTable {
// System.out.println("Table Size: "+table.length+" by "+table[1].length); // System.out.println("Table Size: "+table.length+" by "+table[1].length);
} }
public void addEntry(List<Pair<Genotype, Genotype>> chipEvals, Variation eval, char ref) { public String addEntry(List<Pair<Genotype, Genotype>> chipEvals, Variation eval, char ref) {
String violation = null;
// if the table represents a single sample, then we can calculate genotype stats // if the table represents a single sample, then we can calculate genotype stats
if ( singleSampleMode ) { if ( singleSampleMode ) {
@ -114,7 +114,13 @@ public class ConcordanceTruthTable {
int callType = getCallIndex(eval,ref); int callType = getCallIndex(eval,ref);
addFrequencyEntry( truthType,callType,poolVariant.getSecond().getFirst() ); int numTrueSupportingAlleles = poolVariant.getSecond().getFirst();
if ( numTrueSupportingAlleles > 0 && truthType == VARIANT && callType != VARIANT ) {
violation = String.format("False negative: %s with %d alt alleles",
chipEvals.get(0).getFirst(), numTrueSupportingAlleles);
}
addFrequencyEntry( truthType,callType, poolVariant.getSecond().getFirst() );
} }
@ -122,6 +128,7 @@ public class ConcordanceTruthTable {
// TODO -- You'll want to use eval and the chips from chipEvals (these are the first members of the pair) // TODO -- You'll want to use eval and the chips from chipEvals (these are the first members of the pair)
// TODO -- You'll also need to declare (and initialize) the relevant data arrays for the data // TODO -- You'll also need to declare (and initialize) the relevant data arrays for the data
// TODO -- Indexes like TRUE_POSITIVE are defined above for you // TODO -- Indexes like TRUE_POSITIVE are defined above for you
return violation;
} }
public Pair< Genotype , Pair<Integer,Integer> > getPooledAlleleFrequency( List<Pair<Genotype,Genotype>> chips, char ref) { public Pair< Genotype , Pair<Integer,Integer> > getPooledAlleleFrequency( List<Pair<Genotype,Genotype>> chips, char ref) {

View File

@ -168,4 +168,7 @@ public class BasicGenotype implements Genotype {
return builder.toString(); return builder.toString();
} }
public String toString() {
return String.format("[%s %s]", getLocation(), getBases());
}
} }