Replace heterozygous GT to missing in vcf file using bcftools
1
0
Entering edit mode
11 months ago
User000 ▴ 460

Hello,

I would like to replace all het GT 0/1 or 1/0to missing data ./. ? Is there any way to do it with bcftools? If no how could I do it.

bcftools vcf • 626 views
1
Entering edit mode
11 months ago
microfuge ★ 1.9k

Not tested it but this comes to mind bcftools filter -S . -e 'GT=="het"' yourFile.vcf.gz

0
Entering edit mode

You mean -i 'GT=="het"' and not -e. OP wants to set all HETs (not all non-HETs) to ./..

0
Entering edit mode

-i doesnt work, -e seems to be working, is it normal?

0
Entering edit mode

Sorry, I'd made a typo that led to a formatting error - I've edited that now. What is the full command you're using?

0
Entering edit mode

Hi, I'm using this command line: /DATA/Tools/bcftools-1.10.2/bcftools filter -S . -e 'GT=="het"' {input.f1} > {output.f2} It seems to be working...it that OK? because I expect -e to exclude, no? Should I run something like /DATA/Tools/bcftools-1.10.2/bcftools filter -i 'GT=="het"' {input.f1} > {output.f2} ?

0
Entering edit mode

If the command you're using works and gives you what you expect, then you're all set. The thing to fix is the gap in my understanding - either I'm misunderstanding how bcftools functions or I'm misunderstanding your requirement. Either way, glad it worked for you.

I've moved micofuge's comment to an answer. Go ahead and accept it (using the green check mark on the left side panel).