Change log¶
Legacy command migration¶
LD workflows before v0.8.0¶
The -D/--ld and -B/--binary options and the intermediate .residuals
file have been removed. Compute a reference PCA, then pass its prefix with
-P/--USV while reading the original PLINK or PGEN genotypes:
The old -D/--ld workflow did not standardize sites. Add --scale 0 to the
reference PCA command to reproduce that scaling. See v0.8.0 below for
result changes and compatibility details.
Loadings before v0.8.0¶
-V/--printv has been removed, and PCAone stops if it is given. The .loadings
and .mbim are now written by default, so drop -V/--printv from old commands;
add --no-loadings to skip them.
Projection syntax before v0.4.8¶
Older examples supplied --read-V, --read-S, and --match-bim separately.
Since v0.4.8, -P/--USV accepts the reference prefix for .eigvecs,
.sigvals, .loadings, and .mbim.
Variance explained with --svd 3 before v0.7.0¶
Older examples ran --svd 3 to get the proportion of variance explained,
dividing each eigenvalue by the sum of .eigvals. Up to v0.6.0 --svd 3 ran a
full SVD and wrote every eigenvalue. Since v0.7.0 it writes only the top -k,
so that sum no longer covers all the variance.
Release history¶
v0.9.0¶
Breaking changes
- The
--project-bootstrapfiles (.proj.bootstrap.tsv,.proj.bootstrap.cov.tsvand.proj.bootstrap.eigvecs) haveFIDandIIDcolumns aftersample, so a script that reads their columns by position needs updating. The.eigvecsof--projectis unchanged. --project 3stops with an error when given-m. It ignored-mbefore, and still runs in-core.
New
-mwith--project 1and2streams the target from PLINK or PGEN a block of variants at a time and holds sums per sample instead of theN x Mgenotypes, so a target of any size is projected in one run within-m, without splitting it into batches of samples. The scores and the--project-bootstrapfiles are those of the in-core run up to rounding. On 60,000 samples and 20,000 simulated variants, which need 10 GB in-core,--project 2 -m 2took 8 s on 2 threads and 2 GB. Without-m, they stream within 2 GB;-m 0runs in-core. See Projection at biobank scale.--projectalso writes.eigvecs2: the scores with a#FID IID PC1 ...header and the FID and IID of each sample, as a PCA run writes them.--no-packed(advanced) decodes the genotypes of a BED for--svd 1and2, as before v0.9.0, e.g. to compare.
Faster
- winSVD (
--svd 2, the default) and sSVD (--svd 1) of a PLINK BED compute on its 2-bit calls, in-core and with-m, without decoding them to numbers. In-core the calls take 2 bits a genotype instead of 8 bytes, and both products of each pass add tabulated sums of 4 calls at a time, as--projectdoes. Onexample/plinkthe.eigvecsand.eigvalsare those of v0.8.0 byte for byte, in-core and with-m, and they do not depend on-n. On 1000 Genomes (3,202 samples, 6.84M variants), in-core took 347 s and 177 GB and now takes 24 s and 8.2 GB; with-m 16, 244 s and now 119 s. Onexample/plink(400 x 656,281, 2 threads), 9.6 s and 2.3 GB, now 3.6 s and 0.35 GB. EM-PCA (--emu,--pcangsd),--scale 1to4, IRAM and the exact PCA decode the genotypes as before. See Out-of-core PCA. - The QR of each pass of
--svd 1and2runs over panels of rows on all threads, for every input. It ran on one thread and took as long as a pass over a million variants. The panels have the same height whatever-nis, so the PCs do not depend on it. - The
.mbimof a BED is written from the.bimread at once, on all threads; reading it a line at a time took as long as a pass of winSVD. --project 1and2on PLINK or PGEN hard calls work on the 2-bit calls, without decoding them: the sites are taken 4 at a time and the 256 sums of their loadings for the codes they can have are tabulated, so each sample adds one row per 4 sites. The scores are those of the decoded calls. On 200,000 samples, 98,000 variants and 20 PCs,--project 1takes 2.8 s and--project 24.0 s (11 threads, Apple M3 Pro), against 12 s and 16 s decoding the calls block by block and 11 s for plink2--score; on a shared Xeon E5-2699 v4 (16 threads), 3 to 4.4 s and 5 to 6.7 s, against 37 s and 42 s decoding and 44 to 72 s for plink2. v0.8.0 needed 9 bytes per genotype in-core, 176 GB for this target. See Projection at biobank scale.--project-bootstrapand PGEN dosages still decode the blocks.- Every large text output is formatted on all threads (
-n) and written while the next block is formatted, with the same bytes as before (but a NaN is alwaysnan, never-nan):.loadings,.eigvecs,.mbim, the PCAngsd.cov, the selection scans,.hwe,.ld.gz,.ld.prune.*, the projection bootstrap and the evalAdmix matrices. Writing the.loadingsof 1M sites and 10 PCs took 2.5 s and now takes 0.6 s on one thread, less with more. - The
.loadings,.eigvecsand.mbimof a-P/--USVrun are read in blocks, the next block while this one is parsed on all threads, and the numbers converted exactly withoutstrtod: the same values as before. Reading the.loadingsof 5M sites and 10 PCs took 5.2 s and now takes 1.6 s on one thread, 1.1 s on two.
Fixed
- The
.eigvecs2of a PGEN whose.psamhas no header line had no samples. - LD and
--evaladmixread a value of the-P/--USV.eigvecsthat is not a number, such as theNAof a projected sample, as 0. They now stop with an error naming the row. --project-bootstrapcounted a site drawn several times once per draw towards theKsites a sample needs, so e.g. 2 called sites drawn twice each passed with 4 PCs, and the replicate was solved from a singular system with arbitrary scores. Such a replicate is now NA. Only samples with very few called sites are affected.
The full notes, with measurements, are in
dev/changes-v0.9.0.md.
v0.8.0¶
Breaking changes, with the new commands in Legacy command migration
-D/--ld,-B/--binaryand the.residualsfile are removed. LD (-R,--ld-r2,--clump) reads the PLINK or PGEN genotypes and removes the PCs of a previous run given with-P/--USV. BGEN, BEAGLE and CSV input no longer support LD.-V/--printvis removed: the.loadingsand.mbimare written by default. Use--no-loadingsto skip them.--evaladmixno longer runs a PCA; pass the PCs of a previous run with-P/--USV.- Invalid option values and unsupported combinations stop with an error naming the option,
instead of running on or crashing: e.g.
-k 0,-d 7, more than one input file,--clump-p1above--clump-p2, EM-PCA with--svd 3,--inbreedwith--maf, or-knot below the number of samples and sites. Errors printError: <message>and exit with status 1.
New
- Relatedness:
--evaladmixwrites the kinship of every pair of samples (.kinship,.corres) from the residuals of the PCs, with no admixture run.--evaladmix-ibdadds the IBD sharing probabilitiesk0,k2, which tell parent–offspring from full sibs. - Relatedness at biobank scale:
--evaladmix-kin <cutoff>writes only the pairs above a kinship cutoff (.kin0) and a maximal unrelated set (.unrelated), within the memory set by-m;--evaladmix-unrelatedgives the set its own cutoff. --inbreed 2estimates the inbreeding coefficient of each sample under population structure (.inbred). See HWE and inbreeding.--em-ksets the number of PCs that model the allele frequencies in--emuand--pcangsd, separately from the-kPCs written.- In every analysis that reads a reference with
-P/--USV(LD,--evaladmix,--project,--selection,--inbreed),-kselects the leading PCs, and all of them are used by default, so one reference run serves any smaller number. - BGEN layouts 1 and 2, every compression and bit depth, and phased files are tested, and BGEN input no longer warns that its support is limited.
.sigvalsrecords how the PCA scaled the data, so analyses with-P/--USVput new genotypes on the same scale. A.sigvalsfrom an older version gives a warning.- Out-of-core PCA reads the shuffled variants straight from BED, PGEN and BGEN, so it needs no
extra disk space;
--bed-copywrites a shuffled copy first, which is faster for a large BED on a spinning disk. The next block is read while the current one is used;--no-prefetchturns this off. - Warnings when EM-PCA reaches
--maxiteror the RSVD reaches--maxpwithout converging. PCAonewithout arguments lists common commands, and the option descriptions are shorter; the analyses of a previous PCA and the LD options have their own sections.
Faster
- BGEN is read by all threads: with 20 threads, 15x faster in-core and 7-8x with
-m. --svd 3streams the data into the N x N GRM, in N x N memory instead of N x M (0.11 GB instead of 2.1 GB on 400 x 656,281), and is faster.- The default
--svd 2is about 2x faster,--svd 14x,--emu3x,--pcangsd3x and BEAGLE input up to 30x. - Ancestry-adjusted LD is up to 14x faster for pruning and 38x for
-Rwith-m, and in-core and-mnow run equally fast. - Out-of-core PGEN is up to 3.7x faster when the file is not in the page cache.
Results change
- The sign of each PC from
--svd 1and--svd 2follows the rule of--svd 0and--svd 3: the largest entry of each PC is positive. --seednow fixes every random draw, on every platform and thread count, so the draws differ from earlier versions.- BEAGLE input filters
--maf 0.05by default, as PCAngsd does. --inbreed 1removed far too many sites as out of HWE; it now agrees with PCAngsd.- Ancestry-adjusted LD with
-Pand more than one PC used the wrong subspace, and in-core--clumpused the standard LD; both are fixed. The PCs of a default PCA are standardized, so add--scale 0to the PCA to reproduce the old-D/--ld. --ld-r2follows PLINK--indep-pairwiseand prunes fewer variants;--clumpno longer depends on the row order of the association file.--project 3put targets on the wrong scale and matched BEAGLE alleles the wrong way round.--project-bootstrapunderestimated the uncertainty.--project 2writes NA for a sample with fewer called sites than PCs.--selectionwith--mafwrites one row per input site, NA for the removed ones.- Phased BGEN gave wrong dosages.
- In-core
--svd 0 --emucomputed the final PCs from the imputation of the previous iteration. - CSV with
-mis now transformed as in-core: not at all with the default--scaleor with--scale 0.
Fixes
- Crashes: in-core
--svd 2with fewer than 4,096 sites;--clumpacross chromosomes out-of-core;--inbreedwith PGEN and-m; a missing.mbimwith-P; several malformed CSV files; EM-PCA on very large matrices. --inbreedwith-mused twice the memory given, three times with BEAGLE input: the target and the individual allele frequencies each took a block of-m. They now share it (70 GB instead of 140 GB at-m 64on 2,530 samples and 12 million sites, with the same output).--selection 1and--projectwith-kbelow the reference's number of PCs.- LD
R2of monomorphic variants is 0 instead ofNaN. - The BEAGLE
.eigvecs2has one tab-separated column per PC. --ncvis used when given.
The full notes, with measurements, are in
dev/changes-v0.8.0.md.
v0.7.2¶
- bug fix for out_of_range issue #23
- add
--project-bootstrap - optimization
v0.7.1¶
- bug fix for sign flipping with
--project 3 - bug fix for output mbim with PGEN input and out-of-core
v0.7.0¶
- add support for PLINK2 PGEN input via
--pgen - bug fixes for projection with missing data
- use dosages from
.pgenwhen available, with--hardcallto force hard-call genotypes - add genotype-likelihood aware projection for BEAGLE input via
--project 3 - projection now matches overlapping markers against the reference
.mbimfile and corrects flipped alleles when needed - add genome-wide selection scans via
--selection 1(Galinsky/FastPCA) and--selection 2(pcadapt) --svd 3eigendecomposes the N x N sample GRM when N <= M instead of running a full SVD, which is much faster when N << M..eigvalsnow holds only the top-kvalues- always write
.mbimtogether with.loadingsto support downstream projection, HWE, and selection workflows
v0.6.0¶
- fix HWE! Rework pcangsd and emu plugins
v0.5.4¶
- fix HWE! There is a bug in the previous release for HWE
- add option
--seed
v0.5.3¶
v0.5.2¶
- fix Makefile for bioconda
v0.5.1¶
- bug fix: there is no standardization step for CSV
- feat: more options for scaling data via
--scale - feat: new
--scale-factoroption for adjusting scale
v0.5.0¶
- optimization: reducing the binary size
- fix Makefile: use clang and Accelerate framework on MacOS (faster than any other solutions)
- fix a small bug in FileCSV
v0.4.9¶
- use C+17 standard
- breaking:
--verbosetakes integer value as the level of verbose - new short option:
-f
v0.4.8¶
- HWE test accounting for population structure via
--inbreed 1 - BEAGLE file can work with in-core mode
- PLINK file can work with both in-core and out-of-core mode
- new option
--USVas the prefix of pcaone.eigvecs/.eigvals/.loadigns/.mbimfiles - simplied usage because both
--projectand--inbreedcan work together with--USV - the output
.eigvecs2stores the eigenvectors of the covariance matrix, which also works for BEALGE file with genotype likelihood input. - the
.eigvecs,.eigvals,.loadingsstores the U,S,V matrix for reconstructing the PI matrix
v0.4.7¶
- breaking: rename option
--ld-bimas--match-bim - projection support via
--project - 1: projection by multiplying the loadings with mean imputation for missing genotypes
- 2: projection by solving the least squares system \(Vx=g\). sites with missingness are skipped like smartPCA.
- new options:
--read-U, --read-V, --read-S - can do LD for subset plink file
v0.4.6¶
- give warnings when sample standard deviation is zero.
- checks unknow options in CLI
- fix parsing bim file ending with empty line
- adjust memory estimator for LD
v0.4.5¶
- can do LD prunning and clumpint out-of-core
- add
--ld-bims, --print-r2options
v0.4.4¶
- add
--clump-namesoption
v0.4.3¶
- new output
eigvecs2for plink input - fix ld clumping and sort snps by pvalues
v0.4.2¶
- fix slowness due to the ld logics
- add ld-clump functions
v0.4.1¶
- fix ld windows
- keep sites with higher maf in prune.in
- support standard pruning using
--svd 0when PCAone is compiled with DEBUG=1 - add
--ld-snpsto output pairwise r2 for given SNPs
v0.4.0¶
- add ld pruning
- fix
--mafbeing af not maf
v0.3.9¶
- pre-lease of ld feature
- verbose cli check
v0.3.4¶
- fix the order of SNP loadings for plink input
v0.3.3¶
- breaking change option
--svdfor choosing different SVD methods. default is PCAone algorithm2. - add permuting
BGENfile with multithreading. - add Full SVD support by
--svd 3 - add log transformation support for bulk RNA-seq data by
--scale 1 - add binary file support
- recover the original order for SNP
loadings. - recover the eigenvalues for diploid genotype (0,1,2) data.
v0.3.2¶
- use
tabas separator for output files
v0.3.1¶
- fix makefile for bioconda can't find zlib
v0.3.0¶
- version after first manuscript revision corresponding to the third version manuscript on biorxiv
- fix algorithm2 to use one more omega updates between epoch.
- parameter
--bandchanged to--windows - support
CXXSTDcompiling option to usec++17standard. defaultCXXSTD=c++11 - add
PCAoneR, which implement the idea of PCAone in R but without out-of-core - colorful warning and error message. more checks and warnings.
v0.2.1¶
- bug fix for PCAngsd
v0.2.0¶
- add
--mafoption for SNPs filtering - faster parser for beagle file
- optimization for PCAngsd
- fix printing loadings for PCAoneA blockwise mode
v0.1.9¶
- command line options are re-designed
- upgrade to zstd v1.5.2
- recover the original order of SNPs loading for fancy batch mode
- add
--no-shuffleoption, remove--shuffleoption - default PCAoneF (fancy RSVD) algorithm is chose.
v0.1.8¶
- add -a, –tmp options
- optimize makefile for conda
v0.1.7¶
- two releases
x64andavx2for linux - add
conda install -c bioconda pcaone - upgrade Spectra to v1.0.1
- change oversamples default as max(10, k)
- add logger
v0.1.6¶
- add –cpmed option to support raw counts for scRNAs
- output elapsed I/O time and total wall time
- remove pgenlib
v0.1.5¶
- publish PCAone on mac with
libiomp5support - update documentation
- add –shuffle option
- optimization of FileCsv
v0.1.4¶
- add CSV format support for scRNAs data
- add –printv to print out another eigen vectors
- add -N and -M options
v0.1.3¶
- refactor Halko implementation
- use Arnoldi as default method
- add external/zlib
- upgrade to Eigen 3.4.0
- add structured permutation
v0.1.2¶
- use double instead of float to improve numerical accuracy
- add –no-shuffle, –oversamples, –buffer options
- disable checking padding region of plink bed
- fix denominator too small
- set band range as 4,8,16,32,64
v0.1.1¶
- supports bfile, bgen as input for both batch and blockwise mode
- implement super power iteration for Halko
- automatically permute plink bed file for fast halko
- port jeremymcrae/bgen as bgen parser.
- remove external BGEN v1.3 lib dependence
- use libiomp5 instead of libgomp as multithreading RTL
- fix bugs for PCAngsd algorithm
v0.1.0¶
- supports bfile as input for both batch and blockwise mode
- supports bgen as input for batch mode
- supports both EMU and PCAngsd algorithm
- supports beagle as input for PCAngsd
- external dependecy: Eigen v3.3.8, Spectra v0.9.0, BGEN v1.3
- release two pre-compiled binary for Linux and Mac OSX (libiomp5 required).