Skip to content

Commit

Permalink
Swapped mito mode in Mutect to use the mode argument utils, providing…
Browse files Browse the repository at this point in the history
… better override behavior and documentation (#8986)
  • Loading branch information
jamesemery authored Sep 24, 2024
1 parent 6036d67 commit e1b5f95
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
import org.broadinstitute.barclay.argparser.Argument;
import org.broadinstitute.barclay.argparser.ArgumentCollection;
import org.broadinstitute.barclay.argparser.DeprecatedFeature;
import org.broadinstitute.hellbender.cmdline.GATKPlugin.DefaultGATKVariantAnnotationArgumentCollection;
import org.broadinstitute.hellbender.cmdline.ReadFilterArgumentDefinitions;
import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;
import org.broadinstitute.hellbender.engine.FeatureInput;
import org.broadinstitute.hellbender.engine.spark.AssemblyRegionArgumentCollection;
import org.broadinstitute.hellbender.tools.walkers.genotyper.GenotypeAssignmentMethod;
import org.broadinstitute.hellbender.tools.walkers.genotyper.GenotypeCalculationArgumentCollection;
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.FlowBasedAlignmentArgumentCollection;
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.*;
import org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingAssembler;
Expand Down Expand Up @@ -95,18 +100,6 @@ protected ReadThreadingAssemblerArgumentCollection getReadThreadingAssemblerArgu
return new MutectReadThreadingAssemblerArgumentCollection();
}

@Override
public ReadThreadingAssembler createReadThreadingAssembler(){
if(mitochondria ) {
assemblerArgs.recoverAllDanglingBranches = true;
if (assemblerArgs.pruningLogOddsThreshold == ReadThreadingAssemblerArgumentCollection.DEFAULT_PRUNING_LOG_ODDS_THRESHOLD) {
assemblerArgs.pruningLogOddsThreshold = DEFAULT_MITO_PRUNING_LOG_ODDS_THRESHOLD;
}
}

return super.createReadThreadingAssembler();
}

@ArgumentCollection
public CollectF1R2CountsArgumentCollection f1r2Args = new CollectF1R2CountsArgumentCollection();

Expand Down Expand Up @@ -164,8 +157,7 @@ public ReadThreadingAssembler createReadThreadingAssembler(){

public double getDefaultAlleleFrequency() {
return afOfAllelesNotInGermlineResource >= 0 ? afOfAllelesNotInGermlineResource :
(mitochondria ? DEFAULT_AF_FOR_MITO_CALLING:
(normalSamples.isEmpty() ? DEFAULT_AF_FOR_TUMOR_ONLY_CALLING : DEFAULT_AF_FOR_TUMOR_NORMAL_CALLING));
(normalSamples.isEmpty() ? DEFAULT_AF_FOR_TUMOR_ONLY_CALLING : DEFAULT_AF_FOR_TUMOR_NORMAL_CALLING);
}

/**
Expand All @@ -176,6 +168,20 @@ public double getDefaultAlleleFrequency() {
@Argument(fullName = MITOCHONDRIA_MODE_LONG_NAME, optional = true, doc="Mitochondria mode sets emission and initial LODs to 0.")
public Boolean mitochondria = false;

/**
* List of arguments to be set when a user specifies mitochondria mode. Each argument will be displayed in the help message.
*/
public String[] getMitochondriaModeNameValuePairs() {
return new String[]{
DEFAULT_AF_LONG_NAME, String.valueOf(DEFAULT_AF_FOR_MITO_CALLING),
EMISSION_LOD_LONG_NAME, String.valueOf(DEFAULT_MITO_EMISSION_LOD),
INITIAL_TUMOR_LOG_10_ODDS_LONG_NAME, String.valueOf(DEFAULT_MITO_INITIAL_LOG_10_ODDS),
ReadThreadingAssemblerArgumentCollection.RECOVER_ALL_DANGLING_BRANCHES_LONG_NAME, "true",
ReadThreadingAssemblerArgumentCollection.PRUNING_LOD_THRESHOLD_LONG_NAME, String.valueOf(DEFAULT_MITO_PRUNING_LOG_ODDS_THRESHOLD),
StandardArgumentDefinitions.ANNOTATION_LONG_NAME, "OriginalAlignment"
};
}

/**
* If true, collect Mutect3 data for learning; otherwise collect data for generating calls with a pre-trained model
*/
Expand Down Expand Up @@ -250,7 +256,7 @@ public double getEmissionLogOdds() {
if (emitReferenceConfidence != ReferenceConfidenceMode.NONE) {
return MathUtils.log10ToLog(DEFAULT_GVCF_LOG_10_ODDS);
}
return MathUtils.log10ToLog(mitochondria && emissionLog10Odds == DEFAULT_EMISSION_LOG_10_ODDS ? DEFAULT_MITO_EMISSION_LOD : emissionLog10Odds);
return MathUtils.log10ToLog(emissionLog10Odds);
}

/**
Expand All @@ -263,7 +269,7 @@ public double getInitialLogOdds() {
if (emitReferenceConfidence != ReferenceConfidenceMode.NONE) {
return MathUtils.log10ToLog(DEFAULT_GVCF_LOG_10_ODDS);
}
return MathUtils.log10ToLog(mitochondria && initialLog10Odds == DEFAULT_INITIAL_LOG_10_ODDS ? DEFAULT_MITO_INITIAL_LOG_10_ODDS : initialLog10Odds);
return MathUtils.log10ToLog(initialLog10Odds);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import org.broadinstitute.barclay.argparser.CommandLineException;
import org.broadinstitute.barclay.argparser.CommandLineProgramProperties;
import org.broadinstitute.barclay.help.DocumentedFeature;
import org.broadinstitute.hellbender.cmdline.GATKPlugin.GATKReadFilterPluginDescriptor;
import org.broadinstitute.hellbender.cmdline.StandardArgumentDefinitions;
import org.broadinstitute.hellbender.cmdline.programgroups.ShortVariantDiscoveryProgramGroup;
import org.broadinstitute.hellbender.engine.*;
import org.broadinstitute.hellbender.engine.filters.MappingQualityReadFilter;
import org.broadinstitute.hellbender.engine.filters.ReadFilter;
import org.broadinstitute.hellbender.exceptions.UserException;
import org.broadinstitute.hellbender.tools.walkers.annotator.*;
Expand Down Expand Up @@ -283,17 +285,6 @@ public void onTraversalStart() {
m2Engine.writeHeader(vcfWriter, getDefaultToolVCFHeaderLines());
}

@Override
public Collection<Annotation> makeVariantAnnotations(){
final Collection<Annotation> annotations = super.makeVariantAnnotations();

if (MTAC.mitochondria) {
annotations.add(new OriginalAlignment());
}

return annotations;
}

@Override
public Object onTraversalSuccess() {
m2Engine.writeExtraOutputs(new File(outputVCF + DEFAULT_STATS_EXTENSION));
Expand Down Expand Up @@ -322,6 +313,12 @@ public void closeTool() {
*/
@Override
protected String[] customCommandLineValidation() {
if (MTAC.mitochondria) {
ModeArgumentUtils.setArgValues(
getCommandLineParser(),
MTAC.getMitochondriaModeNameValuePairs(),
M2ArgumentCollection.MITOCHONDRIA_MODE_LONG_NAME);
}
if (MTAC.flowMode != M2ArgumentCollection.FlowMode.NONE) {
ModeArgumentUtils.setArgValues(
getCommandLineParser(),
Expand Down

0 comments on commit e1b5f95

Please sign in to comment.