This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to get the number of distinct variants genotyped from VCF or bed/bim files (GWAS)?

Hi,

How can I get the number of distinct variants genotyped from VCF or bed/bim files?

The reason why I want to do this is to compare the number of gentoyped variants of different batches but the same array.

Thanks!

plink bed gwas vcf

2 answers

See bcftools for great tools to manipulate vcf files.

In bash, you can simply try :

grep -v "#" vcf_file.vcf | cut -f3 | sort | uniq | wc -l 

If vcf file is gzipped:

zcat vcf_file.vcf.gz | grep -v "#" | cut -f3 | sort | uniq | wc -l 

is the file is indexed

bcftools index -s indexed.vcf.gz | cut -f3 | paste -sd '+' |bc

if the file isn't indexed

bcftools query -f '.' file.vcf.gz |wc -c

Log in to answer this question.