Variant calling tutorial
SAMtools is a suite of commands for dealing with databases of mapped reads. You'll be using it quite a bit throughout the course. It includes programs for performing variant calling (mpileup-bcftools).
Calling variants in reads mapped by bowtie
Right now, we'll be using it to call variants (find mutations) in the re-sequenced E. coli genome from the Mapping tutorial. You will need the output SAM files from that tutorial to continue here.
If you do not have the output from the Mapping tutorial, run these commands to copy over the output that would have been produced. Then, you can immediately start this tutorial!
cds mkdir intro_to_mapping cd intro_to_mapping cp -r $BI/ngs_course/intro_to_mapping/bowtie . cp -r $BI/ngs_course/intro_to_mapping/bwa . cp -r $BI/ngs_course/intro_to_mapping/bowtie2 .
We assume that you are still working in the main directory called intro_to_mapping
data that you created on $SCRATCH
.
Load SAMtools
Load the SAMtools module (if not already loaded).
Can you figure out what version of samtools is loaded on TACC and where it is installed?
Prepare your directories
Create a new output directory called samtools_bowtie
or whatever makes sense to you.
Let's copy over just the read alignment file in the SAM format and the reference genome in FASTA format to this new directory, so that we don't have so many files cluttering our space.
Index the FASTA reference file
First, you need to index the reference file. (This isn't indexing it for read mapping. It's indexing it so that SAMtools can quickly jump to a certain base in the reference.)
Then run this command to index the reference file.
samtools faidx samtools_bowtie/NC_012967.1.fasta
Take a look at the new *.fai file that was created by this command. Any idea what some of the numbers mean?
Convert mapped reads from SAM to BAM, sort, and index
SAM is a text file, so it is slow to access information about how any given read was mapped. SAMtools and many of the commands that we will run later work on BAM files (essentially GZIP compressed binary forms of the text SAM files). These can be loaded much more quickly. Typically, they also need to be sorted, so that when the program wants to look at all reads overlapping position 4,129,888, it can easily find them all at once without having to search through the entire BAM file.
Convert from SAM to BAM format.
samtools view -b -S -o samtools_bowtie/SRR030257.bam samtools_bowtie/SRR030257.sam
Sort and index the BAM file.
samtools sort samtools_bowtie/SRR030257.bam samtools_bowtie/SRR030257.sorted samtools index samtools_bowtie/SRR030257.sorted.bam
This is a really common sequence of commands, so you might want to add it to your personal cheat sheet.
- What new files were created by these commands?
Welcome to the University Wiki Service! Please use your IID (yourEID@eid.utexas.edu) when prompted for your email address during login or click here to enter your EID. If you are experiencing any issues loading content on pages, please try these steps to clear your browser cache. If you require further assistance, please email wikihelp@utexas.edu.