<
10BC8
svg aria-hidden="true" data-component="Octicon" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This cookbook walks you through a variety of applications of minimap2 and its
companion script paftools.js. All data here are freely available from the
minimap2 release page at version tag v2.10. Some examples only work
with v2.10 or later.
To acquire the data used in this cookbook and to install minimap2 and paftools,
please follow the command lines below:
# install minimap2 executables
curl -L https://github.com/lh3/minimap2/releases/download/v2.16/minimap2-2.16_x64-linux.tar.bz2 | tar jxf -
cp minimap2-2.16_x64-linux/{minimap2,k8,paftools.js} .# copy executablesexport PATH="$PATH:"`pwd`# put the current directory on PATH# download example datasets
curl -L https://github.com/lh3/minimap2/releases/download/v2.10/cookbook-data.tgz | tar zxf -
Alternatively, you can create a minimap2 index first and then map:
minimap2 -x map-pb -d ecoli-pb.mmi ecoli_ref.fa # create an index
minimap2 -ax map-pb ecoli-pb.mmi ecoli_p6_25x_canu.fa > mapped.sam
This will save you a couple of minutes when you map against the human genome.
HOWEVER, key algorithm parameters such as the k-mer length and window
size can't be changed after indexing. Minimap2 will give you a warning if
parameters used in a pre-built index doesn't match parameters on the command
line. Please always make sure you are using an intended pre-built index.
Mapping Illumina paired-end reads:
minimap2 -ax sr -t4 ecoli_ref.fa ecoli_mason_1.fq ecoli_mason_2.fq > mapped-sr.sam
Evaluating mapping accuracy with simulated reads (for developers)
minimap2 -ax sr ecoli_ref.fa ecoli_mason_1.fq ecoli_mason_2.fq | paftools.js mapeval -
where a U-line gives the number of unmapped reads (for SAM input only); a
Q-line gives:
Mapping quality (mapQ) threshold
Number of mapped reads between this threshold and the previous mapQ threshold.
Number of wrong mappings in the same mapQ interval
Accumulative mapping error rate
Accumulative number of mappings
For paftools.js mapeval to work, you need to encode the true read positions
in read names in the right format. For PBSIM and mason2, we
provide scripts to generate the right format. Simulated reads in this cookbook
were created with the following command lines:
This is because minimap2 models one additional evolutionarily conserved base
around a canonical junction, but SIRV doesn't honor this signal. Option
--splice-flank=no asks minimap2 no to model this additional base.
In the output a tag ts:A:+ indicates that the read strand is the same as the
transcript strand; ts:A:- indicates the read strand is opposite to the
transcript strand. This tag is inferred from the GT-AG signal and is thus only
available to spliced reads.
Direct-RNA reads are noisier, so we use a shorter k-mer for improved
sensitivity. Here, option -uf forces minimap2 to map reads to the forward
transcript strand only because direct-RNA reads are stranded. Again, applying
--splice-flank=no helps junction accuracy for SIRV data.
Option -C5 reduces the penalty on non-canonical splicing sites. It helps
to align such sites correctly for data with low error rate such as Iso-seq
reads and traditional cDNAs. On this example, minimap2 makes one junction
error. Applying --splice-flank=no fixes this alignment error.
Note that the command line above is optimized for the final Iso-seq reads.
PacBio's Iso-seq pipeline produces intermediate sequences at varying quality.
For example, some intermediate reads are not stranded. For these reads, option
-uf will lead to more errors. Please revise the minimap2 command line
accordingly.
Full-Genome Alignment
Intra-species assembly alignment
# option "--cs" is recommended as paftools.js may need it
minimap2 -cx asm5 --cs ecoli_ref.fa ecoli_canu.fa > ecoli_canu.paf
Here ecoli_canu.fa is the Canu assembly of ecoli_p6_25x_canu.fa. This
command line outputs alignments in the PAF format. Use -a instead of
-c to get output in the SAM format.
Minimap2 has three presets for full-genome alignment: "asm5" for sequence
divergence below 1%, "asm10" for divergence around a couple of percent and
"asm20" for divergence not more than 10%. In theory, with the right setting,
minimap2 should work for sequence pairs with sequence divergence up to ~15%,
but this has not been carefully evaluated.
Eyeballing alignment
# option "--cs" required; minimap2-r741 or higher required for the "asm20" preset
minimap2 -cx asm20 --cs ecoli_ref.fa ecoli_O104:H4.fa | paftools.js view - | less -S
This prints the alignment in a BLAST-like format.
Calling variants from assembly-to-reference alignment
# don't forget the "--cs" option; otherwise it doesn't work
minimap2 -cx asm5 --cs ecoli_ref.fa ecoli_canu.fa \
| sort -k6,6 -k8,8n \
| paftools.js call -f ecoli_ref.fa - > out.vcf
Without option -f, paftools.js call outputs in a custom format. In this
format, lines starting with R give the regions covered by one contig only.
This information is not available in the VCF output.
Option -D asks minimap2 to ignore anchors from perfect self match and -P
outputs all chains. For large nomes, we don't recommend to perform base-level
alignment (with -c, -a or --cs) when -P is applied. This is because
base-alignment is slow and occasionally gives wrong alignments close to the
diagonal of a dotter plot. For E. coli, though, base-alignment is still fast.
This lifts over a region on query sequences to one or multiple regions on
reference sequences. Note that this paftools.js command may not be efficient
enough to lift millions of regions.
Read Overlap
Long read overlap
# For pacbio reads:
minimap2 -x ava-pb ecoli_p6_25x_canu.fa ecoli_p6_25x_canu.fa > overlap.paf
# For Nanopore reads (ava-ont also works with PacBio but not as good):
minimap2 -x ava-ont -r 10000 ecoli_p6_25x_canu.fa ecoli_p6_25x_canu.fa > overlap.paf
# If you have miniasm installed:
miniasm -f ecoli_p6_25x_canu.fa overlap.paf > asm.gfa
Here we explicitly applied -r 10000. We are considering to set this as the
default for the ava-ont mode as this seems to improve the contiguity for
nanopore read assembly (Loman, personal communication).
Minimap2 doesn't work well with short-read overlap.