samtools / bcftools

This is the official development repository for BCFtools. See installation instructions and other documentation here http://samtools.github.io/bcftools/howtos/install.html
http://samtools.github.io/bcftools/
Other
679 stars 239 forks source link

Variable expansion issue with +setGT? [$VARIABLE-] isn't working... #2276

Open goeckeritz opened 2 months ago

goeckeritz commented 2 months ago

Hi Petr,

I've seen some other issues that are similar to this one, but I've not had issues with variable expansion for the filtering expressions until I started using it with +setGT.

I have a variable, $MOM_SAMP, that is the sample number for a mother sample. When I use the variable for pointing to this sample for a certain filter, for example FORMAT/DP[$MOM_SAMP]<15, I get the expected outcome.

However, when I do FORMAT/DP[$MOM_SAMP-]<30, it behaves as if [$MOM_SAMP-] isn't even there, and applies the filter to all samples in the multi-sample vcf. I've also tried [${MOM_SAMP}-], [$(MOM_SAMP)-], [($MOM_SAMP)-], and [$($MOM_SAMP)-], but it still applies the filter to every single sample (for [${MOM_SAMP}-]), I get the error that a command MOM_SAMP isn't found [for $(MOM_SAMP)-], I get a parsing error (for [($MOM_SAMP)-]), or it gives the sample number as it should but without the '-', so it again reports the command is not found (for [$($MOM_SAMP)-]). It honestly looks like the '-' is ignored no matter what.

For context, my command looks like this:

bcftools +fill-tags ${COMBINED_FILE} -Oz --threads 24 -- -t FORMAT/VAF | bcftools view --with-header --threads 24 -Oz -M2 -v snps | bcftools +setGT -Oz -- -t 'q' -n "./." -i "FORMAT/DP<10 | FORMAT/DP[$MOM_SAMP]<15 | FORMAT/DP[$MOM_SAMP]>250 | FORMAT/DP[$MOM_SAMP-]>31" > ${MOM}_test.vcf.gz

I.e., I am trying to apply a different depth filter to the other samples since they have different levels of coverage. Am I by chance just coding this incorrectly? I am using bcftools 1.18. Any insight you can give me is extremely appreciated!

Kindly, Charity

pd3 commented 1 month ago

Can you create a small test case? As the problem is stated, it does not give enough information. I just need to see a minimal VCF and the exact commands to reproduce the problem, including how the environment variable is set. In my own tests it works.