Claude
Skills
Sign in
Back

bio-genome-assembly-hifi-assembly

Included with Lifetime
$97 forever

Assembles haplotype-resolved diploid and telomere-to-telomere (T2T) genomes from PacBio HiFi reads with hifiasm (HiFi-only, Hi-C, or trio phasing) and verkko (HiFi + ultralong ONT for T2T), extracting contigs from GFA and routing phasing QC to k-mer/trio metrics. Covers why a primary assembly is a haplotype mosaic that exists in no cell, partial-vs-full phasing (the .bp. vs .dip. filename convention), the purge-default trap on inbred samples, the --hom-cov coverage-estimate alarm, and verkko-vs-hifiasm for T2T. Use when assembling a diploid eukaryote from HiFi, phasing haplotypes with parents (trio) or Hi-C, deciding whether to chase T2T, or diagnosing switch errors invisible to N50/BUSCO/QV.

General

What this skill does


## Version Compatibility

Reference examples tested with: hifiasm 0.25.0+, yak 0.1+, verkko 2.3+, gfatools 0.5+, meryl 1.4+.

Before using code patterns, verify installed versions match. If versions differ:
- CLI: `<tool> --version` then `<tool> --help` to confirm flags

hifiasm output filenames AND the default purge level are version-dependent: confirm the `.bp.*`/`.dip.*` prefixes and `-l` defaults against `hifiasm --help` and the man page for the installed build before scripting around them. The k-mer-size convention also matters more than the binary version: hifiasm/yak trio uses k=31; verkko/Merqury hap-mers commonly use k=30 - mixing them silently produces garbage hap-mer matching. If a command errors, introspect the installed tool and adapt rather than retrying.

# HiFi Assembly

**"Assemble a diploid genome from HiFi reads"** -> Build two cleanly phased haplotypes (not one mosaic primary) from accurate long reads, choosing the phasing mechanism from the sample type and available data, and validate phasing with k-mer QC the headline metrics cannot see.
- CLI: `hifiasm -o prefix -t 32 reads.hifi.fq.gz` (HiFi-only), `--h1/--h2` (Hi-C), `-1/-2 *.yak` (trio); `verkko --hifi ... --nano ...` (T2T)

## The Single Most Important Modern Insight -- A Primary Assembly Is a Mosaic Chimera, Not a Haplotype

A "primary assembly" is not a genome that exists in any cell. At every heterozygous block the assembler picks one allele, and which one it picks switches arbitrarily from block to block - so the primary is a stitched chimera: maternal here, paternal there, matching no gamete, no parent, no individual. It is a fine *haploid representation* for "roughly where is gene X" and a terrible substrate for anything allele-aware (phased variant calling, allele-specific expression, HLA/KIR typing, compound-heterozygote analysis). HiFi's combination of length AND ~Q30 accuracy made *phased diploid* assembly routine, so the field's deliverable shifted from one collapsed reference to **two phased haplotypes** (and onward to the **pangenome**: each HPRC node is a per-sample phased diploid assembly, Liao 2023 *Nature* 617:312).

**The killer corollary:** the thing that is wrong with a mosaic - that it is a haplotype mix - is exactly the thing none of the metrics people check can see. A switch error does not break a contig (N50 unchanged), delete a gene (BUSCO unchanged), or introduce a wrong base (QV unchanged - both alleles are real sequence, just assigned to the wrong haplotype). **Switch errors and haplotype mosaicism are structurally invisible to N50, BUSCO, and even base-level QV.** Only k-mer/trio QC - Merqury hap-mer blob plots and switch/hamming error against parental k-mers - can see them. "Reported N50 and BUSCO but no switch/hamming or hap-mer plot" means the phasing was never validated. Subtle trap: the HiFi-only `.bp.hap1/hap2` are *partially* phased (locally phased, switch errors between blocks) - "hap1" in a filename does NOT certify global phasing; the phasing *data* supplied (trio or Hi-C) does.

## Tool Taxonomy

| Tool | Citation | Role | When |
|------|----------|------|------|
| hifiasm | Cheng 2021 *Nat Methods* | phased string-graph HiFi assembler; built-in purging | the default for diploid HiFi; HiFi-only / Hi-C / trio / `--ul` |
| hifiasm (Hi-C) | Cheng 2022 *Nat Biotechnol* | global phasing from proximity-ligation, no parents | diploid, Hi-C available, parents unavailable (the broad default) |
| yak | (Li, hifiasm suite) | parental haplotype-specific k-mer DBs for trio | feeds hifiasm `-1/-2`; trio gold-standard phasing |
| verkko | Rautiainen 2023 *Nat Biotechnol* | HiFi + ultralong-ONT graph assembler (MBG -> GraphAligner -> rukki) | T2T-grade; trio or Hi-C phasing; reference-quality |
| verkko2 | Antipov 2025 *Genome Res* | adds proximity-ligation phasing into the De Bruijn graph | T2T with Hi-C; ~doubled T2T-scaffold yield |
| HiCanu | Nurk 2020 *Genome Res* | HiFi Canu fork; segmental dups/satellites/allelic variants | legacy/SD-focused; superseded by hifiasm for routine diploid |
| meryl/Merqury | Rhie 2020 *Genome Biol* | hap-mer DBs; k-mer QV, completeness, switch/hamming, blob plots | the only QC that sees phasing (-> assembly-qc) |

