this works nice, but is there a way to keep the vcf metadata so i can pipe to bcftools?
Output a vcf restricted to variant sites listed in a file
I'm looking for a tool that will output a vcf restricted to variant sites (not genomic intervals) listed in a tab-delimited file. I understand GATK SelectVariants can do this, but I'd prefer an alternative tool that doesn't reorder samples.
• 3,438 views
•
link
2 answers
Not quite sure I understand why this won't work, as long as your bed file is composed of 1bp variant sites and not intervals.
bedtools intersect -a my.vcf -b my.bed -wa >output
If you have something different in mind, then example data would be helpful.
• 0 views
•
link
Convert your vcf / target region to bed. (For a VCF it's something like:
grep -v "^#" your.vcf | awk -F '\t' '{printf("%s\t%d\t%d\n",$1,int($2)-1,int($2)+length($4)-1);}' > input.bed
and then use bcftools view with option --regions-file
or
bedtools intersect..
• 0 views
•
link
Log in to answer this question.