omics.co.in logo omics.co.in

10: Bulk RNA-Seq Alignment & Quantification

Tested Stacks: GATK 4.6.1 Samtools 1.21 Nextflow 24.10 Seurat v5.1 Python 3.12
Prerequisites: Basic Linux CLI & Sequencing Formats
📚 Chapter 10 of 13 0% Course Completed

Chapter 10: Bulk RNA-Seq Alignment & Quantification

Transcriptome profiling via RNA Sequencing (RNA-seq) quantifies the dynamic expression of tens of thousands of genes across conditions, tissues, and treatments. Unlike DNA sequencing, mature eukaryotic mRNA molecules are spliced: non-contiguous exons are joined together after intron excision. Consequently, RNA-seq reads cannot be mapped with standard DNA aligners like BWA-MEM; they require specialized splice-aware aligners or alignment-free pseudoaligners.

The Trap of FPKM: Why TPM is Superior

FPKM (Fragments Per Kilobase Million) normalizes for gene length and library size. However, the sum of FPKMs varies between samples, making cross-sample comparisons invalid. In contrast, TPM (Transcripts Per Million) normalizes for gene length first, then scales by total transcript counts. The sum of TPMs in every single library is guaranteed to equal exactly 1,000,000, making TPM the only mathematically valid unit for relative abundance comparisons across samples.

1. Spliced Alignment with STAR (2-Pass Mode)

# Run STAR in 2-Pass mode for superior novel splice junction discovery
STAR \
    --runThreadN 16 \
    --genomeDir /databases/star_grch38_index \
    --readFilesIn rna_sample_R1.fastq.gz rna_sample_R2.fastq.gz \
    --readFilesCommand zcat \
    --outFileNamePrefix rna_sample_ \
    --outSAMtype BAM SortedByCoordinate \
    --twopassMode Basic \
    --quantMode GeneCounts

2. Ultra-Fast Pseudoalignment with Salmon

Salmon achieves blistering speed (<5 minutes per sample) by bypassing base-to-base alignment. It streams reads against a transcriptome index, corrects for sequence-specific GC biases, and performs expectation-maximization (EM) optimization:

# Quantify transcripts directly using Salmon with GC and sequence bias correction
salmon quant \
    -i /databases/salmon_grch38_index \
    -l A \
    -1 rna_sample_R1.fastq.gz \
    -2 rna_sample_R2.fastq.gz \
    --validateMappings \
    --gcBias \
    --seqBias \
    -p 16 \
    -o salmon_quant_output/
⚠️

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 ↗