bin.bam: Get read counts from BAM file

Description Usage Arguments Details Value Author(s)

View source: R/bin.bam.R

Description

Count the number of reads from a BAM file in specified bins. By default the output bin counts are writtent into a file, which is then automatically compressed and indexed.

Usage

1
2
3
bin.bam(bam.file, bin.df, outfile.prefix = NULL, appendIndex.outfile = TRUE,
  proper = TRUE, map.quality = 30, chunk.size = 10000,
  check.chr.name = TRUE, no.checks = FALSE, bai.file = NULL)

Arguments

bam.file

the BAM file or a list of BAM files (e.g. reverse and forward)

bin.df

a data.frame with the information about the bins. Columns 'chr', 'start' and 'end' are required.

outfile.prefix

the prefix of the name of the output file. The suffix '.bgz' will be appended to this name prefix after compression. In practice this is present in the output of 'init.filenames' function.

appendIndex.outfile

if TRUE (default), the results will be appended regularly on the output file which will be ultimately compressed and indexed. This is recommend when a large number of bins are analyzed. If FALSE, a data.frame with the bin counts will be returned and no file is created.

proper

if TRUE (default), reads with properly mapped pairs are counted. If FALSE, reads with improper mapping are counted.

map.quality

the minimum mapping quality (Phred score) for the reads to count. Default is 30.

chunk.size

the number of bins to analyze at a time (for memory optimization). Default is 10 000. Reduce this number if memory problems arise.

check.chr.name

if TRUE (default), the function will try to check that the definition of chromosome (e.g. '1' vs 'chr1') are consistent between the bin definition and the BAM file. If FALSE, the analysis will continue either way.

no.checks

if TRUE, won't stop if there are no reads or the chromosome names are inconsistent. Default is FALSE.

bai.file

the index file of the BAM. If NULL it will be guessed.

Details

By default, the function tries to check that the bin definition and the BAM file have compatible chromosome names. For example, 'chr1' in both or '1' in both. Moreover it will stop if no reads are found in the BAM file. To switch off these checks use 'no.checks=TRUE'.

Value

a list:

bc

the final output file name if 'appendIndex.outfile' was TRUE; a data.frame with the bin counts if not.

nb.reads

the number of reads counted.

Author(s)

Jean Monlong


jmonlong/PopSV documentation built on April 25, 2018, 7 a.m.