Learn R Programming

metagene (version 1.0.0)

parseBamFile: Parse a single bam file

Description

This function will fetch all the aligned reads from a bam file that overlap with a list of regions.

Usage

parseBamFile( bamFile, features, cores=1)

Arguments

bamFile
The name of the bam file to parse. Must be sorted and indexed.
features
A GRanges corresponding to the regions to parse.
cores
Number of cores for parallel processing (require parallel package).

Value

parseBamFile returns a list with an element for every feature to parse. Each element contains a vector of reads coverage.

Examples

Run this code
  # Get bamFile
  ## Not run: bamFileName <- system.file("extdata/align1_rep1.bam", package="metagene") 

  # Get features
  ## Not run: bedFileName <- system.file("extdata/list1.bed", package="metagene")
  ## Not run: features <- read.table(bedFileName, header=FALSE, stringsAsFactors=FALSE, nrow=10)
  ## Not run: colnames(features) <- c("space", "start_position", "end_position")
  ## Not run: features$end_position <- features$start_position + 200
  ## Not run: features$start_position <- features$start_position - 200

  # Parse the bam file
  ## Not run: bamDensity <- metagene:::parseBamFile(bamFileName, features)

Run the code above in your browser using DataLab