iProcrustes {flowStats} | R Documentation

## Procrustes analysis. Using singular value decomposition (SVD) to determine a linear transformation to align the points in X to the points in a reference matrix Y.

### Description

Based on generalized Procrustes analysis, this function determines a linear transformation (rotation/reflection and scalling) of the points in matrix `x` to align them to their reference points in matrix `xbar`. The alignemnt is carried out by minimizing the distance between the points in `x` and `xbar`.

### Usage

    iProcrustes(x, xbar, rotation.only=TRUE, scalling=TRUE, translate=FALSE)

### Arguments

`x` | A numerical matrix to be align to points in `xbar`, the second arguement. The columns represents the coordinates of the points. The matrices `x` and `xbar` must have the same dimensions.
`xbar` | A numerical, reference matrix to which points in matrix `x` are to be aligned.
`rotation.only` | Logical. When `rotaion.only` is TRUE, it allows the function to lose reflection component of the linear transformation. Although it might not give the best-fitting aligenment, when dealing with flow cytometry data alignment, a non-reflection transformation is prefered. When `rotaion.only` is FALSE, it allows the function to retain the reflection component.
`scalling` | Logical. When `scalling` is FALSE, it allows the function to calculate the linear transformation without a scalling factor. That is, the returning scalling factor is set to 1.
`translate` | Logical. Set `translate` to FALSE when the points in matrices x and xbar are already centralized prior to applying this function. When `translate` is TRUE, it allows the function to translate the centroid the points in matrix `x` to that of points in `xbar`.

### Details

Suppose the points in matrix X and \bar{X} are centralized (meaning their centroids are at the origin). The linear transformation of X for aligning X to its reference matrix \bar{X}., i.e., min ||sXQ - \bar{X}||_F, is given by:

Q = VU^T,

and

s = trace(\bar{X}^TXQ) / trace(X^T X),

where V and U are the sigular value vectors of \bar{X}^T X (that is, \bar{X}^T X = U Σ V^T), and s is the scalling factor.

### Value

A list of the linear tranformation with items

`Q` | An orthogonal, rotation/reflection matrix.
`scal` | A scalling factor

.

`T` | (optional) A translation vector used to shift the centroid of the points in matrix `x` to the origin. Returned when `translate` is TRUE.
`T.xbar` | (optional) Centered `xbar` (that is, the centroid of the points in `xbar` is translated to the origin). Returned when `translate` is TRUE.

Note that the return values of this function do not include the transformed matrix scal* x* Q or scal*(x-IT)*Q, where T is the translation vector and I is an n-by-1 vector with elements 1.

### Author(s)

C. J. Wong cwon2@fhcrc.org

### See Also

`gpaSet`

### Examples

    ## Example 1
    x <- matrix(runif(20), nrow=10, ncol=2)+ 1.4
    s <- matrix(c(cos(60), -sin(60), sin(60), cos(60)),
                nrow=2, ncol=2, byrow=TRUE)
    xbar <- 2.2 *(x %*% s) - 0.1

    lt <- iProcrustes(x, xbar, translate=TRUE) ## return linear transformation
    lt

    ## showing result
    I <- matrix(1, nrow=nrow(x), ncol=1)
    tx <- x - I %*% lt$T
    ## get the transformed matrix xnew
    xnew <- lt$scal * (tx %*% lt$Q)

    if (require(lattice)) {
       xyplot(V1 ~ V2,
              do.call(make.groups, lapply(list(x=x, xbar=xbar, T.xbar=lt$T.xbar,
                      xnew=xnew),as.data.frame)),
              group=which, aspect=c(0.7), pch=c(1,3,2,4), col.symbol="black",
    	  main=("Align the points in x to xbar"),
              key=list(points=list(pch=c(1,3,2,4), col="black"), space="right",
                       text=list(c("x", "xbar", "T.xbar", "xnew"))))
    }

    ## Example 2. centralized x and xbar prior to using iProcrustes
    x <- matrix(runif(10), nrow=5, ncol=2)
    s <- matrix(c(cos(60), -sin(60), sin(60), cos(60)),
                nrow=2, ncol=2, byrow=TRUE)
    xbar <- 1.2 *(x %*% s) - 2
    I <- matrix(1, nrow=nrow(x), ncol=1)
    x <- x-(I %*% colMeans(x)) ## shift the centroid of points in x to the origin
    xbar <- xbar - (I %*% colMeans(xbar)) ## shift centroid to the origin
    lt <- iProcrustes(x, xbar, translate=FALSE) ## return linear transformation
    ## only return the rotation/reflection matrix and scalling factor
    lt

    xnew=lt$scal *(x %*% lt$Q) ## transformed matrix aligned to centralized xbar
    if (require(lattice)) {
        xyplot(V1 ~ V2,
               do.call(make.groups, lapply(list(x=x,xbar=xbar,
                       xnew=xnew), as.data.frame)),
               group=which, auto.key=list(space="right"))
    }

[Package flowStats version 4.4.0 Index]