Versions Compared

Key

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

...

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.

For this exercise, you'll be using bamtofastq.  This function takes an aligned bam file as input and outputs a fastq format file.  You can use the options if you have paired end data to output R1 and R2 reads for your fastq file.  This type of function is especially useful if you need to to  analyze sequences after you've compared several bam or bed files.

Code Block
languagebash
bedtools bamtofastq [OPTIONS] -i input.bam -fq output.fastq

Exercise 1: convert bam to fastq and look at the quality scores

Expand
titleSolution
Code Block
languagebash
titlesolution code
solution goes here

 

module load bedtools
bedtools bamtofastq [OPTIONS] -i input.bam -fq output.fastq
more output.fastq

 

While it's useful to be able to look at the fastq file, many analyses will be easiest to perform in bed format.  Bed format is a simple tab delimited format that designates various properties about segments of the genome, defined by the chromosome, start coordinates and end coordinates.  Bedtools provides a simple utility to convert bam files over into bed files, termed bamtobed.

Code Block
languagebash
bedtools bamtobed [OPTIONS] -i input.bam > output.bed

Note that the output will be piped to standard out unless you redirect to a program (head, more, less) or a file (output.bed).

Exercise 2: Convert the filtered yeast paired end Exercise 2: Convert bam to bed using bamtobed.

Expand
titleSolution
Code Block
languagebash
titlesolution code
solution goes heremodule load bedtools
bedtools bamtobed [OPTIONS] -i input.bam > output.bed

 

Exercise 3: Find the coverage of your bed file over the SacCer3 genome

...