Question: bcftools merge: does it only merge overlapping variants or all
2
gravatar for isabel.hostettler.14
2.3 years ago by
isabel.hostettler.1420 wrote:

Hi there,

I'm not sure about the following: if you use bcftools merge to merge vcf.gz files does it merge the overlapping variants only or does it also merge variants that are present in one dataset but not in the other?

Thanks!

snp bcftools merging • 2.2k views
ADD COMMENTlink modified 2.3 years ago • written 2.3 years ago by isabel.hostettler.1420

Thank you very much for the answer. Is there an option to only merge the overlapping variants from the beginning?

ADD REPLYlink written 2.3 years ago by isabel.hostettler.1420

Hello again,

please use the ADD REPLY button below the post you like to reply to.

I'm not aware of such in option. If you can make sure, that in your vcf file you like to merge, are no genotypes ./., you could filter out those sites after merging.

$ bcftools merge in1.vcf.gz in2.vcf.gz|bcftools filter -e 'GT="./."' > out.vcf

fin swimmer

ADD REPLYlink written 2.3 years ago by finswimmer14k

Okay thanks. But if I do it that way it will still be present in one part of the dataset (for the ones it was present before merging) or will it the variant be remove from the whole dataset?

Isabel

ADD REPLYlink written 2.3 years ago by isabel.hostettler.1420
1

Your initial datasets will be keepd untouched.

If you are interested to find out which variants are in all your vcf files, without merging them than the term you are looking for is intersect.

Have a look at the man page of bcftools isec for some examples. So e.g. this might be a useful command:

# Extract and write records from A shared by both A and B using exact allele match
   bcftools isec A.vcf.gz B.vcf.gz -p dir -n =2 -w 1

fin swimmer

ADD REPLYlink written 2.3 years ago by finswimmer14k
1
gravatar for finswimmer
2.3 years ago by
finswimmer14k
Germany
finswimmer14k wrote:

Hello,

It also merges variants that are present in one file but not in the other. In that case the genotype is set to ./. by default. You can set it to 0/0 by invoking the --missing-to-ref parameter.

fin swimmer

ADD COMMENTlink modified 2.3 years ago by zx87549.9k • written 2.3 years ago by finswimmer14k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2308 users visited in the last hour
_