Exercise

Reading BAM files

To get started, you'll read mapped reads from a BAM file into R. These files store information about the alignment between read sequences and the reference genome in a compressed binary format. Loading data from BAM files is a common task when analyzing genomic data.

In this exercise, you'll first load all reads from a bam file. This is straightforward but can require a lot of memory, so in the second part, you'll learn how to load only the reads from a region of interest.

Instructions

100 XP
  • Load reads from chr20_bam file using the readGAlignments() function.
  • Create a BamViews object for chr20_bam that covers the region 29805000 - 29820000 on chromosome 20.
  • Use readGAlignments() again to load only the reads in that view.
  • Inspect the reads_sub object using str().