Versions Compared

Key

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

...

Since BAM files are binary, they can't be viewed directly using standard Unix file viewers such as more, less and head. We have seen how samtools view can be used to binary-format BAM files into text format for viewing. But samtools view also has options that let you do powerul filtering of the output. We focus on this filtering capability in this set of exercises.

Handy links


Setup


Set up a directory for these exercises and copy an indexed BAM file there. This is a renamed version of the yeast_pairedend.sort.bam file from our Alignment workflow exercises.

...

Code Block
languagebash
titleSetup for samtools exercises
mkdir -p $SCRATCH/core_ngs/samtools
cd $SCRATCH/core_ngs/samtools
cp $CORENGS/catchup/for_samtools/* .


References

Handy links

SAM header fields

The 11 SAM alignment record required fields (Tab-delimited).

Image Added

SAM flags field

Meaning of each bit (flag) in the SAM alignment records flags field (column 2). The most commonly querried flags are denoted in red.

Image Added

SAM CIGAR string

Format of the CIGAR string in column 6 of SAM alignment records.

Image Added

Exercises

Analyzing the CIGAR string


Filtering for only mapped reads (samtools view -F 0x4)

...