hifiasm Documentation

repository·master·Indexed 21 days ago

https://github.com/chhylp123/hifiasm

A high-performance, haplotype-resolved de novo assembler designed for PacBio HiFi reads. It supports ONT R10, Hi-C, and Trio-binning data to achieve telomere-to-telomere (T2T) assemblies. Key features include self-scaffolding via --dual-scaf, telomere preservation with --telo-m, and support for inbred, homozygous, and polyploid genomes.

Tokens
8.6K
Snippets
25
Records
53
Agent score
67%

What's inside hifiasm

  1. Manage Hi-C alignment bin files (*hic*.bin)

    master

    During the first run, hifiasm saves Hi-C read alignments to disk as *hic*.bin files to avoid re-aligning them in subsequent runs.

    Important: If you tune any parameters that affect the *p_utg*gfa output, you should delete the *hic*.bin files to ensure consistency. Since v0.15.5, hifiasm can automatically detect changes and renew these files.

    Parameters that do not change *p_utg*gfa (and thus do not require deleting the .bin files) include:

    • -s
    • --seed
    • --n-weight
    • --n-perturb
    • --f-perturb
    • --l-msjoin
  2. Assemble polyploid genomes

    master

    While the contig-generation modules (partially phased and fully-phased assemblies) are optimized for diploid samples, you can handle polyploid genomes using these strategies:

    1. Lossless files: The *r_utg.gfa and *p_utg.gfa files are lossless and work for polyploid genomes.
    2. Primary assembly: Use the primary assembly for polyploid samples. Setting the ploidy parameter to >2 may improve the quality of the primary assembly.
    3. Third-party purging: Run multiple rounds of purging steps using external tools like purge_dups.
  3. Understand hifiasm bin files and reuse

    master

    Hifiasm produces several .bin files that store intermediate results:

    • *ec.bin, *ovlp.reverse.bin, *ovlp.source.bin: Save results from the error correction step. These are shared between HiFi-only, Hi-C phased, and trio-binning assemblies, allowing you to add Hi-C or trio data to a pre-existing HiFi assembly.
    • *hic.bin: Saves Hi-C alignment results.

    Warning: If you tune any parameters that affect *p_utg.gfa (such as -s, --seed, --n-weight, --n-perturb, or --f-perturb), you must delete *hic.bin. Since v0.15.5, hifiasm can automatically renew these files if it detects changes.

  4. Understand hifiasm assembly types

    master

    Hifiasm produces different types of assemblies depending on the input data provided:

    • HiFi-only Assembly: Produces primary/alternate assemblies or partially phased assemblies using only PacBio HiFi reads.
    • Haplotype-resolved (Fully-phased) Assembly: Produces contiguous, fully-phased assemblies when provided with additional data such as Hi-C data or trio-binning data (parental short reads).
  5. Assemble ONT R10 reads

    master

    Since version 0.21.0 (r686), hifiasm supports ONT simplex R10 reads. This requires input reads to be in FASTQ format. Use the --ont flag to enable this mode.

    hifiasm -t64 --ont -o ONT.asm ONT.read.fastq.gz
  6. Run a typical HiFi-only assembly

    master

    To perform a standard assembly using PacBio HiFi reads, use the following command structure. Input files can be in FASTA or FASTQ format, and can be uncompressed or gzip-compressed (.gz). Note that quality scores in FASTQ files are ignored.

    Key Options:

    • -o <prefix>: Specifies the prefix for all output files.
    • -t <threads>: Sets the number of CPU threads to use.
    • -i: (Optional) Ignore precomputed overlaps and redo overlapping from raw reads.
    • --write-paf: Dump read overlaps in PAF format.
    • --write-ec <file>: Dump error-corrected reads in FASTA format to the specified file (use /dev/null to discard).
    • -l0: Disable haplotig duplication purging (use this for inbred or homozygous genomes).
    • -z<bp>: Trim both ends of reads by the specified number of base pairs (e.g., -z20 for 20bp).
    • -f0: Disable the initial bloom filter (useful for small genomes to save the initial 16GB memory overhead).
    • -f<n>: Adjust k-mer counting memory for very large genomes (e.g., -f38 or -f39).
    hifiasm -o NA12878.asm -t 32 NA12878.fq.gz
  7. Choose the best assembly type for your data

    master

    The choice of assembly depends on the available data types:

    1. Trio-binning mode: Use if parental data is available. Produces *dip.hap*.p_ctg.gfa (fully-phased).
    2. Hi-C mode: Use if Hi-C data is available. Produces *hic.hap*.p_ctg.gfa (fully-phased).
    3. HiFi-only mode: Default behavior if only HiFi reads are provided. Produces *bp.hap*.p_ctg.gfa (not fully-phased). You can also produce primary/alternate assemblies using the --primary flag.

    Note: Trio-binning and Hi-C modes provide superior phasing compared to HiFi-only assemblies.

  8. Improve assembly contiguity and resolution

    master

    If your assembly is fragmented or lacks contiguity, consider the following:

    • Increase resolution: Raising -D or -N can improve the resolution of repetitive regions. This affects all assembly types and generally does not harm quality.
    • Primary assembly purging: Increasing --purge-max can make the primary assembly more contiguous, but carries a risk of collapsing repeats or segmental duplications.
    • Check data quality: If the assembly is extremely fragmented, ensure the HiFi reads are of high quality (check k-mer plots for sufficient coverage and lack of contaminants).
  9. Integrate Ultra-long ONT reads for T2T assembly

    master

    To produce telomere-to-telomere (T2T) assemblies, integrate ultra-long ONT reads using the --ul flag alongside HiFi reads. This can be combined with Hi-C or Trio binning for enhanced results.

    # Basic HiFi + Ultra-long
    hifiasm -o NA12878.asm -t32 --ul ul.fq.gz HiFi-reads.fq.gz
    
    # HiFi + Ultra-long + Hi-C
    hifiasm -o NA12878.asm -t32 --ul ul.fq.gz --h1 read1.fq.gz --h2 read2.fq.gz HiFi-reads.fq.gz
    
    # HiFi + Ultra-long + Trio binning
    hifiasm -o NA12878.asm -t32 --ul ul.fq.gz -1 pat.yak -2 mat.yak HiFi-reads.fq.gz