# Aligners

> Why RNA-seq read alignment is difficult, the algorithms and characteristics of spliced aligners such as STAR, HISAT2, and TopHat, and the uses of other aligners including Bowtie, BWA, and minimap2.

An **aligner** is a type of **analysis software** that matches short sequences, or reads, stored in FASTQ to a reference genome or transcriptome. STAR and HISAT2 are representative aligners for RNA-seq. Their output is stored in `SAM/BAM`, a file containing alignment information.

```text
FASTQ -> alignment(STAR/HISAT2, etc.) -> SAM/BAM -> count/assembly/variant/fusion analysis
```

A DNA-seq aligner can generally assume that a read came from a continuous region of the genome. An RNA-seq read, however, comes from mature mRNA and can cross the joined boundary between exons, called a **splice junction**. From the genome's perspective, the front of the read may need to align to exon 1 and the back to exon 2, thousands of base pairs away.

RNA-seq therefore usually requires a **spliced aligner**.

```text
read:       AAAAAAA|GGGGGGG
genome:     exon 1 |---- intron ----| exon 2
alignment:  AAAAAAA                 GGGGGGG
```

## At a glance

| Tool | Released / introduced | Main use | Key characteristic |
| --- | --- | --- | --- |
| STAR | 2012/2013 | bulk RNA-seq, fusion, large cohorts | Very fast spliced alignment, high memory use |
| HISAT2 | 2015 beta, 2019 paper | bulk RNA-seq, low memory, graph index | Hierarchical Graph FM index, can incorporate SNP and transcript information |
| TopHat / TopHat2 | 2009 / 2013 | Historically important RNA-seq aligner | Bowtie-based exon-first method, now generally a legacy tool |
| Subread / Subjunc | 2013 | expression counting, junction detection | Seed-and-vote strategy, same package ecosystem as featureCounts |
| Bowtie / Bowtie2 | 2009 / 2012 | Unspliced alignment of short reads | BWT/FM-index based, unsuitable for RNA-seq spliced alignment by itself |
| BWA | 2009 | DNA-seq short-read alignment | One of the standard BWT-based DNA aligners |
| minimap2 | 2018 | long reads, long RNA/cDNA, genome alignment | Minimizer based, important for long-read RNA-seq |

## Why RNA-seq needs its own aligners

RNA-seq alignment has four main challenges.

| Problem | Explanation |
| --- | --- |
| splice junction | One read can span two or more discontinuous positions in the genome |
| multi-mapping | The same read can align to multiple positions because of paralogs, pseudogenes, or repeats |
| sequencing error / variant | A read may not exactly match the reference because of mismatches, indels, or SNPs |
| transcript ambiguity | Isoforms share exons, making transcript-level assignment ambiguous |

Splice junctions in particular are the key distinction between DNA-seq and RNA-seq aligners.

```text
DNA-seq aligner: match a read to a continuous region of the genome
RNA-seq spliced aligner: split a read into exon segments and match them to discontinuous regions of the genome
```

## Algorithmic background

### Seed and extend

Most modern aligners do not align an entire read from the beginning with dynamic programming. They first find short pieces of the read, called **seeds**, quickly in the reference, then extend the alignment around those candidate positions.

```text
read:      ACTGACCTGAACT...
seed:      ACTGAC
candidate: a position where ACTGAC was found somewhere in the genome
extend:    extend around it while evaluating mismatches, indels, and splices
```

This method connects to older ideas used by tools such as BLAST. The difference is the use of data structures such as suffix arrays, FM-indexes, and minimizer indexes to search an entire reference genome quickly.

### BWT / FM-index

These are important concepts in the Bowtie, BWA, and HISAT families. The **Burrows-Wheeler Transform** (BWT) and **FM-index** store a large genome string in compressed form while still enabling fast searches for short queries.

Advantages:

| Advantage | Explanation |
| --- | --- |
| Low memory | Keeps the index for whole-genome searches relatively small |
| Fast exact and near-exact search | Well suited to searching for short-read seeds |
| Strong for short-read DNA/RNA alignment | A core data structure of the Illumina short-read era |

The disadvantage is that they do not directly solve the problem of a read aligning to discontinuous regions of the reference, as in splicing. TopHat therefore ran Bowtie first and inferred junctions from the remaining reads, while HISAT and HISAT2 extended the FM-index structure for RNA-seq.

