Introduction to Sequence Alignment

Understand what happens when short RNA-seq reads meet a reference genome — and why alignment is the central step in every transcriptomics pipeline.

✓ Free Lesson 📅 Module 7 · Lesson 1 of 10
Lesson 1 · ⏱ 40 min read · 🧬 Conceptual 🔰 Beginner-friendly

01 What is sequence alignment?

When you sequence RNA from a biological sample, you get millions of short DNA fragments called reads. Each read is typically 50–150 base pairs long. By itself, a single read tells you almost nothing — it is just a short string of A, T, G, C characters with no context.

Sequence alignment is the process of figuring out where in the genome each read came from. You take every read and find its best matching position on a known reference genome. Once you know where each read maps, you can answer the biological question: which genes are active and at what level?

💡 Why this step exists

Think of a shredded book. If you shred 3 billion pages into 150-character strips, you need to reassemble them to read the story. Alignment is the reassembly step — every short read gets placed back onto the reference genome so that the full transcriptional picture emerges. Without alignment, raw reads are uninterpretable noise.

The output of alignment is a file that records, for every read: the chromosome it mapped to, its exact start position, and how confident the aligner is about that placement. This file (in SAM or BAM format) becomes the input for all downstream analyses — differential expression, variant calling, and more.

🌱

Plant genomics note: For crops like rice, maize, and sorghum, genome sizes range from 400 Mb (rice) to over 2 Gb (maize). Alignment to a plant genome uses the exact same tools and concepts as human genomics — only the reference FASTA file changes.

02 Why alignment matters

Every RNA-seq analysis — whether you are studying drought stress in sorghum, cancer cell lines, or immune response — passes through alignment. It is the bridge between raw sequencing data and biological insight.

Getting alignment right matters for several practical reasons:

Problem if alignment goes wrong Consequence
Too many reads fail to map You lose statistical power; genes appear lowly expressed when they are not
Reads map to wrong locations False-positive differentially expressed genes appear
Multi-mapping reads handled incorrectly Counts for gene families with repeated sequences are inflated or deflated
Wrong aligner for the data type Splice junctions in mRNA-seq are missed; gene models become inaccurate
Wrong reference genome version Coordinate mismatch; downstream tools produce errors or silent nonsense
⚠️

Common mistake: Many beginners skip checking alignment rates. Always look at the percentage of reads that successfully mapped. A good RNA-seq alignment should map 85–95% of reads. If you see 30–50%, something is wrong — usually a wrong reference genome, adapter contamination, or a species mismatch.

03 Where alignment sits in the pipeline

Alignment is step 3 in a standard RNA-seq pipeline. Understanding its position helps you know what inputs it expects and what outputs it produces.

Raw FASTQ
Illumina output
QC & Trim
FastQC · Trimmomatic
Alignment
STAR · HISAT2 ← you are here
SAM/BAM
samtools sort/index
Count Matrix
featureCounts · HTSeq
DESeq2
Differential expression
💡 Inputs and outputs

Alignment takes as input: (1) trimmed FASTQ files — your sequencing reads, and (2) an indexed reference genome — the complete genome sequence of your organism plus gene annotation.

Alignment produces as output: a SAM or BAM file — a table with one row per read, recording its mapped position, mapping quality, and additional flags. This file is what every downstream tool (featureCounts, DESeq2, GATK) reads.

04 Types of RNA-seq reads

Not all sequencing reads are the same. The type of reads you have determines which aligner settings you need and what biological questions you can answer.

Read type Description Alignment implication
Single-end (SE) One read per fragment, sequenced from one end only. Files: one FASTQ per sample. Simpler to align; less accurate for quantification of overlapping genes
Paired-end (PE) Two reads per fragment — one from each end. Files: R1.fastq.gz and R2.fastq.gz per sample. More accurate placement; aligner uses both reads together to confirm the insert size
Stranded Library prep preserves which DNA strand the RNA came from. Must set strand parameter correctly (--rna-strandness in HISAT2, --outSAMstrandField in STAR)
Unstranded Both strands are represented equally; strand of origin is unknown. Default setting for most older datasets; simpler but loses strand information
Long reads (PacBio/ONT) Reads of 5,000–50,000 bp; sequenced with PacBio or Oxford Nanopore. Different aligners needed: minimap2 instead of STAR/HISAT2
💡

How to check your read type: Look at your FASTQ filenames. If you have sample1_R1.fastq.gz and sample1_R2.fastq.gz, you have paired-end data. If you only have sample1.fastq.gz, you have single-end data. The library preparation protocol documentation from your sequencing provider will tell you whether it was stranded.

05 Aligner overview

Several aligners exist for RNA-seq. In this module we will learn the two most widely used in plant and human genomics: STAR and HISAT2. Here is how they compare:

Aligner Algorithm Speed Memory Best for
STAR Suffix array; loads entire genome index into RAM Very fast High (30–45 GB for human) Large projects, HPC clusters, novel junction discovery
HISAT2 Graph-based FM-index (GCSA) Fast Low (4–8 GB) Laptops, smaller organisms, known variant-aware alignment
HISAT2 (plant) Same as above Very fast for small genomes 1–4 GB for rice/sorghum Plant genomics on standard workstations
minimap2 Minimiser-based chaining Extremely fast Moderate Long-read data (PacBio, Oxford Nanopore) only
BWA-MEM Burrows-Wheeler transform Fast Moderate DNA alignment (WGS, variant calling) — NOT for RNA-seq
⚠️

