# pca: Principal Components Analysis In mixOmics: Omics Data Integration Project

## Description

Performs a principal components analysis on the given data matrix that can contain missing values. If data are complete 'pca' uses Singular Value Decomposition, if there are some missing values, it uses the NIPALS algorithm.

## Usage

 1 2 3 4 5 6 7 8 9 10 11 12 13 pca( X, ncomp = 2, center = TRUE, scale = FALSE, max.iter = 500, tol = 1e-09, logratio = c("none", "CLR", "ILR"), ilr.offset = 0.001, V = NULL, multilevel = NULL, reconst = TRUE )

## Arguments

 X a numeric matrix (or data frame) which provides the data for the principal components analysis. It can contain missing values. ncomp Integer, if data is complete ncomp decides the number of components and associated eigenvalues to display from the pcasvd algorithm and if the data has missing values, ncomp gives the number of components to keep to perform the reconstitution of the data using the NIPALS algorithm. If NULL, function sets ncomp = min(nrow(X), ncol(X)) center (Default=TRUE) Logical, whether the variables should be shifted to be zero centered. Alternatively, a vector of length equal the number of columns of X can be supplied. The value is passed to scale. scale (Default=FALSE) Logical indicating whether the variables should be scaled to have unit variance before the analysis takes place. The default is FALSE for consistency with prcomp function, but in general scaling is advisable. Alternatively, a vector of length equal the number of columns of X can be supplied. The value is passed to scale. max.iter Integer, the maximum number of iterations in the NIPALS algorithm. tol Positive real, the tolerance used in the NIPALS algorithm. logratio (Default='none') one of ('none','CLR','ILR'). Specifies the log ratio transformation to deal with compositional values that may arise from specific normalisation in sequencing data. Default to 'none' ilr.offset (Default=0.001) When logratio is set to 'ILR', an offset must be input to avoid infinite value after the logratio transform. V Matrix used in the logratio transformation if provided. multilevel sample information for multilevel decomposition for repeated measurements. reconst (Default=TRUE) Logical. If matrix includes missing values, whether nipals must perform the reconstitution of the data using the ncomp components. The components are calculated by imputing the missing values when set to TRUE, otherwise the missing values will be ignored.

## Details

The calculation is done either by a singular value decomposition of the (possibly centered and scaled) data matrix, if the data is complete or by using the NIPALS algorithm if there is data missing. Unlike princomp, the print method for these objects prints the results in a nice format and the plot method produces a bar plot of the percentage of variance explaned by the principal components (PCs).

When using NIPALS (missing values), we make the assumption that the first (min(ncol(X), nrow(X)) principal components will account for 100 % of the explained variance.

Note that scale= TRUE cannot be used if there are zero or constant (for center = TRUE) variables.

According to Filzmoser et al., a ILR log ratio transformation is more appropriate for PCA with compositional data. Both CLR and ILR are valid.

Logratio transform and multilevel analysis are performed sequentially as internal pre-processing step, through logratio.transfo and withinVariation respectively.

Logratio can only be applied if the data do not contain any 0 value (for count data, we thus advise the normalise raw data with a 1 offset). For ILR transformation and additional offset might be needed.

## Value

pca returns a list with class "pca" and "prcomp" containing the following components:

 call The function call. ncomp The number of principal components used. center The centering used. scale The scaling used. names List of row and column names of data. sdev The eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix or by using NIPALS. rotation The matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors). x The value of the rotated data (the centred (and scaled if requested) data multiplied by the rotation/loadings matrix), also called the principal components. var.tot Total variance in the data. loadings Same as 'rotation' to keep the mixOmics spirit variates Same as 'x' to keep the mixOmics spirit explained_variance Explained variance from the multivariate model, used for plotIndiv cum.var The cumulative explained variance for components. X The input data matrix.

## Author(s)

Florian Rohart, Kim-Anh Lê Cao, Ignacio González, Al J Abadi

## References

On log ratio transformations: Filzmoser, P., Hron, K., Reimann, C.: Principal component analysis for compositional data with outliers. Environmetrics 20(6), 621-632 (2009) Lê Cao K.-A., Costello ME, Lakis VA, Bartolo, F,Chua XY, Brazeilles R, Rondeau P. MixMC: Multivariate insights into Microbial Communities. PLoS ONE, 11(8): e0160169 (2016). On multilevel decomposition: Westerhuis, J.A., van Velzen, E.J., Hoefsloot, H.C., Smilde, A.K.: Multivariate paired data analysis: multilevel plsda versus oplsda. Metabolomics 6(1), 119-128 (2010) Liquet, B., Lê Cao, K.-A., Hocini, H., Thiebaut, R.: A novel approach for biomarker selection and the integration of repeated measures experiments from two assays. BMC bioinformatics 13(1), 325 (2012)