pca_wsaf: PCA of within-sample allele frequencies

View source: R/analysis_clustering.R

pca_wsafR Documentation

PCA of within-sample allele frequencies

Description

Conduct principal components analysis (PCA) on a matrix of within-sample allele frequencies (WSAF). Missing values must have been already imputed. Output includes the raw components, the variance in the data explained by each component, and the loadings of each component also returned.

Usage

pca_wsaf(x)

Arguments

x

a matrix of within-sample allele frequencies, as produced by the function get_wsaf().

Details

Contributions of each variable are computed from the loading values (stored as "rotation" within the prcomp object). The percent contribution of a variable is defined as the absolute loading value for this variable, divided by the sum of loadings over all variables and multiplied by 100.

Value

Invisibly returns a list of class 'prcomp' with the following components

  • "sdev" the standard deviations of the principal components (i.e., the square roots of the eigenvalues of the covariance/correlation matrix, though the calculation is actually done with the singular values of the data matrix).

  • "rotation" the matrix of variable loadings (i.e., a matrix whose columns contain the eigenvectors). The function princomp returns this in the element loadings.

  • "center, scale" the centering and scaling used.

  • "x" the value of the rotated data (the centred data multiplied by the rotation matrix). Hence, cov(x) is the diagonal matrix diag(sdev^2).

  • "var" the variance in the data explained by each component.

  • "contribution" the percent contribution of a variable (i.e. a locus) to the overall variation.


mrc-ide/MIPanalyzer documentation built on Jan. 17, 2024, 7:16 p.m.