Hifiasm is a fast haplotype-resolved de novo assembler initially designed for PacBio HiFi reads.
Its latest release could support the telomere-to-telomere assembly by utilizing ultralong Oxford Nanopore reads. Hifiasm produces arguably the best single-sample telomere-to-telomere assemblies combing HiFi, ultralong and Hi-C reads, and it is one of the best haplotype-resolved assemblers for the trio-binning assembly given parental short reads. For a human genome, hifiasm can produce the telomere-to-telomere assembly in one day.
Why Hifiasm?
Hifiasm delivers high-quality telomere-to-telomere assemblies. It tends to generate longer contigs
and resolve more segmental duplications than other assemblers.
Given Hi-C reads or short reads from the parents, hifiasm can produce overall the best
haplotype-resolved assembly so far. It is the assembler of choice by the
Human Pangenome Project for the first batch of samples.
Hifiasm can purge duplications between haplotigs without relying on
third-party tools such as purge_dups. Hifiasm does not need polishing tools
like pilon or racon, either. This simplifies the assembly pipeline and saves
running time.
Hifiasm is fast. It can assemble a human genome in half a day and assemble a
~30Gb redwood genome in three days. No genome is too large for hifiasm.
Hifiasm is trivial to install and easy to use. It does not required Python,
R or C++11 compilers, and can be compiled into a single executable. The
default setting works well with a variety of genomes.
Usage
Assembling HiFi reads without additional data types
A typical hifiasm command line looks like:
hifiasm -o NA12878.asm -t 32 NA12878.fq.gz
where NA12878.fq.gz provides the input reads, -t sets the number of CPUs in
use and -o specifies the prefix of output files. For this example, the
primary contigs are written to NA12878.asm.bp.p_ctg.gfa.
Since v0.15, hifiasm also produces two sets of
partially phased contigs at NA12878.asm.bp.hap?.p_ctg.gfa. This pair of files
can be thought to represent the two haplotypes in a diploid genome, though with
occasional switch errors. The frequency of switches is determined by the
heterozygosity of the input sample.
At the first run, hifiasm saves corrected reads and
overlaps to disk as NA12878.asm.*.bin. It reuses the saved results to avoid
the time-consuming all-vs-all overlap calculation next time. You may specify
-i to ignore precomputed overlaps and redo overlapping from raw reads.
You can also dump error corrected reads in FASTA and read overlaps in PAF with
Hifiasm purges haplotig duplications by default. For inbred or homozygous
genomes, you may disable purging with option -l0. Old HiFi reads may contain
short adapter sequences at the ends of reads. You can specify -z20 to trim
both ends of reads by 20bp. For small genomes, use -f0 to disable the initial
bloom filter which takes 16GB memory at the beginning. For genomes much larger
than human, applying -f38 or even -f39 is preferred to save memory on k-mer
counting.
Assembling ONT reads
Since version 0.21.0 (r686), hifiasm can support ONT assembly using ONT simplex R10 reads.
To enable this feature, add the --ont option as shown below:
hifiasm -t64 --ont -o ONT.asm ONT.read.fastq.gz
Please note that this module requires input reads in FASTQ format.
Hi-C integration
Hifiasm can generate a pair of haplotype-resolved assemblies with paired-end
Hi-C reads:
In this mode, each contig is supposed to be a haplotig, which by definition
comes from one parental haplotype only. Hifiasm often puts all contigs from the
same parental chromosome in one assembly. It has cleanly separated chrX and
chrY for a human male dataset. Nonetheless, phasing across centromeres is
challenging. Hifiasm is often able to phase entire chromosomes but it may fail
in rare cases. Also, contigs from different parental chromosomes are randomly mixed as
it is just not possible to phase across chromosomes with Hi-C.
Hifiasm does not perform scaffolding for now. You need to run a standalone
scaffolder such as SALSA or 3D-DNA to scaffold phased haplotigs.
Trio binning
When parental short reads are available, hifiasm can also generate a pair of
haplotype-resolved assemblies with trio binning. To perform such assembly, you
need to count k-mers first with yak first and then do assembly:
Here NA12878.asm.dip.hap1.p_ctg.gfa and NA12878.asm.dip.hap2.p_ctg.gfa give the two
haplotype assemblies. In the binning mode, hifiasm does not purge haplotig
duplicates by default. Because hifiasm reuses saved overlaps, you can
generate both primary/alternate assemblies and trio binning assemblies with
For diploid haplotype-resolved genome assembly, hifiasm can further enhance assembly contiguity
by introducing scaffolding. It leverages the assemblies of the two haplotypes to scaffold each other.
Specifically, if there is a gap within the haplotype 1 assembly, hifiasm will use the corresponding
homologous region in haplotype 2 to scaffold haplotype 1. Below is an example using the --dual-scaf option.
Hifiasm generates different types of assemblies based on the input data.
It also writes error corrected reads to the prefix.ec.bin binary file and
writes overlaps to prefix.ovlp.source.bin and prefix.ovlp.reverse.bin.
For more details, please see the complete documentation.
Results
The following table shows the statistics of several hifiasm primary assemblies assembled with v0.12:
Hifiasm can assemble a 3.1Gb human genome in several hours or a ~30Gb hexaploid
redwood genome in a few days on a single machine. For trio binning assembly:
Human assemblies above can be acquired from Zenodo and
non-human ones are available here.
Getting Help
For detailed description of options, please see tutorial or man ./hifiasm.1. The -h
option of hifiasm also provides brief description of options. If you have
further questions, please raise an issue at the issue
page.
Limitations
Purging haplotig duplications may introduce misassemblies.
Citating Hifiasm
If you use hifiasm in your work, please cite:
Cheng, H., Concepcion, G.T., Feng, X., Zhang, H., Li H. (2021)
Haplotype-resolved de novo assembly using phased assembly graphs with
hifiasm. Nat Methods, 18:170-175.
https://doi.org/10.1038/s41592-020-01056-5
Cheng, H., Jarvis, E.D., Fedrigo, O., Koepfli, K.P., Urban, L., Gemmell, N.J., Li, H. (2022)
Haplotype-resolved assembly of diploid genomes without parental data.
Nature Biotechnology, 40:1332–1335.
https://doi.org/10.1038/s41587-022-01261-x
Cheng, H., Asri, M., Lucas, J., Koren, S., Li, H. (2024)
Scalable telomere-to-telomere assembly for diploid and polyploid genomes with double graph.
Nat Methods, 21:967-970.
https://doi.org/10.1038/s41592-024-02269-8
Getting Started
See tutorial for more details.
Table of Contents
Introduction
Hifiasm is a fast haplotype-resolved de novo assembler initially designed for PacBio HiFi reads. Its latest release could support the telomere-to-telomere assembly by utilizing ultralong Oxford Nanopore reads. Hifiasm produces arguably the best single-sample telomere-to-telomere assemblies combing HiFi, ultralong and Hi-C reads, and it is one of the best haplotype-resolved assemblers for the trio-binning assembly given parental short reads. For a human genome, hifiasm can produce the telomere-to-telomere assembly in one day.
Why Hifiasm?
Hifiasm delivers high-quality telomere-to-telomere assemblies. It tends to generate longer contigs and resolve more segmental duplications than other assemblers.
Given Hi-C reads or short reads from the parents, hifiasm can produce overall the best haplotype-resolved assembly so far. It is the assembler of choice by the Human Pangenome Project for the first batch of samples.
Hifiasm can purge duplications between haplotigs without relying on third-party tools such as purge_dups. Hifiasm does not need polishing tools like pilon or racon, either. This simplifies the assembly pipeline and saves running time.
Hifiasm is fast. It can assemble a human genome in half a day and assemble a ~30Gb redwood genome in three days. No genome is too large for hifiasm.
Hifiasm is trivial to install and easy to use. It does not required Python, R or C++11 compilers, and can be compiled into a single executable. The default setting works well with a variety of genomes.
Usage
Assembling HiFi reads without additional data types
A typical hifiasm command line looks like:
where
NA12878.fq.gzprovides the input reads,-tsets the number of CPUs in use and-ospecifies the prefix of output files. For this example, the primary contigs are written toNA12878.asm.bp.p_ctg.gfa. Since v0.15, hifiasm also produces two sets of partially phased contigs atNA12878.asm.bp.hap?.p_ctg.gfa. This pair of files can be thought to represent the two haplotypes in a diploid genome, though with occasional switch errors. The frequency of switches is determined by the heterozygosity of the input sample.At the first run, hifiasm saves corrected reads and overlaps to disk as
NA12878.asm.*.bin. It reuses the saved results to avoid the time-consuming all-vs-all overlap calculation next time. You may specify-ito ignore precomputed overlaps and redo overlapping from raw reads. You can also dump error corrected reads in FASTA and read overlaps in PAF withHifiasm purges haplotig duplications by default. For inbred or homozygous genomes, you may disable purging with option
-l0. Old HiFi reads may contain short adapter sequences at the ends of reads. You can specify-z20to trim both ends of reads by 20bp. For small genomes, use-f0to disable the initial bloom filter which takes 16GB memory at the beginning. For genomes much larger than human, applying-f38or even-f39is preferred to save memory on k-mer counting.Assembling ONT reads
Since version 0.21.0 (r686), hifiasm can support ONT assembly using ONT simplex R10 reads. To enable this feature, add the
--ontoption as shown below:Please note that this module requires input reads in FASTQ format.
Hi-C integration
Hifiasm can generate a pair of haplotype-resolved assemblies with paired-end Hi-C reads:
In this mode, each contig is supposed to be a haplotig, which by definition comes from one parental haplotype only. Hifiasm often puts all contigs from the same parental chromosome in one assembly. It has cleanly separated chrX and chrY for a human male dataset. Nonetheless, phasing across centromeres is challenging. Hifiasm is often able to phase entire chromosomes but it may fail in rare cases. Also, contigs from different parental chromosomes are randomly mixed as it is just not possible to phase across chromosomes with Hi-C.
Hifiasm does not perform scaffolding for now. You need to run a standalone scaffolder such as SALSA or 3D-DNA to scaffold phased haplotigs.
Trio binning
When parental short reads are available, hifiasm can also generate a pair of haplotype-resolved assemblies with trio binning. To perform such assembly, you need to count k-mers first with yak first and then do assembly:
Here
NA12878.asm.dip.hap1.p_ctg.gfaandNA12878.asm.dip.hap2.p_ctg.gfagive the two haplotype assemblies. In the binning mode, hifiasm does not purge haplotig duplicates by default. Because hifiasm reuses saved overlaps, you can generate both primary/alternate assemblies and trio binning assemblies withThe second command line will run much faster than the first.
Ultra-long ONT integration
Hifiasm could integrate ultra-long ONT reads to produce the telomere-to-telomere assembly:
For the single-sample telomere-to-telomere assembly with Hi-C reads:
For the trio-binning telomere-to-telomere assembly:
Self-scaffolding
For diploid haplotype-resolved genome assembly, hifiasm can further enhance assembly contiguity by introducing scaffolding. It leverages the assemblies of the two haplotypes to scaffold each other. Specifically, if there is a gap within the haplotype 1 assembly, hifiasm will use the corresponding homologous region in haplotype 2 to scaffold haplotype 1. Below is an example using the
--dual-scafoption.Preserve more telomeres for T2T assemblies
Hifiasm can preserve more telomeres by specifying the telomere motif using the
--telo-moption. Below is an example applied to human genome assembly.Output files
Hifiasm generates different types of assemblies based on the input data. It also writes error corrected reads to the prefix.ec.bin binary file and writes overlaps to prefix.ovlp.source.bin and prefix.ovlp.reverse.bin. For more details, please see the complete documentation.
Results
The following table shows the statistics of several hifiasm primary assemblies assembled with v0.12:
Hifiasm can assemble a 3.1Gb human genome in several hours or a ~30Gb hexaploid redwood genome in a few days on a single machine. For trio binning assembly:
Human assemblies above can be acquired from Zenodo and non-human ones are available here.
Getting Help
For detailed description of options, please see tutorial or
man ./hifiasm.1. The-hoption of hifiasm also provides brief description of options. If you have further questions, please raise an issue at the issue page.Limitations
Citating Hifiasm
If you use hifiasm in your work, please cite: