Entering edit mode
6.0 years ago
Dave Carlson
★
2.1k
Hi Biostars,
Like the title suggests, I have a VCF file and I would like to take every heterozygous position in it and randomly select one of the two alleles to save to a new file. Is there an existing tool that will do this? So far in my searching, I have not found one. Or would I be better off writing my own script to do this?
Thanks for any suggestions!
Hello,
could you please provide an example of your desired output?
fin swimmer
Hi fin swimmer, sorry for the delayed reply. After seeing your question, I realized I wasn't sure what exactly the best option for the output would be. I think maybe turning the heterozygous variant into a homozygous site (either ref or variant) would be good.
So in other words,I would like to take each heterozygous site in my VCF:
And then randomly set the genotype to be homozygous reference or homozygous variant. The result would be either:
Or:
Does that make sense? Thanks! Dave
If this makes sense must you know. You should tell us more about why you want to do this.
bcftools
provide a plugin calledsetGT
which can set the genotypes based on criteria. But it not randomly set it to hom ref or hom alt. What should happen to your already existing homozygous variants? Should they be included in the new output file?