Learn R Programming

csaw (version 1.4.0)

getWidths: Get region widths

Description

Get the widths of the read counting interval for each region.

Usage

getWidths(data)

Arguments

data
a RangedSummarizedExperiment object, produced by windowCounts or regionCounts

Value

An integer vector containing the effective width, in base pairs, of each region.

Details

Widths of all regions are increased by the average fragment length during the calculations. This is because each count represents the number of (imputed) fragments overlapping each region. Thus, a 1 bp window has an effective width that includes the average length of each fragment.

The fragment length is taken from metadata(data)$final.ext, if it is not NA. Otherwise, it is taken from data$ext. For paired-end data, the average fragment length should be the median of the values obtained with getPESizes. If the fragment lengths are different between libraries, the average is used to computed the effective width of the window.

If final.ext is NA and any of ext are NA, the function will throw an error. Users should set the read length in data$rlen to avoid this, as NA values of ext correspond to the use of unextended reads. This information must be manually supplied as it is not automatically stored when constructing data.

See Also

windowCounts, regionCounts

Examples

Run this code
bamFiles <- system.file("exdata", c("rep1.bam", "rep2.bam"), package="csaw")
data <- windowCounts(bamFiles, filter=1)
getWidths(data)

data <- windowCounts(bamFiles, ext=c(50, 100), filter=1)
getWidths(data)

data <- windowCounts(bamFiles, ext=makeExtVector(c(50, 100)), filter=1)
getWidths(data)

# Avoid error by defining 'rlen'.
data <- windowCounts(bamFiles, ext=c(NA, 100), filter=1)
try(getWidths(data))
data$rlen <- 200
getWidths(data)

# Paired-end data takes the fragment length from 'ext'.
bamFile <- system.file("exdata", "pet.bam", package="csaw")
data <- windowCounts(bamFile, param=readParam(pe="both"), ext=200, filter=1)
getWidths(data)

Run the code above in your browser using DataLab