This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bcftools multiple commands

Hello,

I want to process a VCF-file with bcftools. Amongst other things I want to:

  1. use multiple commands in one line of code e.g. bcftools annotate + bcftools view --> (How) is this possible?

  2. filter for multiple bed-file regions. Can I do this in one line of code? --> e.g. bcftools view -R file1.bed -R file2.bed -o output?

Best,

Andreas

bcftools

1 answer

You can't run multiple commands at once, but you can pipe multiple commands e.g. bcftools annotate --some-args in.bcf | bcftools view -s sample > out.bcf. I would probably suggest merging the bed files in bedtools first and then running bcftools on a single file.

Hey, I tried now the piping, but the following error occurs: "Failed to read from standard input: not compressed with bgzip", which does not arise if I split the commands into several lines. Any suggestions?

There may be a - missing from original answer. Can you try: bcftools annotate --some-args in.bcf | bcftools view -s sample - > out.bcf. If that is not the command you are having problem with then post the command you are using.

Here you can find a simplified version of my command:

bcftools annotate -x INFO/vep file.vcf.gz | bcftools view --types snps --regions-file bedfile -o output_file - O z

or

bcftools annotate -x INFO/vep file.vcf.gz | bcftools view --types snps --regions-file bedfile - > output_file

Both commands lead to the same named error.

Thanks for your help!

Andreas

Log in to answer this question.