binNormalize: Normalize counts

View source: R/preprocess-utils.R

binNormalizeR Documentation

Normalize counts

Description

Log-transforms the counts for each bin and centers them by by the mode (default) or median of the counts for the autosomes.

Usage

binNormalize(bins, centerby = c("mode", "median"))

Arguments

bins

a GRanges object

centerby

mode or median

Details

The bins argument to binNormalize() must be a GRanges object with chromosome names in the format [chr1, chr2, ...] and not [1, 2, ...] or any other naming convention. There must be a metadata column of integers named cnt corresponding to the raw counts for each bin.

The output vector from binNormalize() is generally appended back to bins as a metadata column named std_cnt for GC normalization by binGCCorrect().

Value

A numeric vector of normalized counts.

Examples

library(Rsamtools)
library(svbams)
library(svfilters.hg19)
data(bins1kb)
extdir <- system.file("extdata", package="svbams", mustWork=TRUE)
bamfile <- file.path(extdir, "cgov10t.bam")
bins <- keepSeqlevels(bins1kb, "chr3", pruning.mode = "coarse")
bins <- subsetByOverlaps(bins, GRanges("chr3", IRanges(59600000, 61000000)))
bviews <- BamViews(bamRanges=bins, bamPaths=bamfile)
bins$cnt <- binnedCounts(bviews)
head(binNormalize(bins))
std_cnt <- binNormalize(bins)
bins$std_cnt <- std_cnt

cancer-genomics/trellis documentation built on Feb. 2, 2023, 7:04 p.m.