Enabling Rank Sum Tests for multi-allelics: use ref vs any alt allele.
This commit is contained in:
parent
dfdf4f989b
commit
850c5d0db2
|
|
@ -22,12 +22,12 @@ public class BaseQualityRankSumTest extends RankSumTest {
|
|||
|
||||
public List<VCFInfoHeaderLine> getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("BaseQRankSum", 1, VCFHeaderLineType.Float, "Z-score from Wilcoxon rank sum test of Alt Vs. Ref base qualities")); }
|
||||
|
||||
protected void fillQualsFromPileup(byte ref, byte alt, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||
protected void fillQualsFromPileup(byte ref, List<Byte> alts, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||
for ( final PileupElement p : pileup ) {
|
||||
if( isUsableBase(p) ) {
|
||||
if ( p.getBase() == ref )
|
||||
refQuals.add((double)p.getQual());
|
||||
else if ( p.getBase() == alt )
|
||||
else if ( alts.contains(p.getBase()) )
|
||||
altQuals.add((double)p.getQual());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ public class MappingQualityRankSumTest extends RankSumTest {
|
|||
|
||||
public List<VCFInfoHeaderLine> getDescriptions() { return Arrays.asList(new VCFInfoHeaderLine("MQRankSum", 1, VCFHeaderLineType.Float, "Z-score From Wilcoxon rank sum test of Alt vs. Ref read mapping qualities")); }
|
||||
|
||||
protected void fillQualsFromPileup(byte ref, byte alt, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||
protected void fillQualsFromPileup(byte ref, List<Byte> alts, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||
for ( final PileupElement p : pileup ) {
|
||||
if ( isUsableBase(p) ) {
|
||||
if ( p.getBase() == ref ) {
|
||||
refQuals.add((double)p.getMappingQual());
|
||||
} else if ( p.getBase() == alt ) {
|
||||
} else if ( alts.contains(p.getBase()) ) {
|
||||
altQuals.add((double)p.getMappingQual());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.broadinstitute.sting.utils.QualityUtils;
|
|||
import org.broadinstitute.sting.utils.collections.Pair;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
import org.broadinstitute.sting.utils.pileup.ReadBackedPileup;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Genotype;
|
||||
import org.broadinstitute.sting.utils.variantcontext.GenotypesContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
|
@ -41,16 +42,19 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar
|
|||
final ArrayList<Double> refQuals = new ArrayList<Double>();
|
||||
final ArrayList<Double> altQuals = new ArrayList<Double>();
|
||||
|
||||
if (vc.isSNP() && vc.isBiallelic()) {
|
||||
// todo - no current support for multiallelic snps
|
||||
for (final Genotype genotype : genotypes.iterateInSampleNameOrder()) {
|
||||
if ( vc.isSNP() ) {
|
||||
for ( final Genotype genotype : genotypes.iterateInSampleNameOrder() ) {
|
||||
final AlignmentContext context = stratifiedContexts.get(genotype.getSampleName());
|
||||
if (context == null) {
|
||||
if ( context == null )
|
||||
continue;
|
||||
}
|
||||
fillQualsFromPileup(ref.getBase(), vc.getAlternateAllele(0).getBases()[0], context.getBasePileup(), refQuals, altQuals);
|
||||
|
||||
final List<Byte> altAlleles = new ArrayList<Byte>();
|
||||
for ( final Allele a : vc.getAlternateAlleles() )
|
||||
altAlleles.add(a.getBases()[0]);
|
||||
|
||||
fillQualsFromPileup(ref.getBase(), altAlleles, context.getBasePileup(), refQuals, altQuals);
|
||||
}
|
||||
} else if (vc.isIndel() || vc.isMixed()) {
|
||||
} else if ( vc.isIndel() || vc.isMixed() ) {
|
||||
|
||||
for (final Genotype genotype : genotypes.iterateInSampleNameOrder()) {
|
||||
final AlignmentContext context = stratifiedContexts.get(genotype.getSampleName());
|
||||
|
|
@ -105,7 +109,7 @@ public abstract class RankSumTest extends InfoFieldAnnotation implements Standar
|
|||
|
||||
}
|
||||
|
||||
protected abstract void fillQualsFromPileup(byte ref, byte alt, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals);
|
||||
protected abstract void fillQualsFromPileup(byte ref, List<Byte> alts, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals);
|
||||
|
||||
protected abstract void fillIndelQualsFromPileup(ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public class ReadPosRankSumTest extends RankSumTest {
|
|||
return Arrays.asList(new VCFInfoHeaderLine("ReadPosRankSum", 1, VCFHeaderLineType.Float, "Z-score from Wilcoxon rank sum test of Alt vs. Ref read position bias"));
|
||||
}
|
||||
|
||||
protected void fillQualsFromPileup(byte ref, byte alt, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||
protected void fillQualsFromPileup(byte ref, List<Byte> alts, ReadBackedPileup pileup, List<Double> refQuals, List<Double> altQuals) {
|
||||
for (final PileupElement p : pileup) {
|
||||
if (isUsableBase(p)) {
|
||||
int readPos = AlignmentUtils.calcAlignmentByteArrayOffset(p.getRead().getCigar(), p, 0, 0);
|
||||
|
|
@ -41,11 +41,10 @@ public class ReadPosRankSumTest extends RankSumTest {
|
|||
readPos = numAlignedBases - (readPos + 1);
|
||||
|
||||
|
||||
if (p.getBase() == ref)
|
||||
if ( p.getBase() == ref )
|
||||
refQuals.add((double) readPos);
|
||||
else if (p.getBase() == alt)
|
||||
else if ( alts.contains(p.getBase()) )
|
||||
altQuals.add((double) readPos);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue