Lesson 5 of 13 · 11 min
Alignment vs Pseudo-alignment
Once your reads pass QC, the next decision is how to map them to a reference. Two families dominate RNA-Seq: spliced alignment to a genome, and pseudo-alignment to a transcriptome. They answer different questions, so the right choice depends on what you plan to do downstream.
Spliced genome alignment
HISAT2 and STAR are spliced aligners: they place each read at genomic coordinates and split reads that span an intron across the two exons they belong to. This resolves splice junctions and gives you base-level positions you can pile up, view in IGV, or hand to a variant caller. Both work from the genome FASTA, and supplying a GTF annotation lets known junctions guide the alignment for better accuracy.
# Build a splice-aware index from genome FASTA + GTF
STAR --runMode genomeGenerate \
--genomeDir star_index \
--genomeFastaFiles GRCh38.primary_assembly.genome.fa \
--sjdbGTFfile gencode.v44.annotation.gtf \
--sjdbOverhang 99 \
--runThreadN 8
# Align paired-end reads, emit a coordinate-sorted BAM
STAR --genomeDir star_index \
--readFilesIn sample_R1.fastq.gz sample_R2.fastq.gz \
--readFilesCommand zcat \
--outSAMtype BAM SortedByCoordinate \
--runThreadN 8 \
--outFileNamePrefix sample_# sample_Log.final.out (excerpt)
Number of input reads | 28451003
Average input read length | 200
UNIQUE READS:
Uniquely mapped reads number | 25783461
Uniquely mapped reads % | 90.62%
% of reads mapped to multiple loci | 6.11%
% of reads unmapped: too short | 2.84%
Transcriptome pseudo-alignment
Salmon and kallisto skip base-level alignment entirely. They match the k-mers in each read against a precomputed index of transcript sequences, assign the read to the set of transcripts it is compatible with, then resolve multimappers with an expectation-maximization model. kallisto calls this pseudoalignment, and Salmon adds a lightweight selective-alignment scoring step. Neither needs a GTF or a spliced alignment to the genome: the core input is a transcriptome FASTA. Salmon's recommended decoy-aware index does fold in the genome too, but only as decoy sequence that soaks up reads of genomic origin so they are not forced onto a transcript.
# Build a decoy-aware index: transcripts + genome as decoy
grep "^>" GRCh38.primary_assembly.genome.fa | cut -d " " -f 1 | sed 's/>//g' > decoys.txt
cat gencode.v44.transcripts.fa GRCh38.primary_assembly.genome.fa > gentrome.fa
salmon index -t gentrome.fa -d decoys.txt -i salmon_index -k 31 -p 8
# Quantify against the transcriptome (-l A auto-detects library type)
salmon quant -i salmon_index -l A \
-1 sample_R1.fastq.gz -2 sample_R2.fastq.gz \
--gcBias -p 8 -o sample_quant[2024-01-18 11:42:07.331] [jointLog] [info] Automatically detected most likely library type as ISR
[2024-01-18 11:47:52.008] [jointLog] [info] Mapping rate = 93.4127%
$ head -2 sample_quant/quant.sf
Name Length EffectiveLength TPM NumReads
ENST00000456328.2 1657 1483.421 2.87451 38.142
Accuracy, speed, disk
Spliced alignment is slower and heavier: a human STAR index needs roughly 30 GB of RAM to build and each sorted BAM runs to several gigabytes, but you gain genomic coordinates for variant calling, novel-isoform and junction discovery, and coverage QC. Pseudo-alignment finishes in minutes on a laptop, writes a tiny quant.sf, and gives accurate transcript-level counts, but it cannot detect anything missing from the transcriptome and is only as complete as your annotation. Reach for STAR or HISAT2 when you need base-level positions or work with a poorly annotated organism, and reach for Salmon or kallisto when the goal is transcript- or gene-level quantification for differential expression that you will import with tximport into DESeq2 or edgeR.
Try it yourself: quantify one sample with the decoy-aware Salmon index above, then build a second index from the transcriptome alone (salmon index -t gencode.v44.transcripts.fa -i salmon_index_nodecoy -k 31) and quantify against it. Compare the reported Mapping rate and the NumReads for a handful of transcripts. Because the decoys soak up reads from intronic and intergenic regions, dropping them lets those reads land on real transcripts instead, so watch the mapping rate climb and the spurious counts creep up.