This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merge bam files and get VCF file

I have 2 sorted Bam files and I want to merge them and get a VCF file from them using samtools pileup.

first i merge these 2 files with samtools merge and then I get a VCF file as output.

samtools mpileup genome.fa merged-bam.bam output.vcf

then I use

samtools mpileup genome.fa 1.bam 2.bam  output.vcf

but the output of these 2 approach had different size. where am I doing wrong?

thanks a lot

rna-seq snp bam

1 answer

my answer depends of your sam header+ read-group ( https://gatkforums.broadinstitute.org/gatk/discussion/6472/read-groups )

1) samtools merge : would produce one bam and you'll get only one virtual sample in the final vcf (see the columns after FORMAT in the '#CHROM' line)

2) the 2nd command 'samtools mpileup genome.fa 1.bam 2.bam output.vcf' will produce a vcf with two samples (this is what your want in 99% of the use cases)

I have read the link you shared, I didn't understand it properly. how should my bam file header be to use the second approach?

i you have defined read-groups, for each sample, there should be no difference event if you merge the bam.

Log in to answer this question.