Merge vcfs and retain only specific regions
0
0
Entering edit mode
21 months ago
Whirlingdaf ▴ 60

I would like to merge two vcf files, one with a more limited list of SNPs/regions than the other. The trick being that I would like to merge these two files while only retaining SNPs within regions from the more limited vcf. How would you recommend accomplishing this merge successfully?

Thus far I have worked tried merging with bcftools, but have not found a way to limit the regions to those only included in one vcf:

bcftools merge Pop_filtered.bg.vcf.gz Pop_filtered2.bg.vcf.gz --output-type z --output bcftools_merged.vcf.gz -m both --threads 6
SNPs vcf • 1.6k views
ADD COMMENT
0
Entering edit mode

EDIT; Thanks for adding in what you've tried with bcftools.

What have you tried? Have you read through the bcftools manual?

ADD REPLY
1
Entering edit mode

Ah, yes, thank you, I should have included this and just edited the original post to include more detail. I have merged them with bcftools, however I have not found an option to only merge by locations within one vcf file. Perhaps there is a bocftools command that I am missing?

ADD REPLY
0
Entering edit mode

Change your approach slightly - merge and then locus-filter unless you use a locus filter while merging (you can)

ADD REPLY
0
Entering edit mode

Ah, so merge and then perform a region specific filter utilizing the old vcf? Could you recommend how to do this in bcftools? Would it look something like:

bcftools bcftools_merged.vcf.gz -R Pop_filtered.bg.vcf.gz --output-type z --output filtered_bcftools_merged.vcf.gz -m both --threads 6
ADD REPLY
0
Entering edit mode

Why are you using merge with just one file? merge works on multiple input files. The manual also mentions ways to restrict yourself to the exact word you use ("region"). Have you tried any of those options?

ADD REPLY
0
Entering edit mode

Perhaps I got confused in the wording of the manual, but if I am understanding your suggestion, something like this would filter by regions in the Pop_filtered.bg.vcf.gz file?

bcftools merge Pop_filtered.bg.vcf.gz Pop_filtered_2.vcf.gz -R Pop_filtered.bg.vcf.gz --output-type z --output bcftools_merged.vcf.gz -m both --threads 6
ADD REPLY
0
Entering edit mode

You've nailed the filtering part and the merge part in this command. This should theoretically work. Let me know if you run into any problems.

ADD REPLY
0
Entering edit mode

Thanks so much, I will give it a try!

ADD REPLY

Login before adding your answer.

Traffic: 2144 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6