Learn R Programming

sequenza (version 1.0.5)

windowValues: Bins sequencing data for plotting

Description

Given a variable with corresponding genomic positions, the function bins the values in windows of a specified size and calculates weighted mean and 25th and 75th percentile for each window, which is useful for plotting with plotWindows.

Usage

windowValues(x, positions, chromosomes, window = 1e6, overlap = 0, verbose = TRUE,
             weight = rep.int( x = 1, times = length(x)), start.coord = 1)

Arguments

x
variable to be windowed.
positions
base-pair positions.
chromosomes
names or numbers of the chromosomes.
window
size of windows used for binning data. Smaller windows will take more time to compute.
overlap
integer defining the number of overlapping windows. Default is 0, no overlap.
verbose
logical, indicating whether to print information about the chromosome being processed.
weight
weights to be assigned to each value of x, usually related to the read depth.
start.coord
coordinate at which to start computing the windows. If NULL, will start at the first position available.

Value

  • a list of matrices, one per chromosome. Each matrix contains base-pair windows covering the chromosome, and for each window the weighted mean, 25th and 75th percentiles of the input values, and the number of data points within each window.

Details

DNA sequencing produces an amount of data too large to be handled by standard graphical devices. In addition, for samples analyzed with older machines and with low or middle coverage (20x to 50x), measures such as read depth are subject to big variations due to technical noise. Using windowValues prior to plotting reduces the amount of data that will be plotted, and reduces noise.

The output of windowValues can be used as input for plotWindows.

See Also

plotWindows, mutation.table

Examples

Run this code
data.file <-  system.file("data", "abf.data.abfreq.txt.gz", package = "sequenza")
abf.data <- read.abfreq(data.file)
# 1Mb windows, each window is overlapping with 1 other adjacent window: depth ratio
abf.ratio <- windowValues(x = abf.data$depth.ratio,
                           positions = abf.data$n.base,
                           chromosomes = abf.data$chromosome, window = 1e6,
                           weight = abf.data$depth.normal, start.coord = 1, overlap = 1)
abf.hom  <- abf.data$ref.zygosity == 'hom'
abf.het  <- abf.data[!abf.hom, ]
# 1Mb windows, each window is overlapping with 1 other adjacent window: B-allele frequency
abf.bafs  <- windowValues(x = abf.het$Bf,
                           positions = abf.het$n.base,
                           chromosomes = abf.het$chromosome, window = 1e6,
                           weight = abf.het$depth.sample,
                           start.coord = 1, overlap = 1)

Run the code above in your browser using DataLab