forked from gabraham/flashpca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.Rd
71 lines (62 loc) · 2.32 KB
/
check.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/check.R
\name{check}
\alias{check}
\title{Check the accuracy of Principal Component Analysis}
\usage{
check(
X,
evec,
eval,
stand = c("binom2", "binom", "sd", "center", "none"),
divisor = "p",
block_size = 1000,
verbose = FALSE,
check_geno = TRUE,
check_fam = TRUE
)
}
\arguments{
\item{X}{A numeric matrix to project onto the PCs, or a
character string pointing to a PLINK dataset.}
\item{evec}{A numeric matrix of eigenvectors (samples on rows,
ndim dimensions on columns).}
\item{eval}{A numeric vector of eigenvalues.}
\item{stand}{A character string indicating how to standardise X before PCA,
one of "binom" (old Eigenstrat-style), "binom2" (new Eigenstrat-style),
"sd" (zero-mean unit-variance), "center" (zero mean), or "none".}
\item{divisor}{A character string indicating whether to divide the
eigenvalues by number of columns of X ("p"), the number of
rows of X minus 1 ("n1") or none ("none").}
\item{block_size}{Integer. Block size for PCA on PLINK files.}
\item{verbose}{Logical. Verbose output.}
\item{check_geno}{Logical. Whether to explicitly check if the matrix X
contains values other than {0, 1, 2}, when stand="binom". This can be
be set to FALSE if you are sure your matrix only contains these values
(only matters when using stand="binom").}
\item{check_fam}{Logical. Whether to check that the number of row in
the PLINK fam file (if X is a character string) matches the number of
rows in the eigenvectors.}
}
\value{
\code{check} returns a list containing the following components:
\describe{
\item{err}{A numeric vector. The squared error along each dimension k.}
\item{mse}{A numeric value. The mean squared error; the sum of the
squared errors divided by N * ndim.}
\item{rmse}{A numeric value. The root mean squared error, the square
root of mse.}
}
}
\description{
Check the accuracy of Principal Component Analysis
}
\details{
\code{check} computes the accuracy of the eigen-decomposition of XX'/m,
defined as
\deqn{[1/(nK) \sum_{k=1}^K ||(1/m) XX' U_k - U_k d^2_k||_F^2]^{1/2}}
Note: this definition is sensitive to the magnitude of the eigenvalues and
therefore requires specifiying the same standardisation that was used in
the original eigen-decomposition, and the same divisor of XX' (usually the
number of SNPs, p).
}