Do not use BWA for RNA-seq. BWA is a DNA aligner — it does not understand splicing. If you align RNA-seq reads with BWA, reads that span exon-intron junctions will fail to map, and you will dramatically undercount most genes. Always use a splice-aware aligner (STAR or HISAT2) for mRNA sequencing data.

06 Key concepts & terminology

These terms appear throughout every alignment workflow. Make sure you understand each one before moving to Lesson 2.

Term What it means
Reference genome The complete DNA sequence of an organism, stored in a FASTA file. The aligner uses this as a map to place reads against. Example: Sbicolor_730_v5.0.fa for sorghum.
Genome index A pre-computed data structure built from the reference genome. Building it once allows the aligner to locate any sequence in milliseconds rather than scanning billions of bases each time.
Mapping rate The percentage of reads that successfully aligned to the genome. Reported in the aligner log file after each run.
Mapping quality (MAPQ) A score (0–255) that represents how confident the aligner is about each read's placement. Higher is better. MAPQ 255 = unique, unambiguous mapping in STAR.
Multi-mapper A read that aligns equally well to two or more locations in the genome. Common in gene families and repeated elements. Most pipelines discard or down-weight these reads.
Splice junction The boundary between two exons in mature mRNA. A read that spans a splice junction must be "split" across the gap — only splice-aware aligners like STAR and HISAT2 can handle this.
SAM / BAM The output file format. SAM (Sequence Alignment Map) is human-readable text. BAM is the compressed binary version. BAM files are smaller and faster for downstream tools.
GTF / GFF annotation A file that describes where genes, transcripts, and exons are located on the reference genome. The aligner uses this to understand splice junctions. Example: Sbicolor_730_v5.1.gene.gtf
Soft-clipping When the aligner cannot place the ends of a read, it "clips" them off and still maps the core of the read. Common at read ends where quality is lower or where adapters remain.
Insert size For paired-end reads: the distance between the outer ends of the two reads on the original DNA fragment. Typically 100–500 bp for Illumina short-read sequencing.
💡 The splice junction problem — why RNA-seq alignment is hard

Mature mRNA has had its introns removed. So a 150 bp read from mRNA might have its first 80 bp from exon 5 and its last 70 bp from exon 6 — with a 10,000 bp intron in between on the genome. A standard DNA aligner would fail to place this read because it looks for a perfect continuous match. STAR and HISAT2 solve this by splitting the read and placing each part on its correct exon, with a "N" in the CIGAR string representing the skipped intron. This is why splice-aware alignment matters for every RNA-seq experiment.

Advertisement AdSense in-feed slot reserved

07 Exercises

These exercises are conceptual — no terminal needed yet. They prepare you for the hands-on work starting in Lesson 2.

1
Identify your read type

You receive a sequencing dataset with files named drought_rep1_R1.fastq.gz and drought_rep1_R2.fastq.gz. Answer the following:

(a) Is this single-end or paired-end data?
(b) What does R1 represent and what does R2 represent?
(c) Which aligner would you choose — STAR or BWA-MEM — and why?

Show answer

(a) This is paired-end data. The presence of both R1 and R2 files for the same sample confirms this.

(b) R1 is the forward read — sequenced from the 5′ end of the RNA fragment. R2 is the reverse read — sequenced from the 3′ end of the same fragment. Together they cover both ends of one original RNA molecule.

(c) STAR (or HISAT2) — because this is RNA-seq data. BWA-MEM is a DNA aligner that does not understand splicing. Using BWA would cause reads that span exon-intron junctions to fail to map, leading to severely undercounted genes.

2
Interpret a mapping rate

After running STAR on a sorghum RNA-seq dataset, the log file reports: "Uniquely mapped reads %: 42.35%". The experiment used a sorghum reference genome downloaded from Phytozome three years ago.

(a) Is this mapping rate acceptable?
(b) List three things you would check to diagnose the problem.

Show answer

(a) No. A mapping rate of 42% is far below the expected 85–95% for a well-processed RNA-seq dataset. This strongly suggests a problem upstream of alignment.

(b) Things to check:

1. Reference genome version mismatch. A three-year-old genome download may not match the current assembly version. The annotation (GTF) and genome (FASTA) must be from the same version — mixing versions causes poor alignment.

2. Adapter contamination. If the reads were not trimmed before alignment, adapter sequences at read ends prevent clean mapping. Run FastQC on the raw reads and check the "Adapter Content" panel.

3. Species contamination. If the sequenced sample contained contaminating organisms (fungi, bacteria, human), a significant fraction of reads would fail to map to the sorghum genome. BLAST a few unmapped reads to check their origin.

3
Splice junction reasoning

A 150 bp read from an RNA-seq experiment maps to chromosome 1 with the CIGAR string 75M1000N75M. Explain in plain language what this means. Would a standard DNA aligner (like BWA) have been able to map this read correctly?

Show answer

The CIGAR string 75M1000N75M means: the first 75 bases of the read matched the genome perfectly (75M), then there is a 1,000 bp gap on the genome (1000N — a skipped intron), and then the last 75 bases matched the genome (75M). This read spans a splice junction: it came from an mRNA where exon boundaries are separated by a 1,000 bp intron in the genomic DNA.

No, BWA would not map this correctly. BWA looks for continuous matches. When it tries to align all 150 bp at once, it finds 75 bp matching at one location and then the next 75 bp 1,000 bp away — which looks like an impossibly large gap. BWA would either fail to map the read entirely or would soft-clip one half of it and report a poor alignment. Only splice-aware aligners like STAR and HISAT2 know to look for this pattern and correctly place both halves across the intron.

Advertisement AdSense rectangle slot reserved