This is a test version of Biostars. For the public version, visit https://www.biostars.org.
extract DS field from a genotype file

Hello,

I am trying to extract DS field from my vcf files. But it's giving me two values. This is my original vcf file:

22      20012563        22:20000086:T:C T       C       .       PASS    AF=0.00289;MAF=0.00289;R2=1;ER2=0.83285;TYPED   GT:DS:HDS:GP    0|0:0:0,0:1,0,0 0|0:0:0,0:1,0,0 0|0:0:0,0:1,0,0 0|0:0:0,0:1,0,0 0|0:0:0,0:1,0,0 0|0:0:0,0:1,0,0 

This is the command that I used:

bcftools +dosage chr22_dosage.filtered.vcf.gz > output2.tsv

This is the final output file being generated.

22      20012563        T       C       0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0     0.0
     0.0     0.0     0.0     0.0     0.0  

Generally the final output file should only have 0,1 or 2 as values and not 1.0,2.0, 0.0 Can anyone help me out with this and tell me if I am doing something wrong.

Thank you

vcf bcftools genotype

1 answer

The genotype dosage is a floating-point formatted value between 0 and 2; and therefore should not only have integer-valued 0, 1, and 2 as outputs. Imputation may generate values such as 1.8 or 0.9; and thus the entire field is float formatted. If you want to convert them to an integer representation where possible, you can post-process the file with sed to do so.

Log in to answer this question.