pca_af: PCA Allele frequencies

View source: R/pca_af.R

pca_afR Documentation

PCA Allele frequencies

Description

Compute matrix of individual-specific allele frequencies via PCA

Usage

pca_af(X, d, override = FALSE, ploidy = 2, tol = 1e-13, m_chunk = 1000)

Arguments

X

A matrix of SNP genotypes, i.e. an integer matrix of 0's, 1's, 2's and NAs. BEDMatrix is supported. Sparse matrices of class Matrix are not supported (yet).

d

Number of logistic factors, including the intercept

override

Optional boolean passed to trunc_svd() to bypass its Lanczos bidiagonalization SVD, instead using corpcor::fast.svd(). Usually not advised unless encountering a bug in the SVD code. Ignored if X is a BEDMatrix object.

ploidy

Ploidy of data, defaults to 2 for bi-allelic unphased SNPs

tol

Tolerance value passed to trunc_svd() Ignored if X is a BEDMatrix object.

m_chunk

If X is a BEDMatrix object, number of loci to read per chunk (to control memory usage).

Details

This corresponds to algorithm 1 in the paper. Only used for comparison purposes.

Value

Matrix of individual-specific allele frequencies.

Examples

LF <- lfa(hgdp_subset, 4)
allele_freqs_lfa <- af(hgdp_subset, LF)
allele_freqs_pca <- pca_af(hgdp_subset, 4)
summary(abs(allele_freqs_lfa-allele_freqs_pca))

StoreyLab/lfa documentation built on March 7, 2024, 9:59 p.m.