Enabling Fisher Strand for multi-allelics: use the alt allele with max AC. Added minor optimization to the method in the VC.

This commit is contained in:
Eric Banks 2012-02-27 09:50:09 -05:00
parent d34f07dba0
commit dfdf4f989b
2 changed files with 15 additions and 9 deletions

View File

@ -59,10 +59,10 @@ public class FisherStrand extends InfoFieldAnnotation implements StandardAnnotat
int[][] table;
if (vc.isBiallelic() && vc.isSNP())
table = getSNPContingencyTable(stratifiedContexts, vc.getReference(), vc.getAlternateAllele(0));
else if (vc.isIndel() || vc.isMixed()) {
table = getIndelContingencyTable(stratifiedContexts, vc);
if ( vc.isSNP() )
table = getSNPContingencyTable(stratifiedContexts, vc.getReference(), vc.getAltAlleleWithHighestAlleleCount());
else if ( vc.isIndel() || vc.isMixed() ) {
table = getIndelContingencyTable(stratifiedContexts);
if (table == null)
return null;
}
@ -234,7 +234,7 @@ public class FisherStrand extends InfoFieldAnnotation implements StandardAnnotat
* allele2 # #
* @return a 2x2 contingency table
*/
private static int[][] getIndelContingencyTable(Map<String, AlignmentContext> stratifiedContexts, VariantContext vc) {
private static int[][] getIndelContingencyTable(Map<String, AlignmentContext> stratifiedContexts) {
final double INDEL_LIKELIHOOD_THRESH = 0.3;
final HashMap<PileupElement,LinkedHashMap<Allele,Double>> indelLikelihoodMap = IndelGenotypeLikelihoodsCalculationModel.getIndelLikelihoodMap();

View File

@ -1229,12 +1229,15 @@ public class VariantContext implements Feature { // to enable tribble intergrati
}
public Allele getAltAlleleWithHighestAlleleCount() {
// first idea: get two alleles with highest AC
// optimization: for bi-allelic sites, just return the 1only alt allele
if ( isBiallelic() )
return getAlternateAllele(0);
Allele best = null;
int maxAC1 = 0;
for (Allele a:this.getAlternateAlleles()) {
int ac = this.getCalledChrCount(a);
if (ac >=maxAC1) {
for ( Allele a : getAlternateAlleles() ) {
final int ac = getCalledChrCount(a);
if ( ac >= maxAC1 ) {
maxAC1 = ac;
best = a;
}
@ -1244,6 +1247,9 @@ public class VariantContext implements Feature { // to enable tribble intergrati
}
public int[] getGLIndecesOfAllele(Allele inputAllele) {
// TODO -- this information is cached statically by the UnifiedGenotyperEngine; pull it out into a common utils class for all to use
int[] idxVector = new int[3];
int numAlleles = this.getAlleles().size();