Question: VCF to genotype file of specific format
0
gravatar for David.shaw
3.5 years ago by
David.shaw10
European Union
David.shaw10 wrote:

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?

bash genotypes awk vcf • 1.7k views
ADD COMMENTlink modified 3.5 years ago by Shane McCarthy320 • written 3.5 years ago by David.shaw10
3
gravatar for Shane McCarthy
3.5 years ago by
Cambridge, Cambridgeshire
Shane McCarthy320 wrote:

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 "/" " "
ADD COMMENTlink written 3.5 years ago by Shane McCarthy320

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

ADD REPLYlink modified 3.5 years ago • written 3.5 years ago by David.shaw10

Then replace the tr command at the end with

tr "/|" " "
ADD REPLYlink written 3.5 years ago by Shane McCarthy320
0
gravatar for Vivek
3.5 years ago by
Vivek2.3k
Denmark
Vivek2.3k wrote:
awk '! /\#/' file.vcf | awk -F '\t' '{print $3"\t"$1"\t"$2"\t"$4"\t"$5}'
ADD COMMENTlink written 3.5 years ago by Vivek2.3k

No, This doesn't handle more than biallelic SNPs.

ADD REPLYlink written 3.5 years ago by David.shaw10
0
gravatar for Pierre Lindenbaum
3.5 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum122k wrote:

GATK VariantsToTable https://www.broadinstitute.org/gatk/blog?id=7089

or my tool BioAlcidae see Taking genotypes out of a vcf file

ADD COMMENTlink written 3.5 years ago by Pierre Lindenbaum122k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 539 users visited in the last hour