Should be
bcftools query -H -f '%FILTER[\t%GT\t%DP]\n' {input} -o {outputname}
This includes header but, for me, also numbers before the names:
#[1]FILTER [2]GT [3]DP
Hello,
I have a vcf file and I extract only some columns like FILTER, and GT and DP values.
bcftools query -f '%FILTER[\t%GT\t%DP]\n' {input} > {output}
This gives me an output without a header, is it possible to add a tab delimited header like FILTER GT DP?
FILTER GT DP
PASS 1/1 89
PASS 0/1 78
I found an easier way:
bcftools query -H -f '%FILTER[\t%GT\t%DP]\n' {output} -o {output}
Should be
bcftools query -H -f '%FILTER[\t%GT\t%DP]\n' {input} -o {outputname}
This includes header but, for me, also numbers before the names:
#[1]FILTER [2]GT [3]DP
(bcftools query -l in.vcf | awk 'BEGIN{printf("FILTER");} {printf("\t%s_GT\t%s_DP",$1,$1);} END{printf("\n");}' && bcftools query -f '%FILTER[\t%GT\t%DP]\n' in.vcf ) > out.tsv
thanks a lot, this gives me an error:
IndexError: list index out of range
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 140, in run_jobs
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 441, in run
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 230, in _run
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 156, in _run
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 162, in printjob
I'ts unrelated to your original problem. Looks like a snakemake error. See if awk statements need to be escaped.
NameError: The name 'printf("FILTER");' is unknown in this context. Please make sure that you defined that variable. Also note that braces not used for variable access have to be escaped by repeating them, i.e. {{print $1}}
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 140, in run_jobs
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 441, in run
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 230, in _run
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 156, in _run
File "/usr/local/lib/python3.6/site-packages/snakemake/executors/__init__.py", line 162, in printjob
In case somebody else stumbles upon this question, -HH disables the column numbers:
bcftools query -HH -f '%CHROM\t%POS\t%REF\t%ALT\n' input.vcf
Output will be
#CHROM POS REF ALT
chr1 10000 A T
chr1 20000 G C
chr1 30000 T A
Log in to answer this question.