AddPCA {polyRAD} | R Documentation |
Perform Principal Components Analysis on “RADdata” Object
Description
This function uses read depth ratios or posterior genotype probabilities
(the latter preferentially) as input data for principal components analysis.
The PCA scores are then stored in the $PCA
slot of the
"RADdata"
object.
Usage
AddPCA(object, ...)
## S3 method for class 'RADdata'
AddPCA(object, nPcsInit = 10, maxR2changeratio = 0.05,
minPcsOut = 1, ...)
Arguments
object |
A |
nPcsInit |
The number of principal component axes to initially calculate. |
maxR2changeratio |
This number determines how many principal component axes are retained. The
difference in |
minPcsOut |
The minimum number of PC axes to output, which can override
|
... |
Additional arguments to be passed to the |
Details
The PPCA (probabalistic PCA) method from pcaMethods is used, due to the high missing data rate that is typical of genotyping-by-sequencing datasets.
Value
A "RADdata"
object identical to the one passed to the function, but with
a matrix added to the $PCA
slot. This matrix contains PCA scores, with
taxa in rows, and PC axes in columns.
Note
If you see the error
Error in if (rel_ch < threshold & count > 5) { :
missing value where TRUE/FALSE needed
try lowering nPcsInit
.
Author(s)
Lindsay V. Clark
See Also
Examples
# load data
data(exampleRAD)
# do PCA
exampleRAD <- AddPCA(exampleRAD, nPcsInit = 3)
plot(exampleRAD$PCA[,1], exampleRAD$PCA[,2])