PCAngsd: Difference between revisions
No edit summary |
No edit summary |
||
Line 41: | Line 41: | ||
<pre> | <pre> | ||
./angsd -GL | ./angsd -GL 2 -out data -nThreads 10 -doGlf 2 -doMajorMinor 1 -doMaf 1 -SNP_pval 1e-6 -bam bam.filelist | ||
</pre> | </pre> | ||
Revision as of 12:05, 23 August 2019
This page contains information about PCAngsd, which estimates the covariance matrix for low-depth NGS data in an iterative procedure based on genotype likelihoods and is able to perform multiple population genetic analyses in structured/heterogeneous populations. Based on iterative population structure inference, PCAngsd estimates individual allele frequencies. These individual allele frequencies can be used in various analyses to account for population structure in such a way that PCAngsd can perform PCA (estimate covariance matrix), call genotypes, estimate individual admixture proportions, estimate inbreeding coefficients (per-site and per-individual) and perform genomic selection scan using principal components. The entire program is written in Python and is multithreaded to take advantage of several CPUs.
Since version 0.98, PCAngsd has been re-written in Cython for computational bottlenecks and parallelization.
Download
The program can be downloaded from Github: https://github.com/Rosemeis/pcangsd
git clone https://github.com/Rosemeis/pcangsd.git
See github for more information regarding installation. PCAngsd should work on all platforms meeting the requirements but server-side usage is highly recommended. Installation has only been tested on Linux systems.
Quick start
# See all options in PCAngsd python pcangsd.py -h # Only estimate covariance matrix using 10 threads python pcangsd.py -beagle data.beagle.gz -o test -threads 10 # Estimate covariance matrix and individual admixture proportions python pcangsd.py -beagle data.beagle.gz -admix -o test -threads 10 # Estimate covariance matrix and inbreeding coefficients python pcangsd.py -beagle data.beagle.gz -inbreed 1 -o test -threads 10 # Estimate covariance matrix and perform selection scan python pcangsd.py -beagle data.beagle.gz -selection -o test -threads 10
Input
The only input PCAngsd needs and accepts are genotype likelihoods in Beagle format. ANGSD can be easily be used to compute genotype likelihoods and output them in the required Beagle format.
./angsd -GL 2 -out data -nThreads 10 -doGlf 2 -doMajorMinor 1 -doMaf 1 -SNP_pval 1e-6 -bam bam.filelist
See ANGSD for more information on how to compute the genotype likelihoods and call SNPs.
Using PCAngsd
All the different options in PCAngsd are listed here. PCAngsd will always compute and output the covariance matrix, where it uses principal components to estimate individual allele frequencies in an iterative procedure. The estimated individual allele frequencies will then be used in any of the other specified options of PCAngsd.
Estimation of individual allele frequencies
- -beagle [Beagle filename]
Input file of genotype likelihoods in Beagle format (.beagle.gz).
- -plink [Prefix for binary PLINK files]
Path to PLINK files using their prefix (.bed, .bim, .fam).
- -plink_error [float]
Incorporate error model for PLINK genotypes.
- -minMaf [float]
Minimum minor allele frequency threshold. (Default: 0.05)
- -iter [int]
Maximum number of iterations for estimation of individual allele frequencies (Default: 100).
- -tole [float]
Tolerance value for update in estimation of individual allele frequencies (Default: 1e-5).
- -maf_iter [int]
Maximum number of EM iterations for computing the population allele frequencies (Default: 100).
- -maf_tole [float]
Tolerance value in EM algorithm for population allele frequencies estimation (Default: 1e-4).
- -e [int]
Manually select the number of eigenvalues to use in the modelling of individual allele frequencies (Default: Automatically tested using MAP test).
- -o [prefix]
Set the prefix for all output files created by PCAngsd (Default: "pcangsd").
- -indf_save
Choose to save estimated individual allele frequencies (Binary). Numpy format (.npy).
- -dosage_save
Choose to save estimated genotype dosages (Binary). Numpy format (.npy).
- -sites_save
Choose to save the marker IDs after performing filtering using population allele frequencies. Useful for especially selection scans and per-site inbreeding coefficients.
- -post_save
Choose to save the posterior genotype probabilities. Beagle format (.beagle).
- -threads [int]
Specify the number of thread(s) to use (Default: 1).
Call genotypes
Genotypes can be called from posterior genotype probabilities incorporating the individual allele frequencies as prior information.
- -geno [float]
Call genotypes with defined threshold (Binary). Numpy format (.npy).
- -genoInbreed [float]
Call genotypes with defined threshold also taking inbreeding into account. -inbreed [int] is required, since individual inbreeding coefficients must have been estimated prior to calling genotypes using that information (Binary). Numpy format (.npy).
Admixture
Individual admixture proportions and population-specific allele frequencies can be estimated based on assuming K ancestral populations using an accelerated mini-batch NMF method.
- -admix
Toggles admixture estimations. Individual ancestry proportions are saved (Binary). Numpy format (.npy).
- -admix_alpha [float-list]
Specify alpha (sparseness regularization parameter). Can be specified as a sequence to try several alpha's in a single run (Default: 0).
- -admix_auto [float]
Enable automatic search for optimal alpha using likelihood measure, by giving soft upper search bound of alpha.
- -admix_seed [int-list]
Specify seed for random initializations of factor matrices in admixture estimations. Can be specified as a sequence to try several different seeds in a single run.
- -admix_K [int]
Not recommended. Manually specify the number of ancestral populations to use in admixture estimations (overrides number chosen from -e). Structure explained by individual allele frequencies may therefore not reflect the manually chosen K. It is recommended to adjust -e instead of -admix_K.
- -admix_iter [int]
Maximum number of iterations for admixture estimations using NMF. (Default: 200)
- -admix_tole [float]
Tolerance value for update in admixture estimations using NMF. (Default: 1e-5)
- -admix_batch [int]
Specify the number of batches to use in NMF method. (Default: 10)
- -admix_save
Choose to save the population-specific allele frequencies (Binary). Numpy format (.npy).
Inbreeding
Per-individual inbreeding coefficients incorporating population structure can be computed using three different methods. However, -inbreed 1 is recommended for low depth cases.
- -inbreed 1
Simple estimator computed by an EM algorithm. Allows for F-values between -1 and 1. Based on ngsF.
- -inbreed 2
A maximum likelihood estimator also computed by an EM algorithm. Only allows for F-values between 0 and 1. Based on [1].
- -inbreed 3
Estimator using an estimated kinship matrix. Allows for F-values between -1 and 1. Based on PC-Relate.
- -inbreed_iter [int]
Maximum number of iterations for the EM algorithm methods. (Default: 200)
- -inbreed_tole [float]
Tolerance value for the EM algorithms for inbreeding coefficients estimation. (Default: 1e-4)
Per-site inbreeding coefficients incorporating population structure alongside likehood ratio tests for HWE can be computed as follows:
- -inbreedSites
Use likelihood ratio tests (.lrt.sites.gz) generated from -inbreedSites to filter out variable sites using a given threshold for HWE test p-value:
- -hwe [LRT filename]
- -hwe_tole [float]
Tolerance value for HWE test. (Default: 1e-6)
Selection
A genome selection scan can be computed based on posterior expectations of the genotypes (genotype dosages):
- -selection
Using an extended model of FastPCA. Performs a genome selection scan along all significant PCs. Outputs the selection statistics and must be converted to p-values by user. Each column reflect the selection statistics along a tested PC and they are χ²-distributed with 1 degree of freedom.
Relatedness
Estimate kinship matrix based on method Based on PC-Relate:
- -kinship
Automatically estimated if -inbreed 3 has been selected.
Remove related individuals based on kinhsip matrix of previous run:
- -relate [Kinship filename]
- -relate_tole [float]
Threshold for kinship coefficients for removing individuals (Default: 0.0625).
Citation
Our methods for inferring population structure have been published in GENETICS: Inferring Population Structure and Admixture Proportions in Low Depth NGS Data
Our method for estimating per-site inbreeding sites and testing for HWE has been published in Molecular Ecology Resources: Testing for Hardy‐Weinberg Equilibrium in Structured Populations using Genotype or Low‐Depth NGS Data