Skip to main content

STEP 3/4 - RNA-seq Alignments


STEP 3: Alignment


This page covers the alignment step for RNA-seq data - mapping sequencing reads to a reference genome or transcriptome.

RNA-seq Alignment Tools

RNA-seq aligners must handle spliced alignments (reads spanning exon-exon junctions):

  • STAR - Fast, splice-aware aligner (recommended)
  • HISAT2 - Memory-efficient splice-aware aligner
  • Salmon - Quasi-mapping, fast quantification (alternative approach)

STAR Alignment

STAR (for RNA-seq data)

STAR (Spliced Transcripts Alignment to a Reference) is a fast aligner specifically designed for RNA-seq data. It can handle spliced alignments and is suitable for longer reads.

Loading STAR

On the CCB:

module load star

Genome Indexing

The CCB provides pre-built STAR indices for common reference genomes. You can find the available indices in the directory /databank/igenomes/.

The reference genome index for human (hg38): /databank/igenomes/Homo_sapiens/UCSC/hg38/Sequence/STAR/Genome

The reference genome index for human (mm39): /databank/igenomes/Mus_musculus/UCSC/mm39/Sequence/STAR/Genome

# Example indexing command (usually pre-done)
STAR --runMode genomeGenerate \
  --genomeDir /path/to/star_index \
  --genomeFastaFiles mm39.fa \
  --sjdbGTFfile genes.gtf \
  --sjdbOverhang 99

Running STAR

For paired-end RNA-seq:

STAR --runThreadN 8 \
  --genomeDir /path/to/star_index \
  --readFilesIn sample_R1.fastq.gz sample_R2.fastq.gz \
  --readFilesCommand zcat \
  --outFileNamePrefix sample_ \
  --outSAMtype BAM SortedByCoordinate \
  --quantMode GeneCounts

STAR Parameters

  • --runThreadN - Number of threads
  • --genomeDir - Path to genome index
  • --readFilesIn - Input FASTQ file(s)
  • --readFilesCommand zcat - For gzipped files
  • --outFileNamePrefix - Output prefix
  • --outSAMtype BAM SortedByCoordinate - Output sorted BAM
  • --quantMode GeneCounts - Generate gene count table

HISAT2 Alignment

Alternative to STAR, uses less memory:

module load hisat2

hisat2 -p 8 \
  -x /path/to/hisat2_index \
  -1 sample_R1.fastq.gz \
  -2 sample_R2.fastq.gz \
  -S sample.sam

Output Files

STAR produces:

  • Aligned.sortedByCoord.out.bam - Sorted BAM file
  • ReadsPerGene.out.tab - Gene count table
  • Log.final.out - Alignment statistics

STEP 4 - Post-alignment Processing


After alignment, the SAM file needs to be converted to BAM format and processed.

Samtools

Samtools is a suite of programs for interacting with high-throughput sequencing data in SAM and BAM formats.

Loading Samtools

On the CCB:

module load samtools

Keep only Mapped Reads

Convert SAM to BAM, keep only mapped reads:

samtools view -@8 -bS -F4 -o mapped.bam alignment.sam ; # Convert SAM to BAM, keep only mapped reads

Sort BAM File

Sort the BAM file by genomic coordinates:

samtools sort mapped.bam -@8 -o mapped.srtC 

Remove Duplicates

Remove PCR duplicates from the sorted BAM file:

samtools rmdup mapped.srtC filtered.bam ; # Remove PCR duplicates

Index BAM File

Index the final BAM file for efficient access:

samtools index filtered.bam ; # Index the final BAM File