Tidy a gt_pca
object
tidy_gt_pca.Rd
This summarizes information about the components of a gt_pca
from the
tidypopgen
package. The parameter matrix
determines which element is
returned. Column names of the tidied output match those returned by
broom::tidy.prcomp, the tidier for the standard PCA objects returned
by stats::prcomp.
Usage
# S3 method for class 'gt_pca'
tidy(x, matrix = "eigenvalues", ...)
Arguments
- x
A
gt_pca
object returned by one of thegt_pca_*
functions.- matrix
Character specifying which component of the PCA should be tidied.
"samples"
,"scores"
, or"x"
: returns information about the map from the original space into principle components space (this is equivalent to product of u and d)."v"
,"rotation"
,"loadings"
or"variables"
: returns information about the map from principle components space back into the original space."d"
,"eigenvalues"
or"pcs"
: returns information about the eigenvalues.
- ...
Not used. Needed to match generic signature only.
Value
A tibble::tibble with columns depending on the component of PCA being tidied.
If "scores"
each row in the
tidied output corresponds to the original data in PCA space. The columns
are:
row
ID of the original observation (i.e. rowname from original data).
PC
Integer indicating a principal component.
value
The score of the observation for that particular principal component. That is, the location of the observation in PCA space.
If matrix
is "loadings"
, each
row in the tidied output corresponds to information about the principle
components in the original space. The columns are:
row
The variable labels (colnames) of the data set on which PCA was performed.
PC
An integer vector indicating the principal component.
value
The value of the eigenvector (axis score) on the indicated principal component.
If "eigenvalues"
, the columns are:
PC
An integer vector indicating the principal component.
std.dev
Standard deviation (i.e. sqrt(eig/(n-1))) explained by this PC (for compatibility with
prcomp
.cumulative
Cumulative variation explained by principal components up to this component (note that this is NOT phrased as a percentage of total variance, since many methods only estimate a truncated SVD.