minimap2
Run a GPU-accelerated minimap2.
This tool aligns long read sequences against a large reference database using accelerated seeding, chaining, and KSW2 to convert FASTQ to BAM/CRAM.
Refer to the minimap2 Reference section for a detailed listing of all available options.
Quick Start
Compatible CPU-based minimap2, GATK4 Commands
The commands below are the minimap2-v2.31 and GATK4 counterpart of the Clara Parabricks command above. The output from these commands will be identical to the output from the above command. Refer to the Output Comparison page for comparing the results. You may need to increase the Java heap size based on your dataset, or decrease the number of —MAX_RECORDS_IN_RAM.
Note that three changes must be made to the baseline minimap2 code in order to match the results exactly:
Firstly, a new preset must be made in options.c in the mm_set_opt function that
tries to replicate the preset of pbmm2 by setting these parameters as a new preset named “map-pbmm2”:
Secondly, a fix must be made to the baseline KSW2 code to round the loop fission start and end
points by changing them to st and en respectively. If the start point (st0)
is a number below 16, but greater than 0, its scoring values will not be initialized correctly, but
will still be used later when computing the actual alignment. This can be fixed by rounding the
start and end points to multiples of 16.
To make this fix, change the following code in ksw2_extd2_sse.c:
Fixed version that uses lf_start and lf_en:
Thirdly, Parabricks minimap2 uses a stable radix sort for anchors, whereas the
default CPU baseline uses an unstable radix sort (‘radix_sort_128x’). This can cause ties between anchors
sharing the same reference position to break differently between the two. To obtain bit-for-bit identical results
against the GPU output, replace collect_seed_hits and collect_seed_hits_heap in
map.c with a stable variant that sorts by (anchor.x, original_index):
Replace both the heap-sort and radix-sort branches in mm_map_frag_core with a single call
to collect_seed_hits_stable. The original two-branch code in map.c:
Should be replaced with:
Both collect_seed_hits (radix sort) and collect_seed_hits_heap (min-heap merge)
produce different tie-breaking orders from each other and from the GPU pipeline, so both must be
replaced. collect_seed_hits_stable supersedes both: it builds the anchor array with the
same logic as collect_seed_hits but then sorts by the augmented key
(anchor.x, original_index) using qsort.
The original index as a tiebreaker makes qsort behave as a stable sort: anchors at the
same reference position are ordered by their emission order (query position), which matches the
GPU pipeline’s CUB segmented radix sort output.
This change affects only reads that have multiple anchors mapping to the same reference position. In practice, about 0.003% (short reads) - 0.2% (long reads) of reads differ between the original unstable sort and the stable variant.