pca_function: pca_function

Description Usage Arguments Details Value Examples

View source: R/all.R

Description

Create Principal Components from Standardized Set of SNPs.

Usage

1
pca_function(SNPs,number_components,plot_it)

Arguments

SNPs

The SNP matrix where the columns consist of 0 and 1's.

number_components

The number of principal components desired, if you don't know put a random value and use plot_it = TRUE.

plot_it

A TRUE FALSE logical equality, if TRUE will plot the percent variation explained by the components, if FALSE will not create a plot. In both scenarios this function will return a matrix of principal components.

Details

This will work with both the full SNP matrix and the reduced SNP matrix. If you use the full SNP matrix you will have to reduce it yourself and this is at a higher computational burden. If you use the reduced SNP matrix you will get the same values as if you aggregated the principal components from the full SNP matrix, but this will be much faster.

Value

Plot

A plot of the percent variation explained by the components when plot_it = TRUE

Matrix

A matrix that the number of columns is the number of principal components and the number of rows is the same number of rows as the inputted data matrix.

Examples

1
2
3
4
5
6
7
8
9
data("vignette_lm_dat")
Y <- vignette_lm_dat$Phenotype
SNPs <- vignette_lm_dat[,-1]
fullPreprocess <- preprocess_SNPs(SNPs = SNPs,Y = Y,MAF = 0.01,number_cores = 1)
SNPs <- fullPreprocess$SNPs
Y <- fullPreprocess$Y
fullPreprocess$SNPs_Dropped

pca_function(SNPs = SNPs,number_components = 3,plot_it = TRUE)

GWAS.BAYES documentation built on Nov. 8, 2020, 7:47 p.m.