Coverage, Counting, and Plots
The other day I showed how to filter a bam file to remove low quality reads . As a side effect of this, we also removed all reads that did not map to the particular chromosome that the bam file referenced. This greatly reduced the size of the bam file. In addition, it makes the next task much easier. We want to know about the read coverage in each of the chromosomes to visualize how the coverage might differ among runs and sources of RNA and DNA. Coverage is the number of reads overlapping a particular genomic position. Counting coverage is pretty easy with the PySam module. Here's one way to do it: def ReadBamFile(chrom, bam_file, genome_file): """ ReadBamFile - read a bam file and count nucleotides by context chrom - the chromosome name as aa string, e.g. chr2L bam_file - bam file containing reads genome_file - file containing the genome in fasta format returns: a nump...