Now that we have a bam file with only the reads we want included, we can do some more sophisticated analysis using bedtools. Bedtools changes from version to version, and here we are using version 2.22, the newest version, and what is currently installed on stampede.
Converting a bam file to a fastq file
Sometimes, especially when working with external data, we need to go from a bam file back to a fastq file. This can be useful for re-aligning reads using a different aligner, different settings on the original aligner used. It can also be useful for extracting the sequence of interesting regions of the genome after you have manipulated your bam file.
Exercise 1: convert bam to fastq and look at the quality scores
Exercise 2: Convert bam to bed using bamtobed
Exercise 3: Find the coverage of your bed file over the genome
Exercise 4: Use bedtools merge to merge an experiment
Exercise 5: Intersect two experiments using intersect