View source: R/withinVariation.R
withinVariation | R Documentation |
This function is internally called by pca
, pls
, spls
,
plsda
and splsda
functions for cross-over design data, but can
be called independently prior to any kind of multivariate analyses.
withinVariation(X, design)
X |
numeric matrix of predictors. |
design |
a numeric matrix or data frame. The first column indicates the repeated measures on each individual, i.e. the individuals ID. The 2nd and 3rd columns are to split the variation for a 2 level factor. |
withinVariation
function decomposes the Within variation in the
X
data set. The resulting Xw
matrix is then input in the
multilevel
function.
One or two-factor analyses are available.
withinVariation
simply returns the Xw
within matrix,
which can be input in the other multivariate approaches already implemented
in mixOmics (i.e. spls or splsda, see multilevel
, but also pca or
ipca).
Benoit Liquet, Kim-Anh Lê Cao, Benoit Gautier, Ignacio González, Florian Rohart, AL J Abadi
On multilevel analysis:
Liquet, B., Lê Cao, K.-A., Hocini, H. and Thiebaut, R. (2012) A novel approach for biomarker selection and the integration of repeated measures experiments from two platforms. BMC Bioinformatics 13:325.
Westerhuis, J. A., van Velzen, E. J., Hoefsloot, H. C., and Smilde, A. K. (2010). Multivariate paired data analysis: multilevel PLSDA versus OPLSDA. Metabolomics, 6(1), 119-128.
spls
, splsda
, plotIndiv
,
plotVar
, cim
, network
.
## Example: one-factor analysis matrix decomposition
#--------------------------------------------------------------
data(vac18)
X <- vac18$genes
# in design we only need to mention the repeated measurements to split the one level variation
design <- data.frame(sample = vac18$sample)
Xw <- withinVariation(X = X, design = design)
# multilevel PCA
res.pca.1level <- pca(Xw, ncomp = 3)
# compare a normal PCA with a multilevel PCA for repeated measurements.
# note: PCA makes the assumptions that all samples are independent,
# so this analysis is flawed and you should use a multilevel PCA instead
res.pca <- pca(X, ncomp = 3)
# set up colors for plotIndiv
col.stim <- c("darkblue", "purple", "green4","red3")
col.stim <- col.stim[as.numeric(vac18$stimulation)]
# plotIndiv comparing both PCA and PCA multilevel
plotIndiv(res.pca, ind.names = vac18$stimulation, group = col.stim)
title(main = 'PCA ')
plotIndiv(res.pca.1level, ind.names = vac18$stimulation, group = col.stim)
title(main = 'PCA multilevel')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.