Learn R Programming

sequenza (version 2.1.2)

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,
             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.

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

mutation.table

Examples

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

Run the code above in your browser using DataLab