2
$\begingroup$

I need to mask all sites in a vcf file flagged by the 1000 Genomes Project as being unfit for population genetic analyses. The sites for all chromosomes are available at:

1000Genomes masked sites

From above mentioned link you can get both bed files and Fasta files.

I wanted to mask all sites using VCFtools but VCFtools is not longer being updated and therefore, can't me used on the my vcf file because you can only VCFtools upto VCF file format v.2. And file format for my file is v.3. Can someone suggest another tool that I can use. Insights will be appreciated.

$\endgroup$

3 Answers 3

2
$\begingroup$

I've tried many ways to do this with bcftools but don't think it's possible to exclude a bed file. What you want is

bedtools intersect -v -a sample.vcf -b mask.bed -wa -header

The -v option gives you only the parts of file a that are not in file b. -wa only keeps entries from file a, and -header preserves the header from file a.

$\endgroup$
1
$\begingroup$

If you are familiar with Python, check out the pyvcf.VcfFrame.filter_bed() method I wrote:

from fuc import pyvcf
vf = pyvcf.VcfFrame.from_file('your_vcf.vcf')
filtered_vf = vf.filter_bed('your_bed.bed', opposite=True)
filtered_vf.to_file('filtered.vcf')
$\endgroup$
0
$\begingroup$

Have a look at BCFtools, which I think does most of the stuff that VCFtools does. I notice there's a --mask option in BCFtools consensus, which may do what you want:

-m, --mask FILE
 BED file or TAB file with regions to be replaced with N
 (the default) or as specified by the next --mask-with
 option. See discussion of --regions-file in Common
 Options for file format details
$\endgroup$
2
  • $\begingroup$ So just to make sure that I am using the correct command. It'll be: bcftools consensus --mask A.fa A.vcf.gz > masked_file.vcf. Is this correct? $\endgroup$
    – John
    Commented Jun 1, 2021 at 8:32
  • $\begingroup$ @John Sorry, I don't know anything more than what I've read; I have no experience with using masking in BCFtools or VCFtools. Try it and see if it works! $\endgroup$
    – gringer
    Commented Jun 1, 2021 at 13:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.