来自于: https://www.biostars.org/p/63429/
I'm using samtools mpileup and would like to generate both a pileup file and a vcf file as output. I can see how to generate one or the other, but not both (unless I run mpileup twice). I suspect I am missing something simple.
Specifically, calling mpileup with the -g or -u flag causes it to compute genotype likelihoods and output a bcf. Leaving these flags off just gives a pileup. Is there any way to get both, without redoing the work of producing the pileup file? Can I get samtools to generate the bcf _from_ the pileup file in some way? Generating the bcf from the bam file, when I already have the pileup, seems wasteful.
Thanks for any help!
我写了脚本来运行,才发现我居然需要两个重复的步骤来得到mpileup格式的数据和bcftools格式的数据,而这很明显的重复并且浪费时间的工作
for i in *sam
do
echo $i
samtools view -bS $i >${i%.*}.bam
samtools sort ${i%.*}.bam ${i%.*}.sorted
samtools index ${i%.*}.sorted.bam
samtools mpileup -f /home/jmzeng/ref-database/hg19.fa ${i%.*}.sorted.bam >${i%.*}.mpileup
samtools mpileup -guSDf /home/jmzeng/ref-database/hg19.fa ${i%.*}.sorted.bam | bcftools view -cvNg - > ${i%.*}.vcf
Done
我想得到mpileup格式,是因为后续的varscan等软件需要这个文件来call snp
而得到bcftools格式可以直接用bcftools进行snp-calling
samtools mpileup 命令只有用了-g或者-u那么就只会输出bcf文件
如果想得到mpileup格式的数据,就只能用-f参数。
- bcftools doesn't work on pileup format data. It works on bcf/vcf files.
- samtools provides a script called sam2vcf.pl, which works on the output of "samtools pileup". However, this command is deserted in newer versions. The output of "samtools mpileup" does not satisfy the requirement of sam2vcf.pl. You can check the required pileup format on lines 95-99, which is different from output of "samtools mpileup".