Principal Component Analysis All in One (v0.9.0)¶
PCAone is a scalable and memory-efficient C++ tool for principal component analysis(PCA).
It runs with all data in memory or streams it from disk, so biobank-scale data fit on an ordinary machine. PCA methods supported (--svd):
window-based randomized SVD (default, ours), single-pass randomized SVD, IRAM, and exact sample-GRM eigendecomposition.
What sets PCAone apart is structure-aware analysis. Standard estimators of
relatedness, LD and HWE assume one homogeneous population with a single allele
frequency per site. In structured or admixed samples, that assumption turns
population structure into false signal. PCAone models the structure with the
top PCs of one PCA run with informative SNPs, saved once and read back with -P/--USV:
- Relatedness (
--evaladmix): with one allele frequency per site, unrelated samples from the same population look related. PCAone estimates pairwise kinship from the correlation of the genotype residuals left after the PCs (evalAdmix, with PCA in place of an admixture model), so no admixture run is needed. - LD (
--ld-r2,--clump): variants that differ in frequency between populations are correlated even when far apart, so pruning on standard LD removes too many. PCAone computes LD on the residuals after removing the PCs, and prunes and clumps on that ancestry-adjusted LD. - HWE and inbreeding (
--inbreed): pooling populations creates a deficit of heterozygotes (the Wahlund effect), so standard tests flag every differentiated site. PCAone tests each site against individual allele frequencies, the frequency for each sample predicted from the PCs.
It handles the main kinds of genetic data:
- Array or imputed genotypes: PLINK BED, PLINK2 PGEN (dosages when available) and BGEN.
- Low-coverage sequencing: genotype likelihoods in BEAGLE format, with
PCAngsd-style EM-PCA (
--pcangsd). - Missing data: EM-PCA (
--emu) imputes missing genotypes from the PCs instead of filling them with the mean.
PCAone also projects new samples onto the PCs of a reference panel without recomputing them, built for sparse data such as ancient DNA and low-coverage sequencing:
- Called genotypes with missing calls (
--project 2): each sample is fitted on its own called sites only, rather than filling the gaps with the reference allele frequency. - Low-coverage data (
--project 3): projects genotype likelihoods (BEAGLE) directly, by EM, without calling genotypes. - Bootstrap (
--project-bootstrap): resamples the matched SNPs to give each projected sample a standard error and PC covariances for uncertainty ellipses (with--project 2). - Biobank-size targets:
--project 1and2stream the target in blocks, within 2 GB or the-mgiven, straight from its 2-bit PLINK/PGEN calls, so any number of samples is projected in one run, several times faster than plink2--score.
Also included: selection scans, and PCA of other data such as zstd-compressed CSV counts.
Documentation · Change log and migration notes · R package

One PCA, reused by structure-aware analyses. (a) PCAone saves U, S, V and the allele frequencies f; every downstream analysis reads them back with -P/--USV. (b–h) Examples on 1000 Genomes samples and on admixed samples with known relatedness.
Installation¶
Install with Bioconda:
Or download a Linux/macOS binary from the releases page.
To build from source, use a C++17 compiler, GNU make, and zlib. On macOS,
install OpenMP first with brew install libomp.
See Installation for MKL and OpenBLAS builds.
Quick start¶
# PLINK BED/BIM/FAM: compute 10 PCs
PCAone -b data -k 10 -o pcs
# PLINK2 PGEN/PVAR/PSAM: use dosages when available
PCAone -p data -k 10 -o pcs
# Out-of-core PCA with a 2 GB memory setting
PCAone -b data -k 10 -m 2 -o pcs
Replace data with your input prefix. Add --hardcall to use PGEN hard calls.
-m sizes the working blocks, so total RAM can exceed it.
| Output | Contents |
|---|---|
.eigvecs |
PC coordinates: samples × PCs |
.eigvecs2 |
The same with FID/IID columns and a header |
.eigvals |
Eigenvalues |
.sigvals |
Singular values and scaling metadata |
.loadings |
Feature loadings; skip with --no-loadings |
.mbim |
Variant metadata and frequencies with loadings |
.log |
Run settings and progress |
For up to a few thousand samples, use --svd 3 for exact PCA. It holds an
N × N sample GRM in memory and does not support EM-PCA. Keep the
default --svd 2 for large datasets; see
choosing a PCA method.
Common workflows¶
Most analyses take two steps: compute the PCs once, then pass them back with
-P/--USV.
# Step 1: compute the PCs once
PCAone -b data -k 3 -o pcs
# Relatedness: pairwise kinship from the PCA residuals
PCAone -b data -P pcs --evaladmix -o rel
# LD pruning adjusted for ancestry
PCAone -b data -P pcs --ld-r2 0.2 -o pruned
# HWE tests and inbreeding that account for population structure
PCAone -b data -k 3 --pcangsd -o pcs_hwe
PCAone -b data -P pcs_hwe --inbreed 1 -o hwe
# Build a reference and project new samples, with 100 bootstrap replicates
PCAone -b reference -k 10 -o ref
PCAone -b target -P ref --project 2 --project-bootstrap 100 -o projected
# Project low-coverage samples from genotype likelihoods
PCAone -G target.beagle.gz -P ref --project 3 -o projected_gl
# PCA for count data in zstd-compressed CSV
PCAone -c counts.csv.zst -k 10 --scale 2 -S -o counts
Projection requires compatible genome builds and alleles. Relatedness, LD and
HWE require the same samples in the same order as the reference PCA. Analyses
using -P use every reference PC unless -k selects the leading PCs.
Documentation¶
The full documentation is at zilongli.org/PCAone; its
Markdown sources are in docs/.
- Install: binaries, Bioconda, and builds with MKL or OpenBLAS.
- User guide: options, input and output, choosing a PCA method, and plotting SNP loadings and LD decay.
- Small-N, up to a few thousand samples: exact PCA and EM-PCA, projection, selection scans, HWE and inbreeding, relatedness, and ancestry-adjusted LD.
- Biobank analysis, tens of thousands of samples or more: out-of-core PCA, projection, LD pruning and clumping, relatedness, and plotting large cohorts.
- Change log: release history, result changes, and legacy command migration.
Each analysis guide ends with the method details: the model, how PCAone computes it, and how it was checked.
Run PCAone --help for all options, or generate a man page:
Citation¶
Please cite Fast and accurate out-of-core PCA framework for large scale biobank data when using PCAone. For specific analyses, also cite:
- EMU: Large-scale inference of population structure in presence of missingness using PCA.
- PCAngsd: Inferring Population Structure and Admixture Proportions in Low-Depth NGS Data.
- Ancestry-adjusted LD: Measuring linkage disequilibrium and improvement of pruning and clumping in structured populations.
Contributing and acknowledgements¶
Issues and contributions are welcome. PCAone uses Eigen, Spectra, and a BGEN reader adapted from jeremymcrae/bgen; its EMU and PCAngsd implementations build on Jonas Meisner's packages.