Performs PCA using the genome relationship matrix (GRM).

doPCA(genotypes)

Arguments

genotypes

Genotype matrix.

Value

List containing `pcs` (principal components) and `eigen` (eigenvalues).

Examples

# \donttest{
set.seed(1)
mat <- matrix(sample(as.raw(1:3), 200, TRUE), nrow = 10, ncol = 20)
geno <- methods::new("SnpMatrix", mat)
#> object has no names - using numeric order for row/column names
rownames(geno) <- paste0("S", 1:10)
colnames(geno) <- paste0("SNP", 1:20)
res <- doPCA(geno)
#> Eigenvalues near zero set to zero (|eigenvalue| < 1e-3)
str(res)
#> List of 2
#>  $ pcs  : num [1:10, 1:10] -2.933 2.378 -1.713 2.066 -0.603 ...
#>  $ eigen: num [1:10] 54.6 41.9 38.4 33 27.9 ...
# }