Good idea, thanks!
Hi,
I am currently trying to filter a multi-sample vcf file obtained with samtools mpileup. I would like to keep the positions with all samples depths > 4.
I found a way with SnpSift filter, but I have to specify each sample one by one:
cat test.vcf | java -jar SnpSift.jar filter "(GEN[0].DP>4) & (GEN[1].DP>4) & ... &(GEN[66].DP>4)" > filtered.vcf
(I've got 66 samples ... )
Does anyone know how to apply this filtering option to all samples without specifying each samples one by one? (GEN[*] does not seem to work)
Moreover I would like to apply others genotype calling filters on subsets of my samples, is there a way to apply a filter to a specific subset?
Thanks
2 answers
How about generating the script?
cat test.vcf | java -jar SnpSift.jar filter `seq 1 66 | awk '{ printf("%s (GEN[%d].DP>4) ",(NR==1?"":" & "), $1);}'`
See also my tool : https://github.com/lindenb/jvarkit/wiki/VCFFilterJS to filter with javascript.
The -minDP option in vcftools might help. Reference link: http://vcftools.sourceforge.net/man_latest.html#GENOTYPE%20FILTERING%20OPTIONS
Log in to answer this question.