Learn R Programming

polyRAD (version 2.0.0)

AddPCA: 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 RADdata
AddPCA(object, nPcsInit = 10, maxR2changeratio = 0.05, 
                         minPcsOut = 1, ...)

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.

Arguments

object

A "RADdata" object.

nPcsInit

The number of principal component axes to initially calculate.

maxR2changeratio

This number determines how many principal component axes are retained. The difference in \(R^2\) values between the first and second axes is multiplied by maxR2changeratio. The last axis retained is the first axis after which the \(R^2\) value changes by less than this value. Lower values of maxR2changeratio will result in more axes being retained.

minPcsOut

The minimum number of PC axes to output, which can override maxR2changeratio.

...

Additional arguments to be passed to the pca function from the pcaMethods BioConductor package.

Author

Lindsay V. Clark

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.

See Also

AddAlleleFreqByTaxa

Examples

Run this code
# load data
data(exampleRAD)
# do PCA
exampleRAD <- AddPCA(exampleRAD, nPcsInit = 3)

plot(exampleRAD$PCA[,1], exampleRAD$PCA[,2])

Run the code above in your browser using DataLab