Has anyone ever successfully specified window size along the genome for linkage disequilibrium calculations using vcftools, and if so, which version did you use and where did you download it from? The forums say that this is possible in "version 4 and above". I can't find any downloads anywhere whose version numbers start above "1". The most recent version available on Github is VCFtools 0.1.17, and this does not allow me to do this.
Here's the line of code (as specified in the vcftools manual):
That is [possibly] because VCFtools is virtually out of use. It has been superseded by BCFtools for many years, at this stage.
You can do the same with the BCFtools 'prune' plugin:
bcftools +prune
About: Prune sites by missingness or linkage disequilibrium.
Usage: bcftools +prune [Options]
Plugin options:
--AF-tag STR use this tag with -n to determine allele frequency
-a, --annotate-info STR add INFO/STR_POS and STR_R2 annotation: an upstream site with the biggest r2 value
-e, --exclude EXPR exclude sites for which the expression is true
-f, --set-filter STR annotate FILTER column with STR instead of discarding the site
-i, --include EXPR include only sites for which the expression is true
-l, --max-LD R2 remove sites with r2 bigger than R2 within within the -w window
-n, --nsites-per-win N keep at most N sites in the -w window, removing sites with small AF first
-o, --output FILE write output to the FILE [standard output]
-O, --output-type b|u|z|v b: compressed BCF, u: uncompressed BCF, z: compressed VCF, v: uncompressed VCF [v]
--randomize-missing replace missing data with randomly assigned genotype based on site's allele frequency
-r, --regions REGION restrict to comma-separated list of regions
-R, --regions-file FILE restrict to regions listed in a file
-t, --targets REGION similar to -r but streams rather than index-jumps
-T, --targets-file FILE similar to -R but streams rather than index-jumps
-w, --window INT[bp|kb] the window size of INT sites/bp/kb for the -n/-l options [100kb]
Examples:
# Discard records with r2 bigger than 0.6 in a window of 1000 sites
bcftools +prune -l 0.6 -w 1000 input.bcf -Ob -o output.bcf
# Set FILTER (but do not discard) records with r2 bigger than 0.4 in the default window of 100kb
bcftools +prune -l 0.4 -f MAX_R2 input.bcf -Ob -o output.bcf
# Annotate INFO field of all records with maximum r2 in a window of 1000 sites
bcftools +prune -l 0.6 -w 1000 -f MAX_R2 input.bcf -Ob -o output.bcf
# Discard records with r2 bigger than 0.6, first removing records with more than 2% of genotypes missing
bcftools +prune -l 0.6 -e'F_MISSING>=0.02' input.bcf -Ob -o output.bcf
Thank you very much!!! This is super helpful!