plink_pca: Estimate principal components with plink2

View source: R/plink_pca.R

plink_pcaR Documentation

Description

A wrapper for running plink2's PCA. In addition to the arguments listed below, the executable is run with --silent, --nonfounders (to use all individuals whether they are labeled as founders or not), and --bad-freqs (to apply even when sample sizes are very small).

Usage

plink_pca(
  name,
  name_out = name,
  n_pcs = 10,
  maf = 0.1,
  approx = FALSE,
  plink_bin = "plink2",
  threads = 0,
  verbose = TRUE
)

Arguments

name

The shared name of the input plink BED/BIM/FAM files without extensions.

name_out

The base name of the output eigenvec/eigenval files (default same as input name), which gets extensions added automatically.

n_pcs

The number of eigenvectors/eigenvalues (a.k.a. principal components) to calculate.

maf

The minor allele frequency threshold to apply to data prior to eigendecomposition.

approx

Apply approximate PCA algorithm.

plink_bin

The path to the binary executable. Default assumes plink2 is in the PATH.

threads

The number of threads to use. The values 0 (default), NA, or NULL use all threads available (the output of parallel::detectCores()).

verbose

If TRUE (default), prints the command line before it is executed.

Value

Nothing (the eigenvec/eigenval files are not read in; see example below for reading with a different function).

See Also

genio::read_eigenvec() for reading eigenvec files.

delete_files_pca() for deleting the eigenvec/eigenval outputs.

delete_files_log() for deleting plink log files.

system3(), used (with ret = FALSE) for executing plink2 and error handling.

Examples

## Not run: 
# create PCs (on file)
plink_pca( name, name_out )

# read file with genio
data <- genio::read_eigenvec( name_out )

## End(Not run)


OchoaLab/genbin documentation built on Nov. 14, 2024, 7:33 p.m.