## Decision Tree by Scenario

| Scenario | Recommended | Why |
|----------|-------------|-----|
| Sample type/heterozygosity unknown | profile first: k-mer spectrum (GenomeScope) for genome size + heterozygosity | purge setting, n-hap, and whether to phase are all downstream of outbred-vs-inbred |
| Outbred diploid, HiFi only, quick draft | hifiasm default | primary + partially-phased `.bp.hap1/hap2`; partial phasing is the cost of no linkage data |
| Diploid, HiFi + Hi-C, no parents | hifiasm `--h1/--h2` (Cheng 2022) | global phasing from the sample itself; the pragmatic default for the non-human bestiary |
| Diploid, HiFi + both parents | hifiasm trio `-1 pat.yak -2 mat.yak` | gold standard - read-level phasing, no switch ambiguity where parents are informative |
| Inbred / doubled-haploid / mole | hifiasm `-l0` (purging OFF) | nothing to phase; default purging would DELETE real segmental duplications |
| Unbalanced hap1/hap2 size after a run | re-run with `--hom-cov` set to the k-mer peak | the size imbalance is a mis-estimated coverage alarm, not a phasing result |
| T2T-grade reference, have HiFi + ultralong ONT + trio/Hi-C | verkko (or hifiasm `--ul` for speed) | only graph + UL spanning reaches gapless centromeres; T2T is a project, not a flag |
| No ultralong ONT but want a reference | hifiasm-HiFi-only is the sensible stop | neither tool reaches T2T without UL reads to span repeats |
| One of 50 individuals in a diversity panel | phased diploid (primary may suffice) | do NOT chase T2T per-sample; match grade to question |
| Reads not yet QC'd | -> long-read-sequencing/long-read-qc | HiFi length/QV/contamination cap assembly quality |

## hifiasm Invocations (the fragile commands - run as written)

```bash
# HiFi-only (default): primary mosaic + PARTIALLY-phased hap1/hap2
hifiasm -o prefix -t 32 reads.hifi.fq.gz

# Hi-C phased (no parents) - Cheng 2022; global phasing
hifiasm -o prefix -t 32 --h1 hic_R1.fq.gz --h2 hic_R2.fq.gz reads.hifi.fq.gz

# Trio phased (gold standard) - build parental k-mer DBs first (k=31)
yak count -k31 -b37 -t16 -o pat.yak paternal_R1.fq.gz paternal_R2.fq.gz
yak count -k31 -b37 -t16 -o mat.yak maternal_R1.fq.gz maternal_R2.fq.gz
hifiasm -o prefix -t 32 -1 pat.yak -2 mat.yak reads.hifi.fq.gz

# Inbred / homozygous / mole: DISABLE purging or real duplications are deleted
hifiasm -o prefix -t 32 -l0 reads.hifi.fq.gz

# Unbalanced haplotype sizes: pin the homozygous-coverage peak read off the k-mer histogram
hifiasm -o prefix -t 32 --hom-cov 38 reads.hifi.fq.gz

# Ultralong ONT toward T2T (combine with Hi-C or trio for phasing)
hifiasm -o prefix -t 32 --ul ul_ont.fq.gz reads.hifi.fq.gz
```

**Key flags:** `-l` purge level (`0` none, `1` light, `2`/`3` aggressive; **default 3 in HiFi-only, 0 in trio**); `--h1/--h2` Hi-C R1/R2; `-1/-2` paternal/maternal yak DBs; `--ul` ultralong ONT; `--hom-cov INT` force the homozygous-coverage peak; `--n-hap INT` ploidy (default 2); `--primary` emit primary + alternate (`a_ctg`) instead of dual hap1/hap2.

## Output Filenames: the .bp. vs .dip. Convention (read the prefix, it encodes the mode)

The prefix is not cosmetic - it tells how the assembly was phased:
- **`.bp.` ("balanced phasing") = HiFi-only OR Hi-C mode.** `prefix.bp.p_ctg.gfa` (the mosaic primary), `prefix.bp.hap1.p_ctg.gfa`/`prefix.bp.hap2.p_ctg.gfa` (the two haplotypes - *partially* phased in HiFi-only, *fully* phased with Hi-C). Also `prefix.bp.r_utg.gfa`/`p_utg.gfa` (unitig graphs).
- **`.dip.` ("diploid") = trio mode.** `prefix.dip.hap1.p_ctg.gfa` (paternal/hap1), `prefix.dip.hap2.p_ctg.gfa` (maternal/hap2).
- **`--primary` mode:** `prefix.p_ctg.gfa` (primary) + `prefix.a_ctg.gfa` (alternate). The alternate is incomplete by construction (only heterozygous loci produce alt
Files: 3
Size: 27.3 KB
Complexity: 45/100
Category: General

Related in General