tidy.gt_pca | R Documentation |
gt_pca
objectThis 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.
## S3 method for class 'gt_pca'
tidy(x, matrix = "eigenvalues", ...)
x |
A |
matrix |
Character specifying which component of the PCA should be tidied.
|
... |
Not used. Needed to match generic signature only. |
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 |
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. |
gt_pca_autoSVD()
augment_gt_pca
# Create a gen_tibble of lobster genotypes
bed_file <-
system.file("extdata", "lobster", "lobster.bed", package = "tidypopgen")
lobsters <- gen_tibble(bed_file,
backingfile = tempfile("lobsters"),
quiet = TRUE
)
# Remove monomorphic loci and impute
lobsters <- lobsters %>% select_loci_if(loci_maf(genotypes) > 0)
lobsters <- gt_impute_simple(lobsters, method = "mode")
# Create PCA object
pca <- gt_pca_partialSVD(lobsters)
# Tidy the PCA object
tidy(pca)
# Tidy the PCA object for eigenvalues
tidy(pca, matrix = "eigenvalues")
# Tidy the PCA object for loadings
tidy(pca, matrix = "loadings")
# Tidy the PCA object for scores
tidy(pca, matrix = "scores")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.