### Suffix array

STAR makes extensive use of an **uncompressed suffix array** rather than a compressed FM-index. This makes seed searches very fast, but loading a human genome index requires substantial memory.

A key term in the STAR paper is **Maximal Mappable Prefix** (MMP). STAR starts at the front of a read and finds the longest prefix that can align to the reference. If a splice or mismatch interrupts it, STAR searches for another seed in the remaining portion.

```text
read:       exonA_part | exonB_part
MMP 1:      exonA_part
MMP 2:                   exonB_part
stitching:  connect the two seeds through a splice junction to form one alignment
```

## Aligners commonly used for RNA-seq

## STAR

**STAR** (Spliced Transcripts Alignment to a Reference) is an RNA-seq aligner whose paper was published online in 2012 and appeared in *Bioinformatics* in 2013. It was developed to process large transcriptome datasets such as ENCODE quickly.

Core algorithm:

| Item | Details |
| --- | --- |
| index | uncompressed suffix array |
| seed search | sequential maximum mappable seed search, Maximal Mappable Prefix (MMP) |
| splice handling | creates split alignments through seed clustering, stitching, and scoring |
| annotation use | GTF splice junctions can be included during index generation to improve [sensitivity](/en/reference/classification-metrics/#recall-how-many-actual-positives-did-we-catch) |
| output | supports sorted BAM, splice junction tables, chimeric junctions, and other outputs |

STAR's major advantage is speed. Its paper reported much faster performance than other RNA-seq aligners of the time, and it remains widely used in bulk RNA-seq pipelines. It is often selected for these situations:

| Situation | Why STAR fits |
| --- | --- |
| Human/mouse bulk RNA-seq | A well-validated default choice |
| Processing many samples | Very fast when given CPU resources |
| Fusion transcript discovery | Can use chimeric alignment output |
| Novel splice junction discovery | Can find junctions without annotation |

Cautions:

| Caution | Explanation |
| --- | --- |
| Memory use | A human genome index may require tens of GB of RAM |
| Parameter effects | Multi-mapping, chimeric alignment, and splice-overhang settings change results |
| Very short reads | Junctions are harder to detect reliably and depend more on annotation |

In practice, GTF is usually included when building the index.

```bash
STAR \
  --runThreadN 8 \
  --runMode genomeGenerate \
  --genomeDir star_index \
  --genomeFastaFiles genome.fa \
  --sjdbGTFfile annotation.gtf \
  --sjdbOverhang 100
```

`--sjdbOverhang` is usually set to `read length - 1`. For example, use 100 for a 101 bp read.

## HISAT2

**HISAT2** is the successor to HISAT. A beta release appeared in 2015, and the HISAT2 paper covering graph-based genome alignment and genotyping was published in *Nature Biotechnology* in 2019.

The core of HISAT2 is its **Hierarchical Graph FM index** (HGFM).

| Item | Details |
| --- | --- |
| index | global FM/GFM index plus many local FM/GFM indexes |
| graph support | can include SNP, haplotype, and transcript information in the index |
| memory | can align to the human genome with much less memory than STAR |
| RNA-seq support | splice-aware alignment, can use known splice-site and exon information |

HISAT2 has a smaller memory burden than STAR. It is a good choice when RNA-seq alignment must run on an ordinary server or personal workstation.

```bash
hisat2 \
  -p 8 \
  --dta \
  -x genome_index \
  -1 sample_R1.fastq.gz \
  -2 sample_R2.fastq.gz \
  -S sample.sam
```

`--dta` reports alignments in a form convenient for downstream transcript assemblers such as StringTie.

Advantages:

| Advantage | Explanation |
| --- | --- |
| Low memory | Relatively manageable even in desktop-class environments |
| Fast | Strong short-read processing through an FM-index |
| Graph index | Can incorporate known SNPs and variants into the reference |
| Works well with StringTie | Often presented as the HISAT2 + StringTie + Ballgown pipeline |

Cautions:

| Caution | Explanation |
| --- | --- |
| Fusion analysis | Less common than tools based on STAR chimeric output |
| Preparing a graph index | Indexes including SNPs or transcripts can complicate preparation and file management |
| Parameters require understanding | Use of known and novel splice sites and `--dta` depends on the purpose |

## TopHat / TopHat2

**TopHat**, released in 2009, was an early RNA-seq spliced aligner. It first used Bowtie to align reads that mapped continuously to the genome, then used the remaining reads to find splice junctions.

```text
1. First align unspliced reads with Bowtie
2. Collect unaligned reads and infer exon islands and junction candidates
3. Perform spliced alignment including the junctions
```

TopHat is historically important. The combination of TopHat and Cufflinks was widely used in the "Tuxedo pipeline" during the early years of RNA-seq analysis. For new analyses today, STAR or HISAT2 is generally recommended instead.

| Item | TopHat |
| --- | --- |
| Advantage | Popularized RNA-seq spliced alignment |
| Limitation | Slow and inefficient for modern read lengths and large datasets |
| Current role | Legacy tool, mainly encountered when reproducing older papers or maintaining old pipelines |

TopHat2 improved handling of insertions, deletions, fusion transcripts, and other situations. Even so, modern new analyses generally use HISAT2 or STAR instead of TopHat2.

## Subread / Subjunc

**Subread**, released in 2013, uses a **seed-and-vote** strategy. It extracts multiple seeds from a read, maps them to the reference, and selects the genomic location supported by the greatest number of seeds.

| Tool | Explanation |
| --- | --- |
| Subread | Used for genomic read alignment and RNA-seq expression analysis |
| Subjunc | A tool in the Subread family specialized for RNA-seq junction detection |
| featureCounts | A read-counting tool in the same package, very commonly used to create RNA-seq count matrices |

Subread itself is mentioned less often than STAR or HISAT2 as an RNA-seq aligner, but the Subread package is extremely common in RNA-seq analysis because of `featureCounts`.

## Pseudoalignment and quasi-mapping: are they aligners?

Tools such as Salmon and kallisto also appear frequently in RNA-seq expression estimation. They differ from genome aligners in the traditional sense.

| Method | Representative tools | Output | Characteristic |
| --- | --- | --- | --- |
| genome alignment | STAR, HISAT2 | BAM/SAM | Records where each read aligns in the genome |
| transcriptome quantification | Salmon, kallisto | transcript/gene abundance table | Quickly calculates compatibility with a transcriptome |

kallisto uses **pseudoalignment**, while Salmon uses **quasi-mapping** or selective alignment. Instead of generating a complete base-level alignment for every read, these methods quickly determine which transcripts are compatible with a read and estimate abundance.

Salmon and kallisto are therefore very fast and practical when the goal is **gene or transcript expression quantification**. A genome aligner is needed for these other goals:

| Goal | Why genome alignment is needed |
| --- | --- |
| Novel splice junctions | Must directly inspect exon-exon connections on the genome |
| Fusion transcripts | Requires chimeric alignments spanning distant loci or chromosomes |
| RNA editing / variant candidates | Requires reference coordinates and base-level mismatches |
| IGV visualization | Requires BAM for inspection in a genome browser |

## Aligners outside RNA-seq

## Bowtie / Bowtie2

**Bowtie** is a BWT-based short-read aligner released in 2009. Its speed and low memory use made it important in early NGS analysis.

Bowtie focused on rapidly aligning short reads to a reference and was close to ungapped alignment by default. **Bowtie2**, released in 2012, improved handling of gapped alignments and longer reads.

Bowtie and Bowtie2 do not directly handle splice junctions in RNA-seq. They instead serve supporting roles such as:

| Use | Explanation |
| --- | --- |
| TopHat's internal aligner | TopHat constructs spliced alignments on top of Bowtie/Bowtie2 |
| Transcriptome alignment | Aligning reads to a transcript FASTA in which splicing is already represented |
| QC / contamination checks | Rapid mapping to rRNA, adapters, microbial sequences, and similar references |

## BWA

**BWA** (Burrows-Wheeler Aligner) is a DNA-seq short-read aligner released in 2009. It includes the BWA-backtrack, BWA-SW, and BWA-MEM families, and BWA-MEM was a standard choice for WGS and WES analysis for many years.

| Item | BWA |
| --- | --- |
| Main use | DNA-seq, WGS, WES, targeted sequencing |
| index | BWT based |
| Role in RNA-seq | Unsuitable as the default aligner for ordinary mRNA RNA-seq because it is not a spliced aligner |

BWA can align RNA-seq reads that map to a continuous region of the genome, but it cannot naturally handle reads crossing exon-exon junctions.

## minimap2

**minimap2** is a general-purpose pairwise aligner released in 2018. It supports some short-read use cases but is especially strong for long reads and alignment between large sequences.

| Situation | Why minimap2 is often used |
| --- | --- |
| Oxford Nanopore / PacBio long reads | Handles long reads and high error rates |
| Long-read RNA-seq | Spliced alignment of full-length cDNA and direct RNA reads |
| Assembly to reference | Aligns contigs or an assembly to a reference |
| Genome-to-genome comparison | Fast alignment between large sequences |

minimap2 uses **minimizers** as seeds. It selects representative k-mers from the read and reference to find candidate positions quickly, then creates the final alignment through chaining and alignment extension.

For short-read Illumina bulk RNA-seq, STAR and HISAT2 are usually more familiar choices. minimap2 appears very frequently in long-read transcriptome analysis.

## GMAP / GSNAP / MapSplice

These tools were important aligners that addressed RNA-seq and spliced alignment before or around the same time as STAR and HISAT2.

| Tool | Characteristic |
| --- | --- |
| GMAP | A long-established splice-aware mapper for aligning cDNA/EST to a genome |
| GSNAP | A short-read aligner in the GMAP family, supporting SNP-tolerant alignment and splicing |
| MapSplice | An RNA-seq aligner focused on splice-junction discovery |

They are not the most common choices for new bulk RNA-seq analyses today, but they can still appear in result files or methods descriptions from older papers and particular pipelines.

## Which aligner should you choose?

| Goal | Recommended choice | Reason |
| --- | --- | --- |
| Ordinary human/mouse bulk RNA-seq | STAR or HISAT2 | The most widely validated spliced aligners |
| Plenty of RAM and fast processing required | STAR | Fast and well supported by downstream tools |
| Limited RAM | HISAT2 | Low memory use |
| Transcript assembly with StringTie | HISAT2 `--dta` or STAR | Produces BAM files convenient for assemblers |
| Fusion transcript discovery | STAR + Arriba/STAR-Fusion, etc. | Strong chimeric-alignment ecosystem |
| Simple expression quantification | Also consider Salmon/kallisto | Fast abundance estimates without BAM |
| Long-read RNA/cDNA | minimap2 | Strong for spliced alignment of long reads |
| Short-read DNA-seq WGS/WES | BWA-MEM/BWA-MEM2 family | Use a DNA aligner because there is no splicing |
| Long-read DNA-seq | minimap2 | Strong for Nanopore/PacBio long-read alignment |

For practice, begin with either STAR or HISAT2 to create a BAM file and inspect the alignments directly in IGV. Seeing how reads cross exon-exon junctions makes the concept of RNA-seq alignment much quicker to grasp.

## What to inspect in the results

Whichever aligner you use, you will usually inspect BAM/SAM in the end. The important items are:

| Item | Meaning |
| --- | --- |
| mapping rate | Proportion of all reads that aligned to the reference |
| uniquely mapped reads | Reads confidently aligned to only one location |
| multi-mapped reads | Reads that align similarly well to several locations |
| splice junction support | Number of reads crossing a junction |
| MAPQ | Mapping quality representing alignment confidence |
| CIGAR | Encodes matches, insertions, deletions, splice skips, and other operations |

`N` is an especially important CIGAR character in RNA-seq BAM. It means that a long region of the reference was skipped, which usually represents an intron in RNA-seq.

```text
50M1000N50M
```

This read aligned its first 50 bp to one exon, skipped 1,000 bp of the reference, and aligned its last 50 bp to the next exon.

## Practical cautions

### 1. Match the genome FASTA and GTF versions

STAR and HISAT2 can both use annotations. The genome build, chromosome names, and release version of the genome FASTA and GTF must match.

```text
Good: GRCh38 FASTA + GENCODE v46 GRCh38 GTF
Risky: GRCh37 FASTA + GRCh38 GTF
Risky: FASTA uses chr1, GTF uses 1
```

### 2. Record alignment parameters with the results

RNA-seq alignment is highly sensitive to parameters. At minimum, record the following in a paper or notebook:

```text
aligner: STAR 2.7.x
genome: GRCh38
annotation: GENCODE v46
key options: --sjdbOverhang 100, --outSAMtype BAM SortedByCoordinate
```

### 3. Be careful with multi-mapping reads

In gene families, pseudogenes, and repetitive regions, a read may align to several places. Aligners differ in how they report multi-mapping reads, and counting tools differ in how they handle them.

### 4. A "fast aligner" is not always the better answer

The right choice depends on the purpose. If you need only expression quantification, Salmon or kallisto may be more practical. If you want to inspect fusions or novel junctions, you need spliced genome alignment. If you want to examine variant candidates, base-level alignment and post-processing matter.

## Cheat sheet

```text
The default choice for short-read RNA-seq is STAR or HISAT2.
STAR is fast and feature-rich but uses substantial memory.
HISAT2 offers low memory use and a graph FM index.
TopHat is historically important but generally a legacy choice for new analyses.
Think of Bowtie and BWA as DNA or unspliced short-read aligners.
minimap2 is important for long-read RNA/cDNA and genome alignment.
Salmon and kallisto estimate transcript abundance rather than serving as traditional aligners.
```

## References and sources

- Dobin A. et al. **STAR: ultrafast universal RNA-seq aligner.** *Bioinformatics* 29(1), 15-21 (2013). DOI: [10.1093/bioinformatics/bts635](https://doi.org/10.1093/bioinformatics/bts635)
- Kim D. et al. **HISAT: a fast spliced aligner with low memory requirements.** *Nature Methods* 12, 357-360 (2015). DOI: [10.1038/nmeth.3317](https://doi.org/10.1038/nmeth.3317)
- Kim D. et al. **Graph-based genome alignment and genotyping with HISAT2 and HISAT-genotype.** *Nature Biotechnology* 37, 907-915 (2019). DOI: [10.1038/s41587-019-0201-4](https://doi.org/10.1038/s41587-019-0201-4)
- Trapnell C., Pachter L., Salzberg S. L. **TopHat: discovering splice junctions with RNA-Seq.** *Bioinformatics* 25(9), 1105-1111 (2009). DOI: [10.1093/bioinformatics/btp120](https://doi.org/10.1093/bioinformatics/btp120)
- Kim D. et al. **TopHat2: accurate alignment of transcriptomes in the presence of insertions, deletions and gene fusions.** *Genome Biology* 14, R36 (2013). DOI: [10.1186/gb-2013-14-4-r36](https://doi.org/10.1186/gb-2013-14-4-r36)
- Langmead B. et al. **Ultrafast and memory-efficient alignment of short DNA sequences to the human genome.** *Genome Biology* 10, R25 (2009). DOI: [10.1186/gb-2009-10-3-r25](https://doi.org/10.1186/gb-2009-10-3-r25)
- Langmead B., Salzberg S. L. **Fast gapped-read alignment with Bowtie 2.** *Nature Methods* 9, 357-359 (2012). DOI: [10.1038/nmeth.1923](https://doi.org/10.1038/nmeth.1923)
- Li H., Durbin R. **Fast and accurate short read alignment with Burrows-Wheeler transform.** *Bioinformatics* 25(14), 1754-1760 (2009). DOI: [10.1093/bioinformatics/btp324](https://doi.org/10.1093/bioinformatics/btp324)
- Liao Y., Smyth G. K., Shi W. **The Subread aligner: fast, accurate and scalable read mapping by seed-and-vote.** *Nucleic Acids Research* 41(10), e108 (2013). DOI: [10.1093/nar/gkt214](https://doi.org/10.1093/nar/gkt214)
- Li H. **Minimap2: pairwise alignment for nucleotide sequences.** *Bioinformatics* 34(18), 3094-3100 (2018). DOI: [10.1093/bioinformatics/bty191](https://doi.org/10.1093/bioinformatics/bty191)
- HISAT2 official documentation: [https://daehwankimlab.github.io/hisat2/](https://daehwankimlab.github.io/hisat2/)
- STAR source and manual: [https://github.com/alexdobin/STAR](https://github.com/alexdobin/STAR)
- minimap2 source and manual: [https://github.com/lh3/minimap2](https://github.com/lh3/minimap2)