Mutect2 (tumor & matched normal) - Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
GATK version used: 4.1.8.1
Exact command used (line-by-line for easy reading):
../gatk-4.1.8.1/gatk
Mutect2
--input ../neoepiscope-paper/Mel5_tumor.marked.sorted.reheadered.recalibrated.bam
--tumor-sample Mel5_tumor
--input ../neoepiscope-paper/Mel5_normal.marked.sorted.reheadered.recalibrated.bam
--normal-sample Mel5_normal
--reference ../gatk_resource_bundle/v0/Homo_sapiens_assembly38.fasta
--germline-resource ../af-only-gnomad.hg38.vcf.gz
--output ../neoepiscope-paper/Mel5_tumor_v_Mel5_normal.mutect.raw.vcf
Entire error log:
...
14:45:42.424 INFO ProgressMeter - chrUn_JTFH01001566v1_decoy:901 119.4 11399360 95475.3
14:46:18.840 INFO ProgressMeter - chrUn_JTFH01001568v1_decoy:901 120.0 11399370 94992.5
14:47:42.601 INFO Mutect2 - Shutting down engine
[2 September 2020 at 2:47:42 pm AEST] org.broadinstitute.hellbender.tools.walkers.mutect.Mutect2 done. Elapsed time: 121.42 minutes.
Runtime.totalMemory()=8432648192
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at htsjdk.tribble.index.linear.LinearIndex$ChrIndex.mergeBlocks(LinearIndex.java:402)
at htsjdk.tribble.index.linear.LinearIndex$ChrIndex.optimize(LinearIndex.java:374)
at htsjdk.tribble.index.linear.LinearIndex$ChrIndex.optimize(LinearIndex.java:349)
at htsjdk.tribble.index.linear.LinearIndex.optimize(LinearIndex.java:426)
at htsjdk.tribble.index.linear.LinearIndex.optimize(LinearIndex.java:436)
at htsjdk.tribble.index.linear.LinearIndexCreator.finalizeIndex(LinearIndexCreator.java:125)
at htsjdk.tribble.index.DynamicIndexCreator.finalizeIndex(DynamicIndexCreator.java:92)
at htsjdk.variant.variantcontext.writer.IndexingVariantContextWriter.close(IndexingVariantContextWriter.java:177)
at htsjdk.variant.variantcontext.writer.VCFWriter.close(VCFWriter.java:233)
at org.broadinstitute.hellbender.tools.walkers.mutect.Mutect2.closeTool(Mutect2.java:305)
at org.broadinstitute.hellbender.engine.GATKTool.doWork(GATKTool.java:1053)
at org.broadinstitute.hellbender.cmdline.CommandLineProgram.runTool(CommandLineProgram.java:140)
at org.broadinstitute.hellbender.cmdline.CommandLineProgram.instanceMainPostParseArgs(CommandLineProgram.java:192)
at org.broadinstitute.hellbender.cmdline.CommandLineProgram.instanceMain(CommandLineProgram.java:211)
at org.broadinstitute.hellbender.Main.runCommandLineProgram(Main.java:160)
at org.broadinstitute.hellbender.Main.mainEntry(Main.java:203)
at org.broadinstitute.hellbender.Main.main(Main.java:289)
-
Hi Lauren Eldershaw, there are a couple things to try. First, adding the java option -Xmx with how much memory the program can use. See how to use java options here. Second, use a temporary directory that is large enough to hold the intermediate files. The option is --tmp-dir (Mutect2 docs). And finally, make sure you have enough space on your machine to run this program.
-
Usually, this error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.Therefore you pretty much have two options:
- Increase the default memory your program is allowed to use using the -Xmx option (for instance for 1024 MB: -Xmx1024m)
- Modify your program so that it needs less memory, using less big data structures and getting rid of objects that are not any more used at some point in your program
Increasing the heap size is a bad solution, 100% temporary. It will crash again in somewhere else. To avoid these issues, write high performance code.
- Use local variables wherever possible.
- Make sure you select the correct object (EX: Selection between String, StringBuffer and StringBuilder)
- Use a good code system for your program(EX: Using static variables VS non static variables)
- Other stuff which could work on your code.
- Try to move with Multy Threading
Please sign in to leave a comment.
2 comments