This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bcftools to remove non-variants sites

Dear all,

I am used to using vcftools to remove non-variants sites. The command I used:

vcftools --vcf input.vcf --mac 1 --recode --out input.mac

However, I cannot find the same command in bcftools.

I tried

bcftools view -m2 -M2 -v snps input.vcf

and

bcftools view --min-ac=1 input.vcf

All these commands keep more variants then I need, for example, the snp with all alternative genotypes 1/1.

However, I am able to get correct results using below command:

bcftools view --min-ac=1 -Q 0.9999 input.vcf

Any better suggestions?

bcftools snp vcftools vcf filter

Hi, I've noticed that there seems to be a discrepancy between bcftools and vcftools when it comes to filtering out non-variant sites. I have a site that includes multiple alleles, with AC=27, 0, 19... vcftools --mac 1 will remove this site, whereas bcftools -c 1 will not.

vcftools --gzvcf xxx.vcf.gz --mac 1 --recode --recode-INFO-all --stdout | bgzip -c >xxx.mac1.vcf.gz
bcftools view -c 1 xxx.vcf.gz -Oz -o xxx.mac1.retry.bcftools.vcf.gz

xxx.vcf.gz: 713639 sites
xxx.mac1.vcf.gz: 129047 sites
xxx.mac1.retry.bcftools.vcf.gz: 161391 sites

Only the result of using bcftools can get the right vcf files.

vcftools is not actively maintained (last update was in 2018) and can thus be considered deprecated. You should use bcftools instead.

1 answer

I find out my answer:

bcftools view -c 1 -c 1:nonmajor test.vcf
#or
bcftools view -i "MAC >=1" test.vcf  #make sure you have only biallelic sites
#or
bcftools filter -e "MAC == 0" test.vcf #make sure you have only biallelic sites

However, if your %INFO tags is wrong, bcftools will produce error results.

Log in to answer this question.