The minor allele frequency and missing rate for each SNP passed in
snp.id
are calculated over all the samples in sample.id
. Four methods can be used to calculate linkage disequilibrium values:
"composite" for LD composite measure, "r" for R coefficient (by EM algorithm
assuming HWE, it could be negative), "dprime" for D', and "corr" for
correlation coefficient. The method "corr" is equivalent to "composite",
when SNP genotypes are coded as: 0 -- BB, 1 -- AB, 2 -- AA. The argument
ld.threshold
is the absolute value of measurement.
It is useful to generate a pruned subset of SNPs that are in approximate
linkage equilibrium with each other. The function snpgdsLDpruning
recursively removes SNPs within a sliding window based on the pairwise
genotypic correlation. SNP pruning is conducted chromosome by chromosome,
since SNPs in a chromosome can be considered to be independent with the other
chromosomes.
The pruning algorithm on a chromosome is described as follows (n is
the total number of SNPs on that chromosome):
1) Randomly select a starting position i, and let the current SNP set
S = { i };
2) For each right position j from i+1 to n: if any LD between j and k is
greater than ld.threshold
, where k belongs to S, and both of j and k
are in the sliding window, then skip j; otherwise, let S be S + { j };
3) For each left position j from i-1 to 1: if any LD between j and k is
greater than ld.threshold
, where k belongs to S, and both of j and k
are in the sliding window, then skip j; otherwise, let S be S + { j };
4) Output S, the final selection of SNPs.