Skip to contents

A window of window variants slides along the variant index in increments of step. Within the current window the squared Pearson correlation of genotype allele counts is computed for every pair of still-kept variants, and pairs with r-squared above the threshold are greedily pruned until no such pair remains (PLINK 1.9 LD documentation; phase is not considered).

Usage

Ldprun(G, window = 50L, step = 5L, r2_threshold = 0.5)

Arguments

G

Genotype matrix, individuals by variants, coded 0/1/2; any other value is treated as missing (pairwise deletion within a pair, per-variant deletion for MAF).

window

Window size in variant count.

step

Window shift in variant count.

r2_threshold

Pairwise r-squared above which one member of a pair is pruned.

Value

List with keep (1-based kept variant indices), drop (removed), estimate (number kept), maf, n_variants, method.

Details

The published description leaves the pair-member choice unspecified, so this implementation pins a deterministic rule, identical in both language arms: offending pairs are scanned in row-major index order (i ascending, then j), and of the first offending pair the member with the LOWER minor allele frequency is removed (the later variant on ties). Removal is permanent across subsequent windows.

References

Purcell, S., Neale, B., et al. (2007). PLINK: a tool set for whole-genome association and population-based linkage analyses. American Journal of Human Genetics 81(3), 559-575 (sec. Linkage disequilibrium based SNP pruning). PLINK 1.9 LD documentation, indep-pairwise, cog-genomics.org/plink/1.9/ld.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
Ldprun(V)
#> $estimate
#> [1] 1
#> 
#> $keep
#> [1] 1
#> 
#> $drop
#> integer(0)
#> 
#> $maf
#> [1] 0.25
#> 
#> $n_variants
#> [1] 1
#> 
#> $method
#> [1] "LD pruning, PLINK --indep-pairwise (lower-MAF member dropped)"
#>