View source: R/gt_dapc_tidiers.R
tidy.gt_dapc | R Documentation |
gt_dapc
objectThis summarizes information about the components of a gt_dapc
from the
tidypopgen
package. The parameter matrix
determines which element is
returned.
## S3 method for class 'gt_dapc'
tidy(x, matrix = "eigenvalues", ...)
x |
A |
matrix |
Character specifying which component of the DAPC should be tidied.
|
... |
Not used. Needed to match generic signature only. |
A tibble::tibble with columns depending on the component of DAPC 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). |
LD |
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. |
LD |
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:
LD |
An integer vector indicating the discriminant axis. |
std.dev |
Standard deviation (i.e. sqrt(eig/(n-1))) explained by
this DA (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_dapc()
augment.gt_dapc()
#' # 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 and run DAPC
pca <- gt_pca_partialSVD(lobsters)
populations <- as.factor(lobsters$population)
dapc_res <- gt_dapc(pca, n_pca = 6, n_da = 2, pop = populations)
# Tidy scores
tidy(dapc_res, matrix = "scores")
# Tidy eigenvalues
tidy(dapc_res, matrix = "eigenvalues")
# Tidy loadings
tidy(dapc_res, matrix = "loadings")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.