Copy of good Alignment workflow
- 1 Overview
- 2 Reference Genomes
- 3 Exercise #1: BWA global alignment – Yeast ChIP-seq
- 4 Exercise #2: Basic SAMtools Utilities
- 4.1.1 SAMtools suite usage
- 4.2 samtools view
- 4.2.1 samtools view usage
- 4.2.2 Get the alignment exercises files
- 4.2.3 Convert SAM to binary BAM
- 4.2.4 View BAM records
- 4.3 samtools sort
- 4.3.1 samtools sort usage
- 4.3.2 Sort a BAM file
- 4.4 samtools index
- 4.4.1 samtools index usage
- 4.4.2 Index a sorted bam
- 4.5 samtools flagstat
- 4.6 samtools idxstats
- 5 Exercise #3: BWA PE alignment with BioITeam script
Overview
After raw sequence files are generated (in FASTQ format), quality-checked, and pre-processed in some way, the next step in many NGS pipelines is mapping to a reference genome.
For individual sequences it is common to use a tool like BLAST to identify genes or species of origin. However a normal NGS dataset will have tens to hundreds of millions of sequences, which BLAST and similar tools are not designed to handle. Thus a large set of computational tools have been developed to quickly align each read to its best location (if any) in a reference.
Even though many mapping tools exist, a few individual programs have a dominant "market share" of the NGS world. In this section, we will primarily focus on two of the most versatile general-purpose ones: BWA and Bowtie2 (the latter being part of the Tuxedo suite which includes the transcriptome-aware RNA-seq aligner Tophat2 as well as other downstream quantifiaction tools).
Stage the alignment data
First connect to login5.ls5.tacc.utexas.edu. This should be second nature by now
Then stage the sample datasets and references we will use.
Get the alignment exercises files
mkdir -p $SCRATCH/core_ngs/alignment/fastq
mkdir -p $SCRATCH/core_ngs/references/fasta
cp $CORENGS/alignment/*fastq.gz $SCRATCH/core_ngs/alignment/fastq/
cp $CORENGS/references/*.fa $SCRATCH/core_ngs/references/fasta/These are descriptions of the FASTQ files we copied:
File Name | Description | Sample |
|---|---|---|
Sample_Yeast_L005_R1.cat.fastq.gz | Paired-end Illumina, First of pair, FASTQ | Yeast ChIP-seq |
Sample_Yeast_L005_R2.cat.fastq.gz | Paired-end Illumina, Second of pair, FASTQ | Yeast ChIP-seq |
human_rnaseq.fastq.gz | Paired-end Illumina, First of pair only, FASTQ | Human RNA-seq |
human_mirnaseq.fastq.gz | Single-end Illumina, FASTQ | Human microRNA-seq |
cholera_rnaseq.fastq.gz | Single-end Illumina, FASTQ | V. cholerae RNA-seq |
Reference Genomes
Before we get to alignment, we need a reference to align to. This is usually an organism's genome, but can also be any set of names sequences, such as a transcriptome or other set of genes.
Here are the four reference genomes we will be using today, with some information about them. These are not necessarily the most recent versions of these references (e.g. the newest human reference genome is hg38 and the most recent miRBase annotation is v21. (See here for information about many more genomes.)
Reference | Species | Base Length | Contig Number | Source | Download |
|---|---|---|---|---|---|
hg19 | Human | 3.1 Gbp | 25 (really 93) | UCSC | |
sacCer3 | Yeast | 12.2 Mbp | 17 | UCSC | |
mirbase v20 | Human subset | 160 Kbp | 1908 | miRBase | |
vibCho (O395) | Vibrio cholerae | ~4 Mbp | 2 | GenBank |
Searching genomes is computationally hard work and takes a long time if done on linear genomic sequence. So aligners require that references first be indexed to accelerate lookup. The aligners we are using each require a different index, but use the same method (the Burrows-Wheeler Transform) to get the job done.
Building a reference index involves taking a FASTA file as input, with each contig (contiguous string of bases, e.g. a chromosome) as a separate FASTA entry, and producing an aligner-specific set of files as output. Those output index files are then used to perform the sequence alignment, and alignments are reported using coordinates referencing names and offset positions based on the original FASTA file contig entries.
We can quickly index the references for the yeast genome, the human miRNAs, and the V. cholerae genome, because they are all small, so we'll build each index from the appropriate FASTA files right before we use them.
Reference FASTA locations
/work/projects/BioITeam/projects/courses/Core_NGS_Tools/references/sacCer3.fa
/work/projects/BioITeam/projects/courses/Core_NGS_Tools/references/hairpin_cDNA_hsa.fahg19 is way too big for us to index here so we will use an existing set of BWA hg19 index files located at:
BWA hg19 index location
/work/projects/BioITeam/ref_genome/bwa/bwtsw/hg19The BioITeam maintains a set of reference indexes for many common organisms and aligners. They can be found in aligner-specific sub-directories of the /work/projects/BioITeam/ref_genome area. E.g.:
/work/projects/BioITeam/ref_genome/
bowtie2/
bwa/
hisat2/
kallisto/
star/
tophat/