Learn R Programming

ClassDiscovery (version 3.4.0)

PCanova: Class "PCanova"

Description

Implements the PCANOVA method for determining whether a putative group structure is truly reflected in multivariate data set.

Usage

PCanova(data, classes, labels, colors, usecor=TRUE)

# S4 method for PCanova,missing plot(x, tag='', mscale=1, cex=1, …)

Arguments

data

either data frame or matrix with numeric values, or an ExpressionSet as defined in the BioConductor tools for analyzing microarray data.

labels

character vector used to label points in plots. The length of the labels vector should equal the number of columns (samples) in the data matrix. Since only the first character of each label is used in the plots, these should be unique.

classes

A subset of the labels used to indicate distinct classes. Again, the method truncates each class indicator to a single letter.

colors

character vector containing color names; this should be the same length as the vector of labels.

usecor

logical scalar. If TRUE, standardize the rows of the data matrix before use.

x

object of class PCanova

tag

character string to name the object, used as part of the plot title.

mscale

A real number. This is a hack; for some reason, the projection of the sample vectors into the principal component space computed from the matrix of group means seems to be off by a factor approximately equal to the square root of the average number of samples per group. Until we sort out the correct formula, this term can be adjusted until the group means appear to be in the correct place in the plots.

cex

Character expansion factor used only in the plot legend on the plot of PC correlations.

additional graphical parameters passed on to plot when displaying the principal components plots.

Value

The PCanova function returns an object of the PCanova class.

Objects from the Class

Objects should be created by calling the PCanova generator function.

Slots

orig.pca:

A matrix containing the scores component from PCA performed on the total matrix. All principal components analyses are performed using the SamplePCA class.

class.pca:

A matrix containing the scores component from PCA performed on the matrix of group-mean vectors.

resid.pca:

A matrix containing the scores component from PCA performed on the matrix of residuals.

mixed.pca:

A matrix containing the projections of all the original vectoprs into the principal component space computed from the matrix of group mean vectors.

xc:

An object produced by performing hierarchical clustering on the total data matrix, using hclust with pearson distance and average linkage.

hc:

An object produced by performing hierarchical clustering on the matrix of group means, using hclust with pearson distance and average linkage.

rc:

An object produced by performing hierarchical clustering on the matrix of residuals, using hclust with pearson distance and average linkage.

n:

An integer; the number of samples.

class2orig:

The numeric vector of PC correlations relating the total-matrix PCA to the group-means PCA.

class2resid:

The numeric vector of PC correlations relating the residual PCA to the group-means PCA.

orig2resid:

The numeric vector of PC correlations relating the total-matrix PCA to the residual PCA.

labels:

A character vector of plot labels to indicate the group membership of samples.

classes:

A character vector of labels identifying the distinct groups.

colors:

A character vector of color names used to indicate the group membership fo samples in plots.

call:

An object of class call that records how the object was constructed.

Methods

plot

signature(x = PCanova, y = missing): Plot the results of the PCANOVA test on the data. This uses par to set up a 2x2 layout of plots. The first three plots show the sample vectors (color-coded and labeled) in the space spanned by the first two principal components for each of the there PCAs. The final plot shows the three sets of PC correlations. Colors in the first three plots are determined by the colors slot of the object, which was set when the object was created. Colors in the PC correlation plot are determined by the current values of oompaColor$OBSERVED, oompaColor$EXPECTED, and oompaColor$PERMTEST

pltree

signature(x = PCanova): Produce dendrograms of the three hierarchical clusters of the samples, based on all the data, the group means, and the residuals. Since this method uses par to put all three dendrograms in the same window, it cannot be combined with other plots.

summary

signature(object = PCanova): Write out a summary of the object.

BUGS

[1] The projection of the sample vectors into the principal component space of the group-means is off by a scale factor. The mscale parameter provides a work-around.

[2] The pltree method fails if you only supply two groups; this may be a failure in hclust if you only provide two objects to cluster.

Details

The PCANOVA method was developed as part of the submission that won the award for best presentation at the 2001 conference on the Critical Assessment of Microarray Data Analysis (CAMDA; http://www.camda.info). The idea is to perform the equivalent of an analysis of variance (ANOVA) in principal component (PC) space. Let X(i,j) denote the jth column vector belonging to the ith group of samples. We can model this as X(i,j) = mu + tau(i) + E(i,j), where mu is the overall mean vector, tau(i) is the “effects” vector for the ith group, and E(i,j) is the vector of residual errors. We can perform principal components analysis on the full matrix X containing all the columns X(i,j), on the matrix containing all the group mean vectors mu + tau(i), and on the residual matrix containing all the E(i,j) vectors. PCANOVA develops a measure (“PC correlation”) for comparing these three sets of principal components. If the PC correlation is close to 1, then two principal component bases are close together; if the PC correlation is close to zero, then two principal components bases are dissimilar. Strong group structures are recognizable because the PC correlation between the total-matrix PC space and the group-means PC space is much larger than the PC correlation between the total-matrix PC space and the residual PC space. Weak or nonexistent group structures are recognizable because the relative sizes of the PC correlations is reversed.

References

Examples of the output of PCANOVA applied to the NCI60 data set can be found at http:/silicovore.com/camda01.html. The full description has not been published (out of laziness on the part of the author of this code). The only description that has appeared in print is an extremely brief description that can be found in the proceedings of the CAMDA 2001 conference.

See Also

SamplePCA

Examples

Run this code
# NOT RUN {
showClass("PCanova")

## simulate data from three groups
d1 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE)
d2 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE)
d3 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE)
dd <- cbind(d1, d2, d3)
## colors that match the groups
cols <- rep(c('red', 'green', 'blue'), each=10)

## compute the PCanova object
pan <- PCanova(dd, c('red', 'green', 'blue'), cols, cols)
summary(pan)

## view the PC plots
plot(pan)

## view the dendrograms
pltree(pan, line=-0.5)

## compare the results when there is no underlying group structure
dd <- matrix(rnorm(100*50, rnorm(100, 0.5)), nrow=100, ncol=50, byrow=FALSE)
cols <- rep(c('red', 'green', 'blue', 'orange', 'cyan'), each=10)
pan <- PCanova(dd, unique(cols), cols, cols)
plot(pan, mscale=1/sqrt(10))

pltree(pan, line=-0.5)

## cleanup
rm(d1, d2, d3, dd, cols, pan)
# }

Run the code above in your browser using DataLab