Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle overlapping mates in M2 isActive #5078

Merged
merged 1 commit into from
Aug 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class M2ArgumentCollection extends AssemblyBasedCallerArgumentCollection
public static final String EMISSION_LOG_SHORT_NAME = "emit-lod";
public static final String INITIAL_TUMOR_LOD_LONG_NAME = "initial-tumor-lod";
public static final String INITIAL_TUMOR_LOD_SHORT_NAME = "init-lod";
public static final String INITIAL_PCR_ERROR_QUAL = "initial-pcr-qual";
public static final String MAX_POPULATION_AF_LONG_NAME = "max-population-af";
public static final String MAX_POPULATION_AF_SHORT_NAME = "max-af";
public static final String DOWNSAMPLING_STRIDE_LONG_NAME = "downsampling-stride";
Expand Down Expand Up @@ -108,6 +109,12 @@ public double getDefaultAlleleFrequency() {
@Argument(fullName = INITIAL_TUMOR_LOD_LONG_NAME, shortName = INITIAL_TUMOR_LOD_SHORT_NAME, optional = true, doc = "LOD threshold to consider pileup active.")
public double initialTumorLod = 2.0;

/**
* PCR error rate for overlapping fragments in isActive()
*/
@Argument(fullName = INITIAL_PCR_ERROR_QUAL, optional = true, doc = "PCR error rate for overlapping fragments in isActive()")
public int initialPCRErrorQual = 40;

/**
* In tumor-only mode, we discard variants with population allele frequencies greater than this threshold.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ public ActivityProfileState isActive(final AlignmentContext context, final Refer

final ReadPileup pileup = context.getBasePileup();
final ReadPileup tumorPileup = pileup.getPileupForSample(tumorSample, header);
final List<Byte> tumorAltQuals = altQuals(tumorPileup, refBase);
final List<Byte> tumorAltQuals = altQuals(tumorPileup, refBase, MTAC.initialPCRErrorQual);
final double tumorLog10Odds = MathUtils.logToLog10(lnLikelihoodRatio(tumorPileup.size()-tumorAltQuals.size(), tumorAltQuals));

if (tumorLog10Odds < MTAC.initialTumorLod) {
return new ActivityProfileState(refInterval, 0.0);
} else if (hasNormal() && !MTAC.genotypeGermlineSites) {
final ReadPileup normalPileup = pileup.getPileupForSample(normalSample, header);
final List<Byte> normalAltQuals = altQuals(normalPileup, refBase);
final List<Byte> normalAltQuals = altQuals(normalPileup, refBase, MTAC.initialPCRErrorQual);
final int normalAltCount = normalAltQuals.size();
final double normalQualSum = normalAltQuals.stream().mapToDouble(Byte::doubleValue).sum();
if (normalAltCount > normalPileup.size() * MAX_ALT_FRACTION_IN_NORMAL && normalQualSum > MAX_NORMAL_QUAL_SUM) {
Expand Down Expand Up @@ -297,8 +297,9 @@ private static byte indelQual(final int indelLength) {
return (byte) Math.min(INDEL_START_QUAL + (indelLength - 1) * INDEL_CONTINUATION_QUAL, Byte.MAX_VALUE);
}

private static List<Byte> altQuals(final ReadPileup pileup, final byte refBase) {
private static List<Byte> altQuals(final ReadPileup pileup, final byte refBase, final int pcrErrorQual) {
final List<Byte> result = new ArrayList<>();
final int position = pileup.getLocation().getStart();

for (final PileupElement pe : pileup) {
final int indelLength = getCurrentOrFollowingIndelLength(pe);
Expand All @@ -307,7 +308,10 @@ private static List<Byte> altQuals(final ReadPileup pileup, final byte refBase)
} else if (isNextToUsefulSoftClip(pe)) {
result.add(indelQual(1));
} else if (pe.getBase() != refBase && pe.getQual() > MINIMUM_BASE_QUALITY) {
result.add(pe.getQual());
final GATKRead read = pe.getRead();
final int mateStart = read.mateIsUnmapped() ? Integer.MAX_VALUE : read.getMateStart();
final boolean overlapsMate = mateStart <= position && position < mateStart + read.getLength();
result.add(overlapsMate ? (byte) FastMath.min(pe.getQual(), pcrErrorQual/2) : pe.getQual());
}
}

Expand Down