Linkage disequilibrium
All of the following calculations only consider founders. If your dataset has a shortage of them, PLINK 1.9 --make-founders may come in handy.
Since two-variant r2 only makes sense for biallelic variants, these collapse multiallelic variants down to most common allele vs. the rest (unless REF-based statistics are explicitly requested, in which case it's REF vs. all ALTs combined).
--indep-pairwise <window size>['kb'] [step size (variant ct)]
<unphased-hardcall-r^2 threshold>
--indep-pairphase <window size>['kb'] [step size (variant ct)]
<phased-hardcall-r^2 threshold>
--indep <window size>['kb'] [step size (variant ct)] <VIF threshold>
--indep-order <mode>
These commands produce a pruned subset of variants that are in approximate linkage equilibrium with each other, writing the IDs to plink2.prune.in (and the IDs of all excluded variants to plink2.prune.out). These files are valid input for --extract/--exclude in a future PLINK run; and, for backward compatibility, they do not affect the set of variants in the current run.
Since the only output of these commands is a pair of variant-ID lists, they now error out when variant IDs are not unique.
--indep-pairwise is the simplest approach, which only considers correlations between unphased-hardcall allele counts. It takes three parameters: a required window size in variant count or kilobase (if the 'kb' modifier is present) units, an optional variant count to shift the window at the end of each step (default 1, and now required to be 1 when a kilobase window is used), and a required r2 threshold. At each step, pairs of variants in the current window with squared correlation greater than the threshold are noted, and variants are greedily pruned from the window until no such pairs remain.
--indep-pairphase is similar, except that it requires all genotypes to be phased (this is a change from PLINK 1.9), and looks at haplotype correlations.
--indep's last parameter is a variance inflation factor (VIF) threshold. At each step, all variants in the current window with VIF exceeding the threshold are removed. See the PLINK 1.07 documentation for some discussion of parameter choices.
Additional notes:
- --indep-order controls the order in which variant pairs are checked within each window.
- '1': Imitate PLINK 1.x.
- '2': Scan backwards within each window (default since 16 May 2023). This is usually faster.
- This operation can be slow, particularly when "--indep-order 1" is specified. You'll usually want to perform e.g. MAF-based filtering beforehand.
- On human data, some reasonable parameter settings are, in order of increasing strictness:
"--indep-pairwise 100kb 0.8"
"--indep-pairwise 200kb 0.5"
"--indep-pairwise 500kb 0.2"
- If you do want to spend the extra compute for dosage-aware pruning, one way to do so is running --clump on the output of --freq.
--indep-preferred <filename>
By default, when given a choice, the variant-pruning commands preferentially keep variants with higher nonmajor allele frequencies. However, if you provide a list of variant IDs to --indep-preferred, all variants in that list are prioritized over all variants outside it. (Allele frequencies will still be used for tiebreaking.)
--r[2]-[un]phased [{square | square0 | triangle | inter-chr}] ['yes-really']
[{zs | bin | bin4}] ['ref-based']
['allow-ambiguous-allele'] ['cols='<column set descriptor>]
--ld-window <max variant ct + 1>
--ld-window-kb <#kb>
--ld-window-cm <#cm>
--ld-window-r2 <min>
--ld-snp <variant ID>
--ld-snps <variant ID(s)/range(s)...>
--ld-snp-list <filename>
--r2-phased computes the textbook haplotype-frequency-based r2, and corresponds to PLINK 1.9 --r2's behavior when the 'd', 'dprime', or 'dprime-signed' modifier was present. --r2-unphased computes the simpler r2 squared-correlation between (unphased) dosage vectors, and corresponds to how PLINK 1.x --r2 behaved without a D'-related modifier. You are now required to explicitly specify which of these r2 statistics you want.
--r-phased and --r-unphased report signed (and of course unsquared) values, with positive sign when the two major (or, when 'ref-based' is specified, REF) alleles are positively correlated with each other.
Dosages are now used when present. (In the diploid case, an unphased dosage of x is interpreted as P(0/0) = 1 - x, P(0/1) = x when x is in 0..1.) Note that you can generate a dosage-free copy of your data with "--make-pgen erase-dosage" when this behavior is unwanted.
Phase information is used when both variants are on the same chromosome.
By default, tabular output is written to plink2.vcor[.zst]. The following filters apply to tabular output:
- --ld-window controls the maximum number of other variants (after generic variant filters) allowed between variant-pairs in the report. All variant-pairs with at least (<--ld-window argument> - 1) variants between them are ineligible. The default setting is infinity (i.e. this filter does nothing unless explicitly specified); this is a change from PLINK 1.x.
- --ld-window-kb controls the maximum kilobase distance. The default setting is 1000, so if you want to look at all same-chromosome variant-pairs, you need to explicitly disable this default with e.g. "--ld-window-kb 9999999". Or if you want to look at inter-chromosomal variant-pairs as well, use --r[2]-[un]phased's 'inter-chr' modifier.
- When centimorgan coordinates are present, --ld-window-cm controls the maximum centimorgan distance. The default setting is infinity.
- --ld-window-r2 controls the minimum r2 for a variant-pair to be included in the report. With a negative setting, 'nan' values are not filtered out. The default setting is 0.2 (for --r-phased and --r-unphased, this means |r|≥sqrt(0.2)).
- You can restrict the first variant in each variant-pair to come from a limited set of variant ID(s). --ld-snp specifies a single ID, --ld-snps accepts one or more variant ranges (same syntax as --snps), and --ld-snp-list specifies a file to load variant IDs from. These flags no longer cause self-comparisons or duplicate entries to appear in the report.
Refer to the file format entry for output details and optional columns (e.g. allele frequency, D').
By default, when multiallelic variants are present, --r2-[un]phased will error out when the 'maj' and 'nonmaj' (or, if 'ref-based' is specified, 'ref' and 'alt') column-sets are absent. Similarly, --r-[un]phased will error out in this sort of case regardless of whether multiallelic variants are present. The 'allow-ambiguous-allele' modifier overrides this behavior.
To request all-pairs matrix output instead, specify a matrix shape ('square', 'square0', 'triangle') and/or encoding ('bin', 'bin4') modifier; these have the same behavior as with --make-rel.
- As with --make-rel and similar commands, if a shape is specified without an encoding, encoding defaults to text; and if an encoding is specified without a shape, shape defaults to square.
- Since there is no header line specifying phased vs. unphased, r vs. r2, or text vs. binary vs. Zstd-compressed-text, this information is embedded in the main matrix filename's extension. ".[un]phased.vcor{1|2}{|.bin|.zst}" summarizes the twelve possibilities.
- A file named <matrix filename without .zst>.vars is also written, containing the matrix's variant ID sequence. (Relatedly, variant IDs are now required to be unique.)
- Since the resulting file can easily be huge, you're required to add the 'yes-really' modifier when requesting an unfiltered (or only-nan-filtered), non-distributed all-pairs computation on more than 400k variants. 'inter-chr' with a nonpositive --ld-window-r2 setting also triggers this sanity check.
With either output type, the computation can be subdivided with --parallel.
23andMe's LDZip software (free for noncommercial use) supports compression of these output files in a manner that allows random access.
--ld <variant ID> <variant ID> ['hwe-midp']
To inspect the relation between a single pair of variants in more detail, you can use the --ld flag, which displays observed and expected (based on MAFs) frequencies of each haplotype, as well as haplotype-based r2 and D'. (The latter two values are calculated in the same manner as they are for --r2-phased.)
When unphased calls are present, and there are multiple biologically possible solutions to the haplotype frequency cubic equation, all are displayed (instead of just the maximum likelihood solution identified by --r[2]-phased), along with HWE exact test statistics.
LD Scores
--ld-score ['zs'] ['multiallelic'] ['cols='<column set descriptor>]
--ld-score-annot <filename>
--ld-score-founders
--ld-score-window <max variant ct radius>
--ld-score-window-kb <max kb radius>
--ld-score-window-cm <max cM radius>
--ld-score computes each variant's LD Score as defined in Bulik-Sullivan et al. (2015) LD Score Regression Distinguishes Confounding from Polygenicity in Genome-Wide Association Studies: the sum of unbiased r2 with every other variant in a window around it, plus 1 for itself. This is the statistic LD Score regression takes as input.
- The unbiased estimator is (r2 - (1-r2)/(n-2)), with n the number of samples the pair has in common. The correction is what makes a pair of unlinked variants contribute zero on average instead of 1/n.
- When nonfounders are present, you must explicitly specify either --ld-score-founders or --nonfounders.
- The default window is a 1 centimorgan radius, so nonzero cM coordinates are required unless --ld-score-window or --ld-score-window-kb is given. Specifying either of those turns the cM default off; to combine them, give --ld-score-window-cm explicitly.
- Haploid chromosomes are skipped, and monomorphic variants are reported as NA. Multiallelic variants are also skipped by default, since the programs that consume ldsc output expect them to have been filtered out; 'multiallelic' keeps them, handled the usual way (major allele taken against all others).
- The variant counts behind the scores are written alongside them, to plink2.ldscore.M (all variants) and plink2.ldscore.M_5_50 (minor allele frequency above 0.05), one value per annotation. LD Score regression needs them to turn a regression coefficient into a heritability.
--ld-score-annot partitions LD Score: given a file with a variant ID column followed by one column per annotation, each window variant contributes its r2 weighted by its value there, and one L2 column is written per annotation, named after it. This is what stratified LD Score regression takes as input. The file must cover every variant being scored; values are usually 0 or 1, but any finite weight works.
--show-tags ['zs'] [<target variant ID file> | 'all']
--list-all
--tag-kb <kbs>
--tag-r2 <val>
--tag-mode2
To help with tag SNP selection, --show-tags determines all variants which have allele count squared correlation ≥ 0.8 with a target variant. This command generates one or two files:
- if the '--list-all' flag or the --show-tags 'all' modifier is specified, a per-target-variant tag report is written to plink2.tags.list. 'all' causes all variants to be target variants, while --list-all restricts the target variant set to those in the file named in the --show-tags parameter.
- when not in 'all' mode, a single list of tags for the entire target variant set is written to plink2.tags. A variant is considered to tag itself here, so this will be a superset of the target variant list unless the latter contains variant IDs missing from the current dataset.
In addition,
- by default, the scan for potential tags is limited to variants within 250 kilobases of the target. This value is adjustable with --tag-kb.
- --tag-r2 allows the minimum tag r2 to be adjusted.
- when not in 'all' mode, --tag-mode2 changes the --show-tags target variant input format to two-column, with IDs in the first column and '0'/'1' values in the second (where target variants are marked by '1's). The .tags output format is also changed to two-column.
- unique variant IDs are required, since the report and the input list are both keyed on them.
- haploid chromosomes are not supported yet, and are an error rather than a silent omission.
--blocks ['no-small-max-span']
--blocks-max-kb <kbs>
--blocks-min-maf <cutoff>
--blocks-strong-lowci <x>
--blocks-strong-highci <x>
--blocks-recomb-highci <x>
--blocks-inform-frac <x>
--blocks estimates haplotype blocks, via Haploview's interpretation of the block definition suggested by Gabriel S et al. (2002) The Structure of Haplotype Blocks in the Human Genome. Each block's variant IDs are written to plink2.blocks, and a longer report with position information is written to plink2.blocks.det.
- Normally, size-2 blocks may not span more than 20kb, and size-3 blocks
are limited to 30kb. The 'no-small-max-span' modifier removes
these limits.
- Only pairs of variants within [--blocks-max-kb argument] kilobases of each other are considered. It is now necessary to explicitly specify this value, since the old default of 200 was frequently too short.
- All variants with MAF < 0.05 are normally ignored by this procedure. Use --blocks-min-maf to adjust this threshold.
- Two variants are normally considered by this procedure to be in "strong LD" if the bottom of the 90% D-prime confidence interval is greater than 0.70, and the top of the confidence interval is at least 0.98. Use --blocks-strong-lowci and --blocks-strong-highci to change these values.
Note that Haploview/PLINK 1.07 has a minor quirk in its handling of the low CI bound: a potential haploblock's outermost variant pair is considered to be in "strong LD" even if the bottom of its D-prime confidence interval is exactly equal to the --blocks-strong-lowci value. To maximize backward compatibility, we have replicated this quirk. Use a lower bound that isn't a perfect multiple of 0.01 (e.g. "--blocks-strong-lowci 0.7005") if you don't want outermost pairs to receive special treatment.
- By default, this procedure treats confidence interval tops smaller than 0.90 as strong evidence for historical recombination; use --blocks-recomb-highci to adjust this threshold.
- Normally, the number of "strong LD" pairs within a haploblock must be more than 0.95 times the total number of informative pairs (i.e. either "strong LD" or 'recombination'). This threshold can be adjusted with --blocks-inform-frac.
The .blocks file is valid input for PLINK 1.07's --hap command. However, the --hap... family of flags has not been reimplemented in PLINK 1.9 or 2.0 due to poor phasing accuracy (and, consequently, inferior haplotype likelihood/frequency estimates) relative to other software. One option for case/control haplotype association analysis is BEAGLE 3.3.2; you can use "--export beagle-[un]phased" to export data.
--bad-ld
PLINK 2 cannot estimate LD effectively when very few founders are present, so it normally errors out when there are less than 50. If you can't solve the problem with --make-founders, you can use --bad-ld as a last resort to force PLINK 2 to proceed.
Sample-distance and similarity matrices >>
|