how to use unix tools to convert VCF genotypes like '1|1' to this '2'
I want every row to be an id and every column a genotype for a different sample:
id1 0 2 1
id2 0 2 1
I know I can do this in python, but trying to get better with unix because the tools are usually faster
bcftools query -f '%ID[\t%GT]\n' my_vcf.vcf | awk -F "|" '{for(i=1; i<=NF; i++) { print $i+$i }}'
I think this is almost there by I almost there but obviously I'm off. Any hints are greatly appreciated thank you.
• 1,544 views
•
link
1 answer
cat 1.vcf
id1 0|0 1|1 1|0
id2 0|0 1|1 1|0
sed -e 's/0|0/0/' -e 's/1|1/2/' -e 's/1|0/1/' -e 's/0|1/1/' 1.vcf
id1 0 2 1
id2 0 2 1
• 0 views
•
link
Log in to answer this question.
How is your output look like? I think you should have two for loops, the first loops the samples, and for each sample loop the GT
just this command
bcftools query -f '%ID[\t%GT]\n' my_vcf.vcfgives me this:I hope to get this with awk or similar:
right now i just get this