Add new annotator for M1 clustered read position filter and M1 strand bias filter.
This commit is contained in:
parent
db196e709a
commit
4066bcd75c
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
* By downloading the PROGRAM you agree to the following terms of use:
|
||||
*
|
||||
* BROAD INSTITUTE
|
||||
* SOFTWARE LICENSE AGREEMENT
|
||||
* FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY
|
||||
*
|
||||
* This Agreement is made between the Broad Institute, Inc. with a principal address at 415 Main Street, Cambridge, MA 02142 (“BROAD”) and the LICENSEE and is effective at the date the downloading is completed (“EFFECTIVE DATE”).
|
||||
*
|
||||
* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and
|
||||
* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions.
|
||||
* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows:
|
||||
*
|
||||
* 1. DEFINITIONS
|
||||
* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK3 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute.org/gatk on the EFFECTIVE DATE.
|
||||
*
|
||||
* 2. LICENSE
|
||||
* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. LICENSEE hereby automatically grants to BROAD a non-exclusive, royalty-free, irrevocable license to any LICENSEE bug fixes or modifications to the PROGRAM with unlimited rights to sublicense and/or distribute. LICENSEE agrees to provide any such modifications and bug fixes to BROAD promptly upon their creation.
|
||||
* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement.
|
||||
* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement.
|
||||
* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM.
|
||||
*
|
||||
* 3. PHONE-HOME FEATURE
|
||||
* LICENSEE expressly acknowledges that the PROGRAM contains an embedded automatic reporting system (“PHONE-HOME”) which is enabled by default upon download. Unless LICENSEE requests disablement of PHONE-HOME, LICENSEE agrees that BROAD may collect limited information transmitted by PHONE-HOME regarding LICENSEE and its use of the PROGRAM. Such information shall include LICENSEE’S user identification, version number of the PROGRAM and tools being run, mode of analysis employed, and any error reports generated during run-time. Collection of such information is used by BROAD solely to monitor usage rates, fulfill reporting requirements to BROAD funding agencies, drive improvements to the PROGRAM, and facilitate adjustments to PROGRAM-related documentation.
|
||||
*
|
||||
* 4. OWNERSHIP OF INTELLECTUAL PROPERTY
|
||||
* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication.
|
||||
* Copyright 2012-2014 Broad Institute, Inc.
|
||||
* Notice of attribution: The GATK3 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc.
|
||||
* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes.
|
||||
*
|
||||
* 5. INDEMNIFICATION
|
||||
* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement.
|
||||
*
|
||||
* 6. NO REPRESENTATIONS OR WARRANTIES
|
||||
* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME.
|
||||
* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING.
|
||||
*
|
||||
* 7. ASSIGNMENT
|
||||
* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void.
|
||||
*
|
||||
* 8. MISCELLANEOUS
|
||||
* 8.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries.
|
||||
* 8.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes.
|
||||
* 8.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4.
|
||||
* 8.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt.
|
||||
* 8.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter.
|
||||
* 8.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement.
|
||||
* 8.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.gatk.tools.walkers.cancer.m2;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class AbstractPowerCalculator {
|
||||
protected HashMap<PowerCacheKey, Double> cache = new HashMap<PowerCacheKey, Double>();
|
||||
protected double constantEps;
|
||||
protected double constantLodThreshold;
|
||||
|
||||
protected static class PowerCacheKey {
|
||||
private int n;
|
||||
private double delta;
|
||||
|
||||
public PowerCacheKey(int n, double delta) {
|
||||
this.n = n;
|
||||
this.delta = delta;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
PowerCacheKey that = (PowerCacheKey) o;
|
||||
|
||||
if (Double.compare(that.delta, delta) != 0) return false;
|
||||
if (n != that.n) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = n;
|
||||
temp = delta != +0.0d ? Double.doubleToLongBits(delta) : 0L;
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
protected static double calculateLogLikelihood(int depth, int alts, double eps, double f) {
|
||||
double a = (depth-alts) * Math.log10(f*eps + (1d-f)*(1d-eps));
|
||||
double b = (alts) * Math.log10(f*(1d-eps) + (1d-f)*eps);
|
||||
return (a+b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -54,6 +54,7 @@ package org.broadinstitute.gatk.tools.walkers.cancer.m2;
|
|||
import org.broadinstitute.gatk.tools.walkers.haplotypecaller.AssemblyBasedCallerArgumentCollection;
|
||||
import org.broadinstitute.gatk.utils.commandline.Advanced;
|
||||
import org.broadinstitute.gatk.utils.commandline.Argument;
|
||||
import org.broadinstitute.gatk.utils.commandline.Hidden;
|
||||
|
||||
public class M2ArgumentCollection extends AssemblyBasedCallerArgumentCollection {
|
||||
@Advanced
|
||||
|
|
@ -119,4 +120,30 @@ public class M2ArgumentCollection extends AssemblyBasedCallerArgumentCollection
|
|||
*/
|
||||
@Argument(fullName = "max_alt_allele_in_normal_fraction", required = false, doc="Threshold for maximum alternate allele fraction in normal")
|
||||
public double MAX_ALT_ALLELE_IN_NORMAL_FRACTION = 0.03;
|
||||
|
||||
/**
|
||||
* This argument is used for the M1-style strand bias filter
|
||||
*/
|
||||
@Argument(fullName="power_constant_qscore", doc="Phred scale quality score constant to use in power calculations", required=false)
|
||||
public int POWER_CONSTANT_QSCORE = 30;
|
||||
|
||||
@Hidden
|
||||
@Argument(fullName = "strand_artifact_lod", required = false, doc = "LOD threshold for calling strand bias")
|
||||
public float STRAND_ARTIFACT_LOD_THRESHOLD = 2.0f;
|
||||
|
||||
@Hidden
|
||||
@Argument(fullName = "strand_artifact_power_threshold", required = false, doc = "power threshold for calling strand bias")
|
||||
public float STRAND_ARTIFACT_POWER_THRESHOLD = 0.9f;
|
||||
|
||||
/**
|
||||
* This argument is used for the M1-style read position filter
|
||||
*/
|
||||
@Argument(fullName = "pir_median_threshold", required = false, doc="threshold for clustered read position artifact median")
|
||||
public double PIR_MEDIAN_THRESHOLD = 10;
|
||||
|
||||
/**
|
||||
* This argument is used for the M1-style read position filter
|
||||
*/
|
||||
@Argument(fullName = "pir_mad_threshold", required = false, doc="threshold for clustered read position artifact MAD")
|
||||
public double PIR_MAD_THRESHOLD = 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,6 +411,11 @@ public class MuTect2 extends ActiveRegionWalker<List<VariantContext>, Integer> i
|
|||
headerInfo.add(GATKVCFHeaderLines.getFilterLine(GATKVCFConstants.GERMLINE_RISK_FILTER_NAME));
|
||||
headerInfo.add(GATKVCFHeaderLines.getFilterLine(GATKVCFConstants.TRIALLELIC_SITE_FILTER_NAME));
|
||||
|
||||
headerInfo.add(new VCFFilterHeaderLine("M1_CLUSTERED_READ_POSITION", "Variant appears in similar read positions"));
|
||||
headerInfo.add(new VCFFilterHeaderLine("M1_STRAND_BIAS", "Forward LOD vs. reverse LOD comparison indicates strand bias"));
|
||||
headerInfo.add(new VCFInfoHeaderLine("TLOD_FWD",1,VCFHeaderLineType.Integer,"TLOD from forward reads only"));
|
||||
headerInfo.add(new VCFInfoHeaderLine("TLOD_REV",1,VCFHeaderLineType.Integer,"TLOD from reverse reads only"));
|
||||
|
||||
if ( ! doNotRunPhysicalPhasing ) {
|
||||
headerInfo.add(GATKVCFHeaderLines.getFormatLine(GATKVCFConstants.HAPLOTYPE_CALLER_PHASING_ID_KEY));
|
||||
headerInfo.add(GATKVCFHeaderLines.getFormatLine(GATKVCFConstants.HAPLOTYPE_CALLER_PHASING_GT_KEY));
|
||||
|
|
@ -829,6 +834,15 @@ public class MuTect2 extends ActiveRegionWalker<List<VariantContext>, Integer> i
|
|||
filters.add(GATKVCFConstants.CLUSTERED_EVENTS_FILTER_NAME);
|
||||
}
|
||||
|
||||
Integer tumorFwdPosMedian = (Integer) vc.getAttribute("TUMOR_FWD_POS_MEDIAN");
|
||||
Integer tumorRevPosMedian = (Integer) vc.getAttribute("TUMOR_REV_POS_MEDIAN");
|
||||
Integer tumorFwdPosMAD = (Integer) vc.getAttribute("TUMOR_FWD_POS_MAD");
|
||||
Integer tumorRevPosMAD = (Integer) vc.getAttribute("TUMOR_REV_POS_MAD");
|
||||
//If the variant is near the read end (median threshold) and the positions are very similar (MAD threshold) then filter
|
||||
if ( (tumorFwdPosMedian != null && tumorFwdPosMedian <= MTAC.PIR_MEDIAN_THRESHOLD && tumorFwdPosMAD != null && tumorFwdPosMAD <= MTAC.PIR_MAD_THRESHOLD) ||
|
||||
(tumorRevPosMedian != null && tumorRevPosMedian <= MTAC.PIR_MEDIAN_THRESHOLD && tumorFwdPosMAD != null && tumorRevPosMAD <= MTAC.PIR_MAD_THRESHOLD))
|
||||
filters.add("M1_CLUSTERED_READ_POSITION");
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
|
|
@ -1052,7 +1066,7 @@ public class MuTect2 extends ActiveRegionWalker<List<VariantContext>, Integer> i
|
|||
// protected List<String> annotationsToUse = new ArrayList<>(Arrays.asList(new String[]{"ClippingRankSumTest", "DepthPerSampleHC"}));
|
||||
//protected List<String> annotationsToUse = new ArrayList<>(Arrays.asList(new String[]{"DepthPerAlleleBySample", "BaseQualitySumPerAlleleBySample", "TandemRepeatAnnotator",
|
||||
// "RMSMappingQuality","MappingQualityRankSumTest","FisherStrand","StrandOddsRatio","ReadPosRankSumTest","QualByDepth", "Coverage"}));
|
||||
protected List<String> annotationsToUse = new ArrayList<>(Arrays.asList(new String[]{"DepthPerAlleleBySample", "BaseQualitySumPerAlleleBySample", "TandemRepeatAnnotator", "OxoGReadCounts"}));
|
||||
protected List<String> annotationsToUse = new ArrayList<>(Arrays.asList(new String[]{"DepthPerAlleleBySample", "BaseQualitySumPerAlleleBySample", "TandemRepeatAnnotator", "OxoGReadCounts", "ClusteredEventsAnnotator"}));
|
||||
|
||||
/**
|
||||
* Which annotations to exclude from output in the VCF file. Note that this argument has higher priority than the -A or -G arguments,
|
||||
|
|
|
|||
|
|
@ -78,12 +78,16 @@ import java.util.*;
|
|||
public class SomaticGenotypingEngine extends HaplotypeCallerGenotypingEngine {
|
||||
|
||||
protected M2ArgumentCollection MTAC;
|
||||
private TumorPowerCalculator strandArtifactPowerCalculator;
|
||||
|
||||
private final static Logger logger = Logger.getLogger(SomaticGenotypingEngine.class);
|
||||
|
||||
public SomaticGenotypingEngine(final M2ArgumentCollection configuration, final SampleList samples, final GenomeLocParser genomeLocParser, final AFCalculatorProvider afCalculatorProvider, final boolean doPhysicalPhasing, final M2ArgumentCollection MTAC) {
|
||||
super(configuration, samples, genomeLocParser, afCalculatorProvider, doPhysicalPhasing);
|
||||
this.MTAC = MTAC;
|
||||
// coverage related initialization
|
||||
double powerConstantEps = Math.pow(10, -1 * (MTAC.POWER_CONSTANT_QSCORE/10));
|
||||
strandArtifactPowerCalculator = new TumorPowerCalculator(powerConstantEps, MTAC.STRAND_ARTIFACT_LOD_THRESHOLD, 0.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -224,6 +228,17 @@ public class SomaticGenotypingEngine extends HaplotypeCallerGenotypingEngine {
|
|||
|
||||
double[] tumorGLs = getVariableGenotypeLikelihoods(mergedVC, tumorPRALM, originalNormalReadQualities, afs);
|
||||
|
||||
PerReadAlleleLikelihoodMap forwardPRALM = new PerReadAlleleLikelihoodMap();
|
||||
PerReadAlleleLikelihoodMap reversePRALM = new PerReadAlleleLikelihoodMap();
|
||||
splitPRALMintoForwardAndReverseReads(tumorPRALM, forwardPRALM, reversePRALM);
|
||||
|
||||
// TODO: TS uncomment and fix
|
||||
// double f_fwd = estimateAlleleFraction(mergedVC, forwardPRALM);
|
||||
// double[] tumorGLs_fwd = getVariableGenotypeLikelihoods(mergedVC, forwardPRALM, f_fwd);
|
||||
//
|
||||
// double f_rev = estimateAlleleFraction(mergedVC, reversePRALM);
|
||||
// double[] tumorGLs_rev = getVariableGenotypeLikelihoods(mergedVC, reversePRALM, f_rev);
|
||||
|
||||
PerReadAlleleLikelihoodMap normalPRALM = null;
|
||||
double[] normalGLs = null;
|
||||
if (hasNormal) {
|
||||
|
|
@ -253,6 +268,12 @@ public class SomaticGenotypingEngine extends HaplotypeCallerGenotypingEngine {
|
|||
|
||||
double[] normalLods = new double[numAlts];
|
||||
|
||||
// TODO: TS extend fwd-rev approach for multiple alt alleles
|
||||
// int REF = 0, HET = 1;
|
||||
// double tumorLod = tumorGLs[HET] - tumorGLs[REF];
|
||||
// double tumorLod_fwd = tumorGLs_fwd[HET] - tumorGLs_fwd[REF];
|
||||
// double tumorLod_rev = tumorGLs_rev[HET] - tumorGLs_rev[REF];
|
||||
// double normalLod = 0;
|
||||
if (hasNormal) {
|
||||
GenomeLoc eventGenomeLoc = genomeLocParser.createGenomeLoc(activeRegionWindow.getContig(), loc);
|
||||
Collection<VariantContext> cosmicVC = tracker.getValues(cosmicRod, eventGenomeLoc);
|
||||
|
|
@ -277,9 +298,27 @@ public class SomaticGenotypingEngine extends HaplotypeCallerGenotypingEngine {
|
|||
}
|
||||
}
|
||||
|
||||
// TS: if more than one passing alt alleles, filter it out, so doesn't matter which one we pick
|
||||
|
||||
final double tumorLod = tumorLods[lodInd];
|
||||
final double normalLod = normalLods[lodInd];
|
||||
|
||||
double tumorSBpower_fwd;
|
||||
double tumorSBpower_rev;
|
||||
|
||||
// TODO: TS fix
|
||||
// try {
|
||||
// tumorSBpower_fwd = strandArtifactPowerCalculator.cachingPowerCalculation(forwardPRALM.getNumberOfStoredElements(), f_fwd);
|
||||
// tumorSBpower_rev = strandArtifactPowerCalculator.cachingPowerCalculation(reversePRALM.getNumberOfStoredElements(), f_rev);
|
||||
// }
|
||||
// catch (Throwable t) {
|
||||
// System.err.println("Error processing " + activeRegionWindow.getContig() + ":" + loc);
|
||||
// t.printStackTrace(System.err);
|
||||
//
|
||||
// throw new RuntimeException(t);
|
||||
// }
|
||||
|
||||
|
||||
VariantContext call = null;
|
||||
if (tumorLod >= MTAC.INITIAL_TUMOR_LOD_THRESHOLD && normalLod >= INIT_NORMAL_LOD_THRESHOLD) {
|
||||
VariantContextBuilder callVcb = new VariantContextBuilder(mergedVC);
|
||||
|
|
@ -289,6 +328,20 @@ public class SomaticGenotypingEngine extends HaplotypeCallerGenotypingEngine {
|
|||
}
|
||||
|
||||
int haplotypeCount = alleleMapper.get(mergedVC.getAlternateAllele(lodInd)).size();
|
||||
// TODO: TS revisit
|
||||
// callVcb.attribute("TLOD_FWD",tumorLod_fwd);
|
||||
// callVcb.attribute("TLOD_REV",tumorLod_rev);
|
||||
// if ( (tumorSBpower_fwd >= MTAC.STRAND_ARTIFACT_POWER_THRESHOLD && tumorLod_fwd < MTAC.STRAND_ARTIFACT_LOD_THRESHOLD) ||
|
||||
// (tumorSBpower_rev >= MTAC.STRAND_ARTIFACT_POWER_THRESHOLD && tumorLod_rev < MTAC.STRAND_ARTIFACT_LOD_THRESHOLD) )
|
||||
// callVcb.filter("M1_STRAND_BIAS");
|
||||
|
||||
// TODO: TS revisit
|
||||
// if ( (tumorSBpower_fwd >= MTAC.STRAND_ARTIFACT_POWER_THRESHOLD && tumorLod_fwd < MTAC.STRAND_ARTIFACT_LOD_THRESHOLD) ||
|
||||
// (tumorSBpower_rev >= MTAC.STRAND_ARTIFACT_POWER_THRESHOLD && tumorLod_rev < MTAC.STRAND_ARTIFACT_LOD_THRESHOLD) )
|
||||
// callVcb.filter("M1_STRAND_BIAS");
|
||||
//
|
||||
// // FIXME: can simply get first alternate since above we only deal with Bi-allelic sites...
|
||||
// int haplotypeCount = alleleMapper.get(mergedVC.getAlternateAllele(0)).size();
|
||||
callVcb.attribute(GATKVCFConstants.HAPLOTYPE_COUNT_KEY, haplotypeCount);
|
||||
callVcb.attribute(GATKVCFConstants.TUMOR_LOD_KEY, tumorLod);
|
||||
callVcb.attribute(GATKVCFConstants.NORMAL_LOD_KEY, normalLod);
|
||||
|
|
@ -545,6 +598,39 @@ public class SomaticGenotypingEngine extends HaplotypeCallerGenotypingEngine {
|
|||
}
|
||||
}
|
||||
|
||||
private void splitPRALMintoForwardAndReverseReads(final PerReadAlleleLikelihoodMap original, final PerReadAlleleLikelihoodMap forward, final PerReadAlleleLikelihoodMap reverse) {
|
||||
Map<GATKSAMRecord, Map<Allele, Double>> origMap = original.getLikelihoodReadMap();
|
||||
Map<GATKSAMRecord, Map<Allele, Double>> fwdMap = forward.getLikelihoodReadMap();
|
||||
Map<GATKSAMRecord, Map<Allele, Double>> revMap = reverse.getLikelihoodReadMap();
|
||||
|
||||
// iterate through the reads, assign reads and likelihoods to the forward or reverse maps based on the read's strand
|
||||
Set<GATKSAMRecord> forwardReads = new HashSet<>();
|
||||
Set<GATKSAMRecord> reverseReads = new HashSet<>();
|
||||
|
||||
for(GATKSAMRecord rec : origMap.keySet()) {
|
||||
if (rec.isStrandless())
|
||||
continue;
|
||||
if (rec.getReadNegativeStrandFlag())
|
||||
reverseReads.add(rec);
|
||||
else
|
||||
forwardReads.add(rec);
|
||||
}
|
||||
|
||||
final Iterator<Map.Entry<GATKSAMRecord, Map<Allele, Double>>> it = origMap.entrySet().iterator();
|
||||
while ( it.hasNext() ) {
|
||||
final Map.Entry<GATKSAMRecord, Map<Allele, Double>> record = it.next();
|
||||
if(forwardReads.contains(record.getKey())) {
|
||||
fwdMap.put(record.getKey(), record.getValue());
|
||||
//logM2Debug("Dropping read " + record.getKey() + " due to overlapping read fragment rules");
|
||||
}
|
||||
else if (reverseReads.contains(record.getKey())){
|
||||
revMap.put(record.getKey(),record.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Move to utility class so we can use one shared with HaplotypeCallerGenotypingEngine
|
||||
private VariantContext addNonRefSymbolicAllele(final VariantContext mergedVC) {
|
||||
final VariantContextBuilder vcb = new VariantContextBuilder(mergedVC);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,139 @@
|
|||
/*
|
||||
* By downloading the PROGRAM you agree to the following terms of use:
|
||||
*
|
||||
* BROAD INSTITUTE
|
||||
* SOFTWARE LICENSE AGREEMENT
|
||||
* FOR ACADEMIC NON-COMMERCIAL RESEARCH PURPOSES ONLY
|
||||
*
|
||||
* This Agreement is made between the Broad Institute, Inc. with a principal address at 415 Main Street, Cambridge, MA 02142 (“BROAD”) and the LICENSEE and is effective at the date the downloading is completed (“EFFECTIVE DATE”).
|
||||
*
|
||||
* WHEREAS, LICENSEE desires to license the PROGRAM, as defined hereinafter, and BROAD wishes to have this PROGRAM utilized in the public interest, subject only to the royalty-free, nonexclusive, nontransferable license rights of the United States Government pursuant to 48 CFR 52.227-14; and
|
||||
* WHEREAS, LICENSEE desires to license the PROGRAM and BROAD desires to grant a license on the following terms and conditions.
|
||||
* NOW, THEREFORE, in consideration of the promises and covenants made herein, the parties hereto agree as follows:
|
||||
*
|
||||
* 1. DEFINITIONS
|
||||
* 1.1 PROGRAM shall mean copyright in the object code and source code known as GATK3 and related documentation, if any, as they exist on the EFFECTIVE DATE and can be downloaded from http://www.broadinstitute.org/gatk on the EFFECTIVE DATE.
|
||||
*
|
||||
* 2. LICENSE
|
||||
* 2.1 Grant. Subject to the terms of this Agreement, BROAD hereby grants to LICENSEE, solely for academic non-commercial research purposes, a non-exclusive, non-transferable license to: (a) download, execute and display the PROGRAM and (b) create bug fixes and modify the PROGRAM. LICENSEE hereby automatically grants to BROAD a non-exclusive, royalty-free, irrevocable license to any LICENSEE bug fixes or modifications to the PROGRAM with unlimited rights to sublicense and/or distribute. LICENSEE agrees to provide any such modifications and bug fixes to BROAD promptly upon their creation.
|
||||
* The LICENSEE may apply the PROGRAM in a pipeline to data owned by users other than the LICENSEE and provide these users the results of the PROGRAM provided LICENSEE does so for academic non-commercial purposes only. For clarification purposes, academic sponsored research is not a commercial use under the terms of this Agreement.
|
||||
* 2.2 No Sublicensing or Additional Rights. LICENSEE shall not sublicense or distribute the PROGRAM, in whole or in part, without prior written permission from BROAD. LICENSEE shall ensure that all of its users agree to the terms of this Agreement. LICENSEE further agrees that it shall not put the PROGRAM on a network, server, or other similar technology that may be accessed by anyone other than the LICENSEE and its employees and users who have agreed to the terms of this agreement.
|
||||
* 2.3 License Limitations. Nothing in this Agreement shall be construed to confer any rights upon LICENSEE by implication, estoppel, or otherwise to any computer software, trademark, intellectual property, or patent rights of BROAD, or of any other entity, except as expressly granted herein. LICENSEE agrees that the PROGRAM, in whole or part, shall not be used for any commercial purpose, including without limitation, as the basis of a commercial software or hardware product or to provide services. LICENSEE further agrees that the PROGRAM shall not be copied or otherwise adapted in order to circumvent the need for obtaining a license for use of the PROGRAM.
|
||||
*
|
||||
* 3. PHONE-HOME FEATURE
|
||||
* LICENSEE expressly acknowledges that the PROGRAM contains an embedded automatic reporting system (“PHONE-HOME”) which is enabled by default upon download. Unless LICENSEE requests disablement of PHONE-HOME, LICENSEE agrees that BROAD may collect limited information transmitted by PHONE-HOME regarding LICENSEE and its use of the PROGRAM. Such information shall include LICENSEE’S user identification, version number of the PROGRAM and tools being run, mode of analysis employed, and any error reports generated during run-time. Collection of such information is used by BROAD solely to monitor usage rates, fulfill reporting requirements to BROAD funding agencies, drive improvements to the PROGRAM, and facilitate adjustments to PROGRAM-related documentation.
|
||||
*
|
||||
* 4. OWNERSHIP OF INTELLECTUAL PROPERTY
|
||||
* LICENSEE acknowledges that title to the PROGRAM shall remain with BROAD. The PROGRAM is marked with the following BROAD copyright notice and notice of attribution to contributors. LICENSEE shall retain such notice on all copies. LICENSEE agrees to include appropriate attribution if any results obtained from use of the PROGRAM are included in any publication.
|
||||
* Copyright 2012-2014 Broad Institute, Inc.
|
||||
* Notice of attribution: The GATK3 program was made available through the generosity of Medical and Population Genetics program at the Broad Institute, Inc.
|
||||
* LICENSEE shall not use any trademark or trade name of BROAD, or any variation, adaptation, or abbreviation, of such marks or trade names, or any names of officers, faculty, students, employees, or agents of BROAD except as states above for attribution purposes.
|
||||
*
|
||||
* 5. INDEMNIFICATION
|
||||
* LICENSEE shall indemnify, defend, and hold harmless BROAD, and their respective officers, faculty, students, employees, associated investigators and agents, and their respective successors, heirs and assigns, (Indemnitees), against any liability, damage, loss, or expense (including reasonable attorneys fees and expenses) incurred by or imposed upon any of the Indemnitees in connection with any claims, suits, actions, demands or judgments arising out of any theory of liability (including, without limitation, actions in the form of tort, warranty, or strict liability and regardless of whether such action has any factual basis) pursuant to any right or license granted under this Agreement.
|
||||
*
|
||||
* 6. NO REPRESENTATIONS OR WARRANTIES
|
||||
* THE PROGRAM IS DELIVERED AS IS. BROAD MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE PROGRAM OR THE COPYRIGHT, EXPRESS OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT DISCOVERABLE. BROAD EXTENDS NO WARRANTIES OF ANY KIND AS TO PROGRAM CONFORMITY WITH WHATEVER USER MANUALS OR OTHER LITERATURE MAY BE ISSUED FROM TIME TO TIME.
|
||||
* IN NO EVENT SHALL BROAD OR ITS RESPECTIVE DIRECTORS, OFFICERS, EMPLOYEES, AFFILIATED INVESTIGATORS AND AFFILIATES BE LIABLE FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING, WITHOUT LIMITATION, ECONOMIC DAMAGES OR INJURY TO PROPERTY AND LOST PROFITS, REGARDLESS OF WHETHER BROAD SHALL BE ADVISED, SHALL HAVE OTHER REASON TO KNOW, OR IN FACT SHALL KNOW OF THE POSSIBILITY OF THE FOREGOING.
|
||||
*
|
||||
* 7. ASSIGNMENT
|
||||
* This Agreement is personal to LICENSEE and any rights or obligations assigned by LICENSEE without the prior written consent of BROAD shall be null and void.
|
||||
*
|
||||
* 8. MISCELLANEOUS
|
||||
* 8.1 Export Control. LICENSEE gives assurance that it will comply with all United States export control laws and regulations controlling the export of the PROGRAM, including, without limitation, all Export Administration Regulations of the United States Department of Commerce. Among other things, these laws and regulations prohibit, or require a license for, the export of certain types of software to specified countries.
|
||||
* 8.2 Termination. LICENSEE shall have the right to terminate this Agreement for any reason upon prior written notice to BROAD. If LICENSEE breaches any provision hereunder, and fails to cure such breach within thirty (30) days, BROAD may terminate this Agreement immediately. Upon termination, LICENSEE shall provide BROAD with written assurance that the original and all copies of the PROGRAM have been destroyed, except that, upon prior written authorization from BROAD, LICENSEE may retain a copy for archive purposes.
|
||||
* 8.3 Survival. The following provisions shall survive the expiration or termination of this Agreement: Articles 1, 3, 4, 5 and Sections 2.2, 2.3, 7.3, and 7.4.
|
||||
* 8.4 Notice. Any notices under this Agreement shall be in writing, shall specifically refer to this Agreement, and shall be sent by hand, recognized national overnight courier, confirmed facsimile transmission, confirmed electronic mail, or registered or certified mail, postage prepaid, return receipt requested. All notices under this Agreement shall be deemed effective upon receipt.
|
||||
* 8.5 Amendment and Waiver; Entire Agreement. This Agreement may be amended, supplemented, or otherwise modified only by means of a written instrument signed by all parties. Any waiver of any rights or failure to act in a specific instance shall relate only to such instance and shall not be construed as an agreement to waive any rights or fail to act in any other instance, whether or not similar. This Agreement constitutes the entire agreement among the parties with respect to its subject matter and supersedes prior agreements or understandings between the parties relating to its subject matter.
|
||||
* 8.6 Binding Effect; Headings. This Agreement shall be binding upon and inure to the benefit of the parties and their respective permitted successors and assigns. All headings are for convenience only and shall not affect the meaning of any provision of this Agreement.
|
||||
* 8.7 Governing Law. This Agreement shall be construed, governed, interpreted and applied in accordance with the internal laws of the Commonwealth of Massachusetts, U.S.A., without regard to conflict of laws principles.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.gatk.tools.walkers.cancer.m2;
|
||||
|
||||
import org.apache.commons.math.MathException;
|
||||
import org.apache.commons.math.distribution.BinomialDistribution;
|
||||
import org.apache.commons.math.distribution.BinomialDistributionImpl;
|
||||
|
||||
public class TumorPowerCalculator extends AbstractPowerCalculator{
|
||||
private double constantContamination;
|
||||
private boolean enableSmoothing;
|
||||
|
||||
public TumorPowerCalculator(double constantEps, double constantLodThreshold, double constantContamination) {
|
||||
this(constantEps, constantLodThreshold, constantContamination, true);
|
||||
}
|
||||
|
||||
public TumorPowerCalculator(double constantEps, double constantLodThreshold, double constantContamination, boolean enableSmoothing) {
|
||||
this.constantEps = constantEps;
|
||||
this.constantLodThreshold = constantLodThreshold;
|
||||
this.constantContamination = constantContamination;
|
||||
this.enableSmoothing = enableSmoothing;
|
||||
}
|
||||
|
||||
public double cachingPowerCalculation(int n, double delta) throws MathException {
|
||||
PowerCacheKey key = new PowerCacheKey(n, delta);
|
||||
Double power = cache.get(key);
|
||||
if (power == null) {
|
||||
power = calculatePower(n, constantEps, constantLodThreshold, delta, constantContamination, enableSmoothing);
|
||||
cache.put(key, power);
|
||||
}
|
||||
return power;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected static double calculateTumorLod(int depth, int alts, double eps, double contam) {
|
||||
double f = (double) alts / (double) depth;
|
||||
return (AbstractPowerCalculator.calculateLogLikelihood(depth, alts, eps, f) - AbstractPowerCalculator.calculateLogLikelihood(depth, alts, eps, Math.min(f,contam)));
|
||||
}
|
||||
|
||||
protected static double calculatePower(int depth, double eps, double lodThreshold, double delta, double contam, boolean enableSmoothing) throws MathException {
|
||||
if (depth==0) return 0;
|
||||
|
||||
// calculate the probability of each configuration
|
||||
double p_alt_given_e_delta = delta*(1d-eps) + (1d-delta)*eps;
|
||||
BinomialDistribution binom = new BinomialDistributionImpl(depth, p_alt_given_e_delta);
|
||||
double[] p = new double[depth+1];
|
||||
for(int i=0; i<p.length; i++) {
|
||||
p[i] = binom.probability(i);
|
||||
}
|
||||
|
||||
// calculate the LOD scores
|
||||
double[] lod = new double[depth+1];
|
||||
for(int i=0; i<lod.length; i++) {
|
||||
lod[i] = calculateTumorLod(depth, i, eps, contam);
|
||||
}
|
||||
|
||||
int k = -1;
|
||||
for(int i=0; i<lod.length; i++) {
|
||||
if (lod[i] >= lodThreshold) {
|
||||
k = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if no depth meets the lod score, the power is zero
|
||||
if (k == -1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
double power = 0;
|
||||
|
||||
// here we correct for the fact that the exact lod threshold is likely somewhere between
|
||||
// the k and k-1 bin, so we prorate the power from that bin
|
||||
// the k and k-1 bin, so we prorate the power from that bin
|
||||
// if k==0, it must be that lodThreshold == lod[k] so we don't have to make this correction
|
||||
if ( enableSmoothing && k > 0 ) {
|
||||
double x = 1d - (lodThreshold - lod[k-1]) / (lod[k] - lod[k-1]);
|
||||
power = x*p[k-1];
|
||||
}
|
||||
|
||||
for(int i=k; i<p.length; i++) {
|
||||
power += p[i];
|
||||
}
|
||||
|
||||
return(power);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue