This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Filtering specific substitution from a vcf file

Dear All,

Is there an option for filtering specific substitutions only from VCF file using VCFtools or bcftools? I want to extract lines from vcffile that contain A and T in Ref column.

Thanks in advance!

snp

I think you mean A or T, in ref column. @OP

bcftools view -i 'REF="A" | REF="T"' example.vcf.gz or bcftools filter -i 'REF=="A"|REF=="T"' example.vcf.gz

bgzip and tabix (index) example vcf for bcftools processing

1 answer

awk -F '\t' '($0 ~ /^#/ || $4=="A" || $4=="T")' in.vcf > out.vcf

Thanks Pierre! I shall try this.. I wrote a python script to do this but then while executing vcfstats, it throws error mentioning no sample columns in VCF file.

Log in to answer this question.