This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How do I use vcftools to filter by variant ID OR variant position?

I'm having a problem obtaining a recoded vcf which contains variants with their IDs in a "snp file" OR their positions in a "position file." The following gives only variants with their IDs in the "snp file" AND their positions in the "position file."

vcftools --vcf <input vcf file> --snps <variant IDs file> --positions <variant positions file> --recode --out <output vcf file>

Is there any way that I can obtain that which I desire without having to do each separately, concatenating, and then getting rid of duplicates?

Thanks in advance.

vcftools

Please use the format bar to indicate code. I did it for you this time.

bar

1 answer

not vcftools

using vcffilterjdk: http://lindenb.github.io/jvarkit/VcfFilterJdk.html

Pierre,

I'd definitely like this in an easy-to-use tool like vcftools or bcftools, but what you've provided seems to work. Thank you for posting this. I will interrogate further later, however...

vcftools --vcf <input vcf file> --snps <variant IDs file> --recode --out <output vcf file>

gives 1695 variants

vcftools --vcf <input vcf file> --positions <variant positions file> --recode --out <output vcf file>

gives 483 variants

vcftools --vcf <input vcf file> --snps <variant IDs file> --positions <variant positions file> --recode --out <output vcf file>

gives 60 variants

java -jar dist/vcffilterjdk.jar --body -f biostar347173.code <input vcf file> > <output vcf file>

gives 2118 variants

1695 + 483 - 60 = 2118 = Yay!!

If an answer was helpful you should upvote it, if the answer resolved your question you should mark it as accepted.

Upvote|Bookmark|Accept

Pierre,

I just realized that you are the creator of jvarkit. Thank you for your hard work in getting that code going and making it freely available and open source.

Cheers, James

Log in to answer this question.