HapCUT2 Haplotype Assembly Tool

repository·master·Indexed 42 days ago

https://github.com/vibansal/hapcut2

A maximum-likelihood-based tool for robust haplotype assembly from diverse sequencing technologies, including NGS short reads, long reads (PacBio/ONT), Linked-Reads, and Hi-C. It utilizes a two-step pipeline consisting of extractHAIRS for fragment extraction and HapCUT2 for assembly. The tool includes specialized Snakemake recipes for 10X Genomics, Hi-C, and combined data workflows.

Tokens
5.1K
Snippets
16
Records
27
Agent score
53%

What's inside HapCUT2

  1. HapCUT2 Recipe Pipeline Types

    master

    HapCUT2 provides sample pipelines for assembling haplotypes from different sequencing data types. These pipelines are organized into specific directories based on the input data used:

    • HiC: For Hi-C (proximity ligation) reads.
    • 10X: For 10X Genomics gemcode linked-reads.
    • HiC_10X: A combination of Hi-C and 10X data.
    • HiC_Longread: A combination of Hi-C and generic long-read data (e.g., PacBio).
  2. Requirements for the Hi-C + Longread pipeline

    master

    To run the Hi-C and Long-read assembly pipeline, the following software and data are required:

    Software Dependencies:

    • Snakemake: version 3.5.5
    • HapCUT2: (See root README for installation)
    • extractHAIRS: (See root README for installation)
    • BWA: version 0.7.12-r1044
    • Samtools: version 1.3
    • htslib: version 1.3
    • Picard Tools: version 2.8
    • Bamtools: version 2.4

    Data Dependencies:

    • Reference genome (FASTA)
    • Aligned long-read BAM file
    • Paired-end Hi-C FASTQ files (*_1.fastq, *_2.fastq)
    • Individual-specific VCF files (chr1.vcf, chr2.vcf, ...)
  3. Assemble haplotypes using the two-step pipeline

    master

    Haplotype assembly is a two-step process.

    Step 1: Extract fragments with extractHAIRS

    Convert your BAM file into a compact fragment file format. This is a mandatory precursor to running HapCUT2.

    Step 2: Assemble haplotypes with HAPCUT2

    Use the fragment file generated in Step 1 to assemble haplotype blocks.

    Input Requirements:

    • A BAM file containing reads aligned to a reference genome.
    • A VCF file containing short variant calls (SNVs and indels) and diploid genotypes for the same individual. Note: The program does not accept gzipped VCF files.

    If you have data from different technologies or multiple BAM files for the same individual, run Step 1 on each BAM file separately, concatenate the resulting fragment files, and then run Step 2 on the combined file.

    # 1. Extract fragments
    ./build/extractHAIRS [options] --bam reads.sorted.bam --VCF variants.vcf --out fragment_file
    
    # 2. Assemble haplotypes
    ./build/HAPCUT2 --fragments fragment_file --VCF variants.vcf --output haplotype_output_file
  4. Phasing data from multiple sequencing technologies

    master

    To combine data from different technologies (e.g., combining long reads with Hi-C reads):

    1. Run extractHAIRS on each BAM/CRAM file independently.
    2. Use the --nf 1 option in extractHAIRS to output fragments in the Hi-C fragment file format.
    3. Concatenate the resulting fragment files using the Linux cat command.
    4. Run HAPCUT2 on the concatenated file, also using the --nf 1 option.
  5. Install and build HapCUT2

    master

    HapCUT2 requires htslib > 1.2.1 to be installed on your system. If htslib is not in your standard path, you can specify its location in the Makefile using HTSLIB=path.

    To build the project, use the standard make command.

    # Install htslib if not present
    git clone https://github.com/samtools/htslib.git
    
    # Build HapCUT2
    make
  6. Reproduce HapCUT2 results using Duitama et al fosmid data

    master

    This guide provides instructions for reproducing the results from the Duitama et al. (2011) study using HapCUT2. The process involves downloading 1000 Genomes VCFs, filtering for heterozygous sites, preparing fosmid fragment files, running HapCUT2 on each fragment, and calculating accuracy statistics against the 1000G trio-phased VCF ground truth.

    Prerequisites:

    • A Linux machine (tested on Ubuntu).
    • HapCUT2 must be built using the makefile following the instructions in the main repository README.

    Workflow Summary:

    1. Download and filter 1000 Genomes VCFs (phase 1, hg18) for the NA12878 trio.
    2. Ensure variant indices and genomic coordinates match between the filtered VCF and the Duitama phased haplotype data.
    3. Prepare fosmid fragment files by removing the first line (matrix dimensions) to ensure compatibility with HapCUT2.
    4. Execute HapCUT2 on each fragment file.
    5. Calculate haplotype accuracy using the calculate_haplotype_statistics.py script.
    # Navigate to the reproduction directory
    cd HapCUT2/reproduce_hapcut2_paper/run_hapcut2_fosmid
    
    # Run the reproduction script
    bash run_hapcut2_fosmid_data.sh
    
    # OR
    chmod +x run_hapcut2_fosmid_data.sh
    ./run_hapcut2_fosmid_data.sh
  7. Requirements for the 10X assembly pipeline

    master

    To run the 10X Genomics assembly pipeline, ensure the following dependencies and data formats are available:

    Software Requirements:

    • Snakemake (version 3.5.5)
    • HapCUT2 and extractHAIRS (refer to the root README for installation)
    • pysam (version 0.11.2)
    • Samtools (version 1.3)
    • htslib (version 1.3)

    Data Requirements:

    • A reference genome in .fasta format.
    • A .bam file containing aligned, barcoded 10X reads (must contain the BX tag).
    • VCF files containing variants for the individual, named by chromosome (e.g., chr1.vcf, chr2.vcf, etc.).
  8. Assemble haplotypes from 10X Genomics data using Snakemake

    master

    This pipeline uses Snakemake to automate the assembly of haplotypes from 10X Genomics data for a single individual. It expects 10X reads to be in an aligned BAM format (ideally aligned using tools like 10X's LongRanger).

    Before running, you must edit the top of the Snakefile to provide the absolute paths to your required data and software tools. The pipeline outputs haplotype block files in the output/chr*.hap directory.

    snakemake