bcftools +fill-tag does not work in loop
1
1
Entering edit mode
3.7 years ago

Hello all!

I work with cattle genome. I am trying to update INFO of my vcf files by using +fill-tag. It works with one file, but it does not work in the loop.

module unload bcftools

bcftools +fill-tags file.vcf -Oz -o file.vcf_ok.gz -- -t AF,AN,AC, AC_Hom,AC_Het,MAF,NS

When I want to work my loop script in the slurm job. I used this:

module unload bcftools
    for file in ./*.vcf; do bcftools +fill-tags $file -Oz ${file%.*}.tagged_vcf.gz -- -t AF,AN,AC,AC_Hom,AC_Het,MAF,NS ; done

But it gave me this error message:

About: Set INFO tags AF, AC, AC_Hemi, AC_Hom, AC_Het, AN, ExcHet, HWE, MAF, NS.
Usage: bcftools +fill-tags [General Options] -- [Plugin Options]
Options:
   run "bcftools plugin" for a list of common options



Plugin options:
   -d, --drop-missing          do not count half-missing genotypes "./1" as hemizygous
   -l, --list-tags             list available tags with description
   -t, --tags LIST             list of output tags. By default, all tags are filled.
   -S, --samples-file FILE     list of samples (first column) and comma-separated list of populations (second column)



Example:
   bcftools +fill-tags in.bcf -Ob -o out.bcf
   bcftools +fill-tags in.bcf -Ob -o out.bcf -- -t AN,AC
   bcftools +fill-tags in.bcf -Ob -o out.bcf -- -d
   bcftools +fill-tags in.bcf -Ob -o out.bcf -- -S sample-group.txt -t HWE

I do not know how to fix this issue. Any help will be welcomed!

bcftools plugin +fill-tags loops • 3.6k views
ADD COMMENT
0
Entering edit mode

What happens if you add quotes around $file like

for file in ./*.vcf; do bcftools +fill-tags "$file" -Oz "${file%.*}".tagged_vcf.gz -- -t AF,AN,AC,AC_Hom,AC_Het,MAF,NS; done
ADD REPLY
0
Entering edit mode

Nothing changed! Same error output.

ADD REPLY
0
Entering edit mode

module unload bcftools

Why are you unloading bcftools module in your code? Do you want to use an older/newer version of bcftools that is present elsewhere and is in your default $PATH?

ADD REPLY
0
Entering edit mode

I am currently using 1.9 version. The hpc has also older versions

ADD REPLY
0
Entering edit mode

Examples for bcftools +fill-tags show bcf format files as well as an output file name. Take a look at bcftools +fill-tags -h

ADD REPLY
0
Entering edit mode

Shall I keep it?

module unload bcftools

ADD REPLY
0
Entering edit mode

By unloading the module we have no idea which version you are using. Normally people load a module they want to use before running some code.

ADD REPLY
0
Entering edit mode

It sounds like you are using your own version of bcftools. I don't know it is just the HPC or Slurm itself but if you type in module unload it will look like a module is being unloaded even if there wasn't one already loaded. Could you use which bcftools? You might be able to see the path to where bcftools is installed. What will at least tell you if you're using your own version or the version your HPC probably has in some shared directory

ADD REPLY
0
Entering edit mode

I was working on Conda. I tried it by deactivating conda. As John mentioned in the comment, I also missed -o option in the loop. I have also included the BCFTOOLS_PLUGINS plugin environment to my slurm script.

module load bcftools
BCFTOOLS_PLUGINS="/cm/shared/apps/bcftools/gcc/64/1.9/libexec/bcftools/"

for file in ./*.vcf; do bcftools +fill-tags "$file" -Oz -o "${file%.*}".tagged_vcf.gz -- -t AF,AN,AC,AC_Hom,AC_Het,MAF,NS ; done
ADD REPLY
5
Entering edit mode
3.7 years ago

Without loop:

bcftools +fill-tags file.vcf -Oz -o file.vcf_ok.gz -- -t AF,AN,AC, AC_Hom,AC_Het,MAF,NS

With loop:

for file in ./*.vcf; do
    bcftools +fill-tags $file -Oz ${file%.*}.tagged_vcf.gz -- -t AF,AN,AC,AC_Hom,AC_Het,MAF,NS ;
done

It's good to think about what the options and file arguments you're using actually mean. Hence:

  1. The ${file%.*}.tagged_vcf.gz is intended to be the output filename.
  2. This corresponds to file.vcf_ok.gz in the non-loop version.
  3. Oh, the -o is missing.
ADD COMMENT
0
Entering edit mode

Thanks John for checking my script. As I shared it in the comments above, I have also deactivated conda and add bcftools_plugin environment variable

ADD REPLY
1
Entering edit mode

If this solved your problem then go ahead and accept the answer (green check mark) to provide closure to the thread.

ADD REPLY
0
Entering edit mode

The answer of John is not a complete solution. But I am adding here the complete solution including accepting his answer

module load bcftools
BCFTOOLS_PLUGINS="/cm/shared/apps/bcftools/gcc/64/1.9/libexec/bcftools/"

for file in ./*.vcf; do bcftools +fill-tags "$file" -Oz -o "${file%.*}".tagged_vcf.gz -- -t AF,AN,AC,AC_Hom,AC_Het,MAF,NS ; done
ADD REPLY

Login before adding your answer.

Traffic: 2656 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6