Thank you very much! That works but I'm wondering, is there any way plot-vcfstats can read that table? As it is not a file directly generated by bcftools stats, it doesn't recognize it.
Hello.
I'm trying to view substitutions specific to sample-names from my vcf. I have ran
bcftools stats --samples '-' file1.vcf.gz file2.vcf.gz > both_vcf.gz.stats
as well as
plot-vcfstats --sample-names both_vcf.gz.stats -p output_dir/
The stats look like the following:
I would like to obtain a plot from plot-vcfstats that gives the substitution types per sample-name, but instead i get 1) it looks like it is not able to count the variants on a sample-specific level as shown in Figure 3; and 2) the substitution plot from vcfstats gives only the info from Figure 1.
Any help to understand what's going on is greatly appreciated, thank you!
1 answer
one can get a table SAMPLE,SUBST,COUNT by running a loop over the samples:
$ bcftools query -l in.vcf.gz | while read SN; do bcftools view --samples ${SN} -O u in.vcf.gz | bcftools view -O u -i 'AC[*]>0' | bcftools stats - | awk -vSN=${SN} '$1=="ST" {printf("%s\t%s\t%s\n",SN,$3,$4);}' ; done
it could be a simple plot using R...
yep! i just did it with matplotlib, i thought maybe there was a way of doing it quicker with the bcftools options. Thank you very much!
Don't forget to follow up on your threads. If an answer was helpful, you should upvote it; if the answer resolved your question, you should mark it as accepted. You can accept more than one answer if they all work. If an answer was not really helpful or did not work, provide detailed feedback so others know not to use that answer.

Log in to answer this question.