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
bcftools +fill-tag does not work in loop
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!
• 5,751 views
•
link
1 answer
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:
- The
${file%.*}.tagged_vcf.gzis intended to be the output filename. - This corresponds to
file.vcf_ok.gzin the non-loop version. - Oh, the
-ois missing.
• 0 views
•
link
• 0 views
•
link
If this solved your problem then go ahead and accept the answer (green check mark) to provide closure to the thread.
• 0 views
•
link
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
• 0 views
•
link
Log in to answer this question.
What happens if you add quotes around
$filelikeNothing changed! Same error output.
Why are you unloading
bcftoolsmodule in your code? Do you want to use an older/newer version ofbcftoolsthat is present elsewhere and is in your default$PATH?I am currently using 1.9 version. The hpc has also older versions
Examples for
bcftools +fill-tagsshowbcfformat files as well as an output file name. Take a look atbcftools +fill-tags -hShall I keep it?
module unload bcftoolsBy
unloadingthe module we have no idea which version you are using. Normally peopleloada module they want to use before running some code.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 unloadit will look like a module is being unloaded even if there wasn't one already loaded. Could you usewhich 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 directoryI 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.