dist2 {affyQCReport} | R Documentation |
Calculate an n-by-n matrix by applying a function to pairs of columns of an m-by-n matrix.
dist2(x, fun=function(a,b) mad(a-b))
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 . |
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.
A symmetric matrix of size n x n
.
Diagonal elements are NA
.
z = matrix(rnorm(15693), ncol=3) dist2(z)