Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

SAMtools

SAMtools is a quite of commands for dealing with databases of mapped reads. You'll be using it quite a bit throughout the course.

Right now, we'll be using it to call variants (find mutations) in the re-sequenced E. coli genome from the Introduction to mapping (bowtie, BWA). You will need the output SAM files from that tutorial to continue here.

Create a new output directory:

Samtools

Setup output directory.

Code Block
mkdir samtools_bowtie

If you do not have an Lets copy over the read alignment file in the SAM format you may want to start with Introduction to mapping (bowtie, BWA)format and the reference genome in FASTA format to the new directory, so that we don't have so many files cluttering our space up.

Code Block
cp bowtie/REL606SRR030257.5.sam samtools_bowtie/ 
cp bowtie/REL606NC_012967.51.fasta samtools_bowtie/

Index the reference file. (This isn't indexing it for mapping. It's indexing it so that SAMtools can quickly jump to a certain base.)

Code Block
samtools faidx samtools_bowtie/REL606NC_012967.51.fasta

Take a look at the new file that was created by this command.

SAM is a text file, so it is slow to access information about a read. SAMtools and many of the commands that we will run later work on BAM files (essentially 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.

Code Block
samtools view -bS -o samtools_bowtie/REL606SRR030257.5.bam bowtie/REL606.5SRR030257.sam |borderStyle=solid}

Sort the BAM file.

Code Block
samtools sort samtools_bowtie/REL606SRR030257.5.bam samtools_bowtie/SRR030257.sorted_REL606.5

Output VCF file.

Code Block
samtools mpileup -uf samtools_bowtie/REL606NC_012967.51.fasta samtools_bowtie/SRR030257.sorted_REL606.5.bam \|bcftools view -vcg - \> samtools_bowtie/output.vcf 

...