hifiasm
Hifiasm is a fast haplotype-resolved de novo genome assembler for PacBio HiFi reads. It can also assemble Oxford Nanopore (ONT) simplex R10 reads, and can use Hi-C reads, parental data or ultra-long ONT reads to produce haplotype-resolved and telomere-to-telomere assemblies.
License
Free to use and open source under the MIT License.
Available
- Roihu-CPU: 0.25.0, via the
bio-appsmodule.
Usage
Hifiasm is part of the bio-apps collection on Roihu. Load the bio-apps module tree and then the hifiasm module:
Assemblies take hours and a lot of memory, so run hifiasm (and the yak steps for trio binning) in a batch job, not on the login node. See the example batch script below.
Assemble HiFi reads, with -o giving the prefix of the output files and -t the
number of threads (the default is one thread):
The primary contigs are written to asm.bp.p_ctg.gfa, and two sets of partially
phased contigs to asm.bp.hap1.p_ctg.gfa and asm.bp.hap2.p_ctg.gfa. With Hi-C
phasing (--h1/--h2), the files are named asm.hic.*.gfa instead. Convert the
primary contigs to FASTA with:
Useful options:
-l0: disable duplication purging, for inbred or homozygous genomes.-f0: disable the initial bloom filter (16 GB of memory), for small genomes. For genomes much larger than human,-f38or-f39reduces the memory used for k-mer counting.--ont: assemble ONT simplex R10 reads (FASTQ) instead of HiFi reads.--h1 read1.fq.gz --h2 read2.fq.gz: phase the assembly with paired-end Hi-C reads.--ul ul.fq.gz: add ultra-long ONT reads.
Hifiasm saves the corrected reads and overlaps as asm.*.bin files and reuses them
if you run it again with the same prefix, which makes reruns with different
options much faster. The files are reused even if the input reads have changed,
so use a new prefix or the -i option when assembling different data.
Trio binning
When short reads from both parents are available, hifiasm can produce two
haplotype-resolved assemblies by trio binning. First count the parental k-mers
with yak, then give them to hifiasm with -1 (paternal) and -2
(maternal):
module load bio-apps/v202603
module load yak/0.1
module load hifiasm/0.25.0
cat pat_1.fq.gz pat_2.fq.gz > pat.fq.gz
cat mat_1.fq.gz mat_2.fq.gz > mat.fq.gz
yak count -b37 -t 16 -o pat.yak pat.fq.gz
yak count -b37 -t 16 -o mat.yak mat.fq.gz
hifiasm -o asm -t 32 -1 pat.yak -2 mat.yak reads.fq.gz 2> asm.log
Run these commands in a batch job script, such as the
example batch script below, with -t set to
$SLURM_CPUS_PER_TASK.
The two haplotype assemblies are written to asm.dip.hap1.p_ctg.gfa and
asm.dip.hap2.p_ctg.gfa. Hifiasm reuses the saved overlaps, so if you have already
run a standard assembly with the same prefix, you can give /dev/null instead of
the reads to skip read correction and overlapping.
Example batch script
#!/bin/bash
#SBATCH --job-name=hifiasm
#SBATCH --account=<project>
#SBATCH --output=output_%j.txt
#SBATCH --error=errors_%j.txt
#SBATCH --partition=small
#SBATCH --time=24:00:00
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=48
#SBATCH --mem=160G
module load bio-apps/v202603
module load hifiasm/0.25.0
hifiasm -o asm -t $SLURM_CPUS_PER_TASK reads.fq.gz
The hifiasm README reports that, with version 0.12, a human genome (3.1 Gb, about
35x HiFi coverage) took around 8 hours and 140 GB of memory with 48 threads. Smaller
genomes need far less. Replace <project> with your CSC project (for example
project_2001234).
See creating a batch job script for Roihu for more information about running batch jobs.