Versions Compared

Key

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

...

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. We assume that you are still in the main directory of introduction_to_mapping data that you copied to $SCRATCH.

Load the SAMtools module

Code Block

module load samtools

What version of samtools is loaded on TACC?

Create a new output directory:

...

Code Block
cp bowtie/SRR030257.sam samtools_bowtie/ 
cp bowtie/NC_012967.1.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/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?

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

...

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

Sort and index the BAM file.

Code Block
samtools sort samtools_bowtie/SRR030257.bam samtools_bowtie/SRR030257.sorted
samtools index samtools_bowtie/SRR030257.sorted.bam

What new files were created by these commands? Why didn't we name the output SRR030257.sorted.bam? Can you guess what a *.bai file is?

Hint: You might be tempted to gzip BAM files when copying them from one computer to another. Don't bother! They are already internally compressed, so you won't be able to shrink the file. On the other hand, compressing SAM files will save a fair bit of space.

Output VCF fileBCF file. This is a binary form of the text Variant Call Format (VCF).

Code Block
samtools mpileup -uf samtools_bowtie/NC_012967.1.fasta  samtools_bowtie/SRR030257.sorted.bam |> $TACC_SAMTOOLS_DIRsamtools_bowtie/SRR030257.bcf

Convert BCF to VCF:

Code Block

/opt/apps/samtools/0.1.18/bcftools/bcftools view -vcg -samtools_bowtie/SRR030257.bcf > samtools_bowtie/outputSRR030257.vcf 

Take a look at this file. It has a nice header explaining what the columns mean.Output - Samtools

Exercise 1

VCF format has Allele Frequency tags denoted by AF1. Try the following command to see what values we have in our files.

Code Block
cat input.vcf | grep AF1grep AF1 samtools_bowtie/SRR030257.vcf

For the data we are dealing with, predictions with an allele frequency not equal to 1 are not really applicable here. (The reference genome is haploid. There aren't any heterozygotes.) How can we remove these lines from the file and continue on?

Expand
Hint...
Hint...

What does the -v flag do in grep?

Code Block
grep -v *something*

Solutions

...

Calling variants in reads mapped by BWA

...

Code Block
mkdir samtools_bwa

You could also try running all of the commands from inside of the samtools_bwa directory, just for a change of pace.

Comparing the results of different mappers

...

Code Block
module load bedtools

Finding alike common mutations.

Code Block
intersectBed -a bowtie.vcf -b bwa.vcf > intersectcommon_bowtie_bwa.vcf

Finding mutations that are unique mutations for each mapper.

Code Block
subtractBed -a bowtie.vcf -b intersect.vcf > unique_bowtie.vcf
subtractBed -a bwa.vcf -b intersect.vcf > unique_bwa.vcf

...

  • Which mapper finds more variants?
  • Can you figure out how to filter the VCF files on various criteria, like coverage, quality, ... ?
  • How many high quality mutations are there in these E. coli samples relative to the reference genome?

Next up

We will examine the reads supporting these variants by Using the Integrative Genomics Viewer (IGV)

Old stuff

Output - Samtools

Output - Determining Differences Between Mappers

Solutions

Output - Filtering Allele Frequencies