dist2 {affyQCReport}R Documentation

Calculate an n-by-n matrix by applying a function to pairs of columns of an m-by-n matrix.

Description

Calculate an n-by-n matrix by applying a function to pairs of columns of an m-by-n matrix.

Usage

  dist2(x, fun=function(a,b) mad(a-b))

Arguments

x A matrix, or indeed any object for which ncol(x) and x[,j] return useful results.
fun A symmetric function of two arguments that may be columns of x.

Details

With the default value of fun, this calculates a matrix of the mad of all pairwise differences of columns of x. This may be considered a measure of distance.

The implementation assumes that fun is symmetric, fun(a,b)=fun(b,a).

A use for this function is the detection of outlier arrays in a microarray experiment. Assume that each column of x can be decomposed as $z+β+ε$, where $z$ is a fixed vector (the same for all columns), $ε$ is vector of nrow{x} i.i.d. random numbers, and $β$ is an arbitrary vector whose majority of entries are negligibly small (i.e. close to zero). In other words, $z$ the probe effects, $ε$ measurement noise and $β$ differential expression effects. Under this assumption, all entries of the resulting distance matrix should be the same, namely $sqrt(2)$ times the standard deviation of $ε$. Arrays whose distance matrix entries are way different give cause for suspicion.

Value

A symmetric matrix of size n x n. Diagonal elements are NA.

Examples

  z = matrix(rnorm(15693), ncol=3)
  dist2(z)

[Package affyQCReport version 1.14.0 Index]