Speeding Up GATK4 with Split Intervals
TL;DR
GATK4 is a time-consuming tool, but with enough compute power you can speed it up using split intervals. This post summarizes how to create and use split intervals. A Spark-based implementation is also under development, but it does not yet cover all tools (as of 2020/09/28).
Creating a Split Interval Directory
First, use picard ScatterIntervalsByNs to create an interval list. This converts a reference genome into an interval list file consisting of positions and counts of ATGC and N bases.
Next, create the split intervals. This splits the interval list so that each resulting interval ultimately contains the same number of bases. Use gatk4 SplitIntervals for this. In the example below, we split into 12 intervals.
Running GATK4 with Split Intervals
Here is an example workflow covering BQSR -> ApplyBQSR -> HaplotypeCaller. The basic idea is to specify the interval list with the -L option and loop over the split intervals using a for loop. You also need to use wait to ensure all background processes finish before proceeding.
Finally, the split VCFs are gathered using picard GatherVcfs.