View source: R/gt_pca_randomSVD.R
gt_pca_randomSVD | R Documentation |
gen_tibble
objects by randomized partial SVDThis function performs Principal Component Analysis on a gen_tibble
,
by randomised partial SVD based on the
algorithm in RSpectra (by Yixuan Qiu and Jiali Mei).
This algorithm is linear in time in all dimensions and is very
memory-efficient. Thus, it can be used on very large big.matrices.
This function is a wrapper
for bigstatsr::big_randomSVD()
gt_pca_randomSVD(
x,
k = 10,
fun_scaling = bigsnpr::snp_scaleBinom(),
tol = 1e-04,
verbose = FALSE,
n_cores = 1,
fun_prod = bigstatsr::big_prodVec,
fun_cprod = bigstatsr::big_cprodVec,
total_var = TRUE
)
x |
a |
k |
Number of singular vectors/values to compute. Default is |
fun_scaling |
Usually this can be left unset, as it defaults to
|
tol |
Precision parameter of svds. Default is |
verbose |
Should some progress be printed? Default is |
n_cores |
Number of cores used. |
fun_prod |
Function that takes 6 arguments (in this order):
|
fun_cprod |
Same as |
total_var |
a boolean indicating whether to compute the total variance
of the matrix. Default is |
a gt_pca
object, which is a subclass of bigSVD
; this is
an S3 list with elements:
A named list (an S3 class "big_SVD") of
d
, the eigenvalues (singular values, i.e. as variances),
u
, the scores for each sample on each component (the left singular
vectors)
v
, the loadings (the right singular vectors)
center
, the centering vector,
scale
, the scaling vector,
method
, a string defining the method (in this case 'randomSVD'),
call
, the call that generated the object.
Note: rather than accessing these elements directly, it is better to use
tidy
and augment
. See gt_pca_tidiers
.
vcf_path <-
system.file("extdata", "anolis",
"punctatus_t70_s10_n46_filtered.recode.vcf.gz",
package = "tidypopgen"
)
anole_gt <-
gen_tibble(vcf_path, quiet = TRUE, backingfile = tempfile("anolis_"))
# Remove monomorphic loci and impute
anole_gt <- anole_gt %>% select_loci_if(loci_maf(genotypes) > 0)
anole_gt <- gt_impute_simple(anole_gt, method = "mode")
# Create PCA obejct, including total variance
gt_pca_randomSVD(anole_gt, k = 10, total_var = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.