Skip to content

Mutect2 works with multiple tumor and normal samples. - #5560

Merged
davidbenjamin merged 5 commits into
masterfrom
db_m2_multiple
Jan 9, 2019
Merged

davidbenjamin merged 5 commits into
masterfrom
db_m2_multiple

Conversation

@davidbenjamin

Copy link
Copy Markdown
Contributor

@takutosato Most of this PR is refactoring to make filtering work for multiple samples while leaving single-pair output unchanged. For example, moving FORMAT annotations to the INFO field, keeping track of the sample of orientation bias priors etc.

I'm leaving the wdl unchanged for now. It will still work with the new release.

@ldgauthier ldgauthier left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor suggestions and questions. Our annotation system is so kludgy, but I don't have a lot of suggestions for reducing the amount of boilerplate.

if (MTAC.mitochondria) {
final Set<String> samples = ReadUtils.getSamplesFromHeader(getHeaderForReads());
if (samples.size() != 1) {
throw new UserException(String.format("The input bam has more than one sample: %s", Arrays.toString(samples.toArray())));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this doesn't require ridiculous amounts of memory to call MT across multiple samples. It would be good to suggest a threshold where GVCF mode becomes preferable for performance reasons.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we should recommend multiple samples autosomes as one M2 call and the MT contig should only be in GVCF mode? (Autosomes in GVCF mode are probably verrrrrrry sloooooow.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe we should recommend multiple samples autosomes as one M2 call and the MT contig should only be in GVCF mode?

I agree, but I was thinking in waiving the exception that we could be laissez-faire. I mean, what if someone wants to joint call a couple of 1000x mitochondria from the same person? If the samples are from different people I don't object to forbidding it outright, but there's no way to know that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's not the end of the world if it takes a long time, as long as it's not an astronomical amount of memory. On a related note, hopefully the dynamic graph pruning already uses the total coverage across all samples?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note, hopefully the dynamic graph pruning already uses the total coverage across all samples?

Fortunately, yes.

final int normalMedianRefBaseQuality = GATKProtectedVariantContextUtils.getAttributeAsIntArray(
normalGenotype, BaseQuality.KEY, () -> new int[] {IMPUTED_NORMAL_BASE_QUALITY}, IMPUTED_NORMAL_BASE_QUALITY)[0];
final double normalPValue = 1 - new BinomialDistribution(null, normalDepth, QualityUtils.qualToErrorProb(normalMedianRefBaseQuality))
final int medianRefBaseQuality = vc.getAttributeAsIntList(BaseQuality.KEY, IMPUTED_NORMAL_BASE_QUALITY).get(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your abstract PerAlleleAnnotation method that builds the header lines, but I'd rather that BaseQuality.KEY referred to a value in GATKVCFConstants.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
final int[] strandBiasCounts = GATKProtectedVariantContextUtils.getAttributeAsIntArray(tumorGenotype, GATKVCFConstants.STRAND_BIAS_BY_SAMPLE_KEY, ()->null, -1);
final MutableInt altForwardCount = new MutableInt(0);
final MutableInt altReverseCount = new MutableInt(0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of changing this to a MutableInt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want the array anymore because with a pass over samples requires it seemed too opaque to use an array to encapsulate two numbers. And once they're two numbers I like the MutableInt because it's final and it makes it more explicit that the for loop below is intended to grow the counts sample-by-sample. But, I mean, at the end of the day this is my own idiosyncratic preference and I can't really justify it beyond all argument. Do you think I should keep it an int[]?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way we have it in other places in the code is as an int array with constants describing the indices in the array as totalReadCounts[ALT_FORWARD_COUNT] or similar. I personally prefer primitives from a memory scalability perspective, but given that this is just two values readability is more important. If you think it's more clear that this is a running total if it's a final MutableInt, then I can be on board.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a dunce at reading anything that resembles C. It's clearer to me this way.

@ldgauthier

Copy link
Copy Markdown

Looks good to me, but I mostly just looked at the annotation parts. I'll let @takutosato review for functionality.

@davidbenjamin

Copy link
Copy Markdown
Contributor Author

I just rebased over Laura's GVCF mode PR.

@codecov-io

codecov-io commented Jan 7, 2019 •

Copy link
Copy Markdown

Codecov Report

Merging #5560 into master will increase coverage by 0.015%.
The diff coverage is 93.206%.

@@               Coverage Diff               @@
##              master     #5560       +/-   ##
===============================================
+ Coverage     87.077%   87.092%   +0.015%     
- Complexity     31479     31525       +46     
===============================================
  Files           1930      1930               
  Lines         145054    145231      +177     
  Branches       16075     16095       +20     
===============================================
+ Hits          126308    126484      +176     
- Misses         12896     12897        +1     
  Partials        5850      5850
Impacted Files Coverage Δ Complexity Δ
.../walkers/mutect/GermlineProbabilityCalculator.java 88.571% <ø> (+5.714%) 14 <0> (+1) ⬆️
...roadinstitute/hellbender/utils/tsv/TableUtils.java 94.595% <ø> (ø) 8 <0> (ø) ⬇️
...ls/walkers/mutect/M2FiltersArgumentCollection.java 100% <ø> (ø) 1 <0> (ø) ⬇️
...ientation/ReadOrientationModelIntegrationTest.java 100% <ø> (ø) 6 <0> (ø) ⬇️
...ute/hellbender/utils/variant/GATKVCFConstants.java 75% <ø> (-5%) 4 <0> (ø)
...ntamination/GetPileupSummariesIntegrationTest.java 95.745% <100%> (+0.29%) 4 <0> (ø) ⬇️
...e/hellbender/utils/variant/GATKVCFHeaderLines.java 95.906% <100%> (+0.073%) 10 <0> (ø) ⬇️
...walkers/readorientation/ArtifactPriorUnitTest.java 100% <100%> (ø) 7 <0> (ø) ⬇️
...ation/LearnReadOrientationModelEngineUnitTest.java 95.671% <100%> (ø) 43 <0> (ø) ⬇️
...ols/walkers/contamination/ContaminationRecord.java 89.744% <100%> (+1.508%) 6 <2> (+1) ⬆️
... and 42 more

@takutosato takutosato left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

final Genotype tumorGenotype = vc.getGenotype(tumorSample);

if (!tumorGenotype.hasExtendedAttribute(UniqueAltReadCount.UNIQUE_ALT_READ_SET_COUNT_KEY)) {
if (vc.hasAttribute(UniqueAltReadCount.KEY)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing negation !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

##source=Mutect2
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT NA12878
chrM 152 . T C . . DP=1582;ECNT=1;TLOD=5266.19;POPAF=5.000e-08 GT:AD:AF:F1R2:F2R1:MBQ:MFRL:MMQ:MPOS:OCM:POTENTIAL_POLYMORPHIC_NUMT 0/1:3,1556:0.998:2,777:1,779:30,30:16270,369:60,60:42:0:true
chrM 263 . A G . . DP=858;ECNT=4;TLOD=2641.72;POPAF=5.000e-08 GT:AD:AF:F1R2:F2R1:MBQ:MFRL:MMQ:MPOS:OCM 0/1:1,831:0.999:0,403:1,428:10,30:292,305:60,60:32:800

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you edit this by hand? For the second variant I think 800 should have been deleted instead of 32.

For the record, I'm not wasting time going through every vcf file looking for typos - I just happened to notice this particular one (and it could very well be not a typo)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants