Last data update: 2014.03.03

R: Normalizes the empirical distribution of a set of samples to...
normalizeQuantileRank.matrixR Documentation

Normalizes the empirical distribution of a set of samples to a common target distribution

Description

Normalizes the empirical distribution of a set of samples to a common target distribution.

The average sample distribution is calculated either robustly or not by utilizing either weightedMedian() or weighted.mean(). A weighted method is used if any of the weights are different from one.

Usage

## S3 method for class 'matrix'
normalizeQuantileRank(X, ties=FALSE, robust=FALSE, weights=NULL,
  typeOfWeights=c("channel", "signal"), ...)

Arguments

X

a numerical NxK matrix with the K columns representing the channels and the N rows representing the data points.

robust

If TRUE, the (weighted) median function is used for calculating the average sample distribution, otherwise the (weighted) mean function is used.

ties

Should ties in x be treated with care or not? For more details, see "limma:normalizeQuantiles".

weights

If NULL, non-weighted normalization is done. If channel weights, this should be a vector of length K specifying the weights for each channel. If signal weights, it should be an NxK matrix specifying the weights for each signal.

typeOfWeights

A character string specifying the type of weights given in argument weights.

...

Not used.

Value

Returns an object of the same shape as the input argument.

Missing values

Missing values are excluded when estimating the "common" (the baseline). Values that are NA remain NA after normalization. No new NAs are introduced.

Weights

Currently only channel weights are support due to the way quantile normalization is done. If signal weights are given, channel weights are calculated from these by taking the mean of the signal weights in each channel.

Author(s)

Adopted from Gordon Smyth (http://www.statsci.org/) in 2002 & 2006. Original code by Ben Bolstad at Statistics Department, University of California. Support for calculating the average sample distribution using (weighted) mean or median was added by Henrik Bengtsson.

See Also

median, weightedMedian, mean() and weighted.mean. normalizeQuantileSpline().

Examples

# Simulate three samples with on average 20% missing values
N <- 10000
X <- cbind(rnorm(N, mean=3, sd=1),
           rnorm(N, mean=4, sd=2),
           rgamma(N, shape=2, rate=1))
X[sample(3*N, size=0.20*3*N)] <- NA

# Normalize quantiles
Xn <- normalizeQuantile(X)

# Plot the data
layout(matrix(1:2, ncol=1))
xlim <- range(X, Xn, na.rm=TRUE);
plotDensity(X, lwd=2, xlim=xlim, main="The three original distributions")
plotDensity(Xn, lwd=2, xlim=xlim, main="The three normalized distributions")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(aroma.light)
aroma.light v3.2.0 (2016-01-06) successfully loaded. See ?aroma.light for help.
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/aroma.light/normalizeQuantileRank.matrix.Rd_%03d_medium.png", width=480, height=480)
> ### Name: normalizeQuantileRank.matrix
> ### Title: Normalizes the empirical distribution of a set of samples to a
> ###   common target distribution
> ### Aliases: normalizeQuantileRank.matrix
> ### Keywords: methods nonparametric multivariate robust
> 
> ### ** Examples
> 
> # Simulate three samples with on average 20% missing values
> N <- 10000
> X <- cbind(rnorm(N, mean=3, sd=1),
+            rnorm(N, mean=4, sd=2),
+            rgamma(N, shape=2, rate=1))
> X[sample(3*N, size=0.20*3*N)] <- NA
> 
> # Normalize quantiles
> Xn <- normalizeQuantile(X)
> 
> # Plot the data
> layout(matrix(1:2, ncol=1))
> xlim <- range(X, Xn, na.rm=TRUE);
> plotDensity(X, lwd=2, xlim=xlim, main="The three original distributions")
> plotDensity(Xn, lwd=2, xlim=xlim, main="The three normalized distributions")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>