binCount {RIPSeeker} | R Documentation

## Count reads in nonoverlapping bins across a chromosome

### Description

Stratify chromosome into nonoverlapping bins of the same size and count the number of reads that fall within each bin.

### Usage

    binCount(alignGR, binSize, returnBinCountOnly = FALSE)

### Arguments

`alignGR` | GRanges object containing the alignments for a single chromosome.
`binSize` | An integer for the bin size.
`returnBinCountOnly` | Binary indicator. If TRUE, only the integer read count is returned; if FALSE, GRanges of bins with value slot saved as the corresponding read counts is returned.

### Details

The funciton is designed to operate to a single chromosome to facilitate parallel computing on multiple chromosomes independently. The function is used in `evalBinSize` to select the optimal bin size based on the read counts and in `mainSeekSingleChrom` to provide the read count as input for the HMM.

### Value

If `returnBinCountOnly` is TRUE, then the integer read count is returned; if `returnBinCountOnly` is FALSE, then the GRanges of bins with value slot saved for the corresponding read counts is returned.

### Author(s)

Yue Li

### References

P. Aboyoun, H. Pages and M. Lawrence. GenomicRanges: Representation and manipulation of genomic intervals. R package version 1.8.9.

### See Also

`selectBinSize, evalBinSize`

### Examples

    # Retrieve system files
    extdata.dir <- system.file("extdata", package="RIPSeeker")

    bamFiles <- list.files(extdata.dir, ".bam$", recursive=TRUE, full.names=TRUE)

    bamFiles <- grep("PRC2", bamFiles, value=TRUE)

    alignGal <- getAlignGal(bamFiles[1], reverseComplement=TRUE, genomeBuild="mm9")

    alignGR <- as(alignGal, "GRanges")

    alignGRList <- GRangesList(as.list(split(alignGR, seqnames(alignGR))))

    binSize <- 1000

    binGR <- binCount(alignGRList$chrX, binSize)

[Package RIPSeeker version 1.24.0 Index]