omics.co.in logo omics.co.in

Module 6: Spliced Read Alignment to Reference Genome with HISAT2

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
Module 06 • Spliced Alignment Track 18 • Practical Transcriptomics Hands-On Code Included

Module 6: Spliced Read Alignment to Reference Genome with HISAT2

Why traditional DNA aligners fail on eukaryotic mRNA: Hierarchical Graph FM-index (HGFM) architecture, indexing genomes with splice sites and exons, HISAT2 alignment execution, and generating SAM streams.

6. Spliced Alignment to Reference Genome with HISAT2

In eukaryotic transcriptomes, mature messenger RNAs originate from genomic exons separated by introns that span from hundreds to hundreds of thousands of base pairs. Standard DNA mappers (BWA-MEM, Bowtie2) cannot align spliced RNA-seq reads because they penalize large gaps. Spliced aligners like HISAT2 (Hierarchical Indexing for Spliced Alignment of Transcripts) utilize a Hierarchical Graph FM-index (HGFM) to map split-reads across intron junctions with extreme speed and low memory (~4 GB RAM for human).

Building the Spliced HISAT2 Genome Index

# 1. Extract splice sites and exons from Ensembl/GENCODE GTF annotation
hisat2_extract_splice_sites.py ref/Homo_sapiens.GRCh38.110.gtf > ref/splice_sites.txt
hisat2_extract_exons.py ref/Homo_sapiens.GRCh38.110.gtf > ref/exons.txt

# 2. Build HISAT2 index incorporating annotated junctions
hisat2-build -p 16 \
  --ss ref/splice_sites.txt \
  --exon ref/exons.txt \
  ref/Homo_sapiens.GRCh38.dna.primary_assembly.fa \
  ref/hisat2_grch38_index

Executing Spliced Alignment with Samtools Streaming

# Spliced paired-end alignment piped directly into coordinate-sorted BAM
hisat2 -p 16 \
  --dta \
  -x ref/hisat2_grch38_index \
  -1 02_trimmed_data/Sample1_R1.trimmed.fastq.gz \
  -2 02_trimmed_data/Sample1_R2.trimmed.fastq.gz \
  --rna-strandness RF \
  --summary-file 04_alignment/Sample1_hisat2_summary.txt | \
  samtools view -@ 8 -bS - | \
  samtools sort -@ 8 -o 04_alignment/Sample1.sorted.bam -

# Index the BAM file
samtools index 04_alignment/Sample1.sorted.bam
⚠️

Common Pitfalls & Troubleshooting Checklist

  • Java Heap Exhaustion (GATK / Picard): If processes terminate with java.lang.OutOfMemoryError, set your environment variable explicitly: export _JAVA_OPTIONS="-Xmx16g -Djava.io.tmpdir=/tmp".
  • Index Timestamp Mismatch: If tools complain that a BAM index is missing or out of date, regenerate with samtools index -@ 4 sample.bam.
  • Conda Channel Conflicts: Avoid ABI incompatibilities between bioconda and conda-forge by setting strict priority: conda config --set channel_priority strict.
  • Chromosome Naming Contamination: Always verify whether reference FASTA headers use chr1 or 1; divergent naming causes silent alignment drops.
Was this guide helpful to your research?
Help us maintain 100% accurate, peer-reviewed bioinformatics standards.
📝 Propose Edit on GitHub ↗