This doesn't quite work in regards to the actual alleles if some are phased and some aren't (because they are rare).
This worked:
bcftools query -f '%ID %CHROM %POS[ %TGT]\n' ../131.vcf | tr "|" " " | tr "/" " " | less -S
I have a VCF per individual.
I'd like to take it, and convert it to the following format so that I have the alleles of the individual in the last two columns:
rsid chr pos ref alt
rs102 chr1 34 A G
Any package that does this already?
For REF and ALT in the last two columns:
bcftools query -f '%ID %CHROM %POS %REF %ALT\n' input.vcf
For the actual alleles of the individual in the last two columns:
bcftools query -f '%ID %CHROM %POS[ %TGT]\n' input.vcf | tr "/" " "
This doesn't quite work in regards to the actual alleles if some are phased and some aren't (because they are rare).
This worked:
bcftools query -f '%ID %CHROM %POS[ %TGT]\n' ../131.vcf | tr "|" " " | tr "/" " " | less -S
Then replace the tr command at the end with
tr "/|" " "
awk '! /\#/' file.vcf | awk -F '\t' '{print $3"\t"$1"\t"$2"\t"$4"\t"$5}'
No, This doesn't handle more than biallelic SNPs.
GATK VariantsToTable https://www.broadinstitute.org/gatk/blog?id=7089
or my tool BioAlcidae see Taking genotypes out of a vcf file
Log in to answer this question.