Merge multiple BAM files

When I need to merge multiple alignment files (in BAM format) I adopted this pipeline: extract the header from one of the files, then printing all the BAM files into the same SAM file.

samtools view -H one-of-the-files.sam > mergedfile.sam
find . -name "*.bam" -exec samtools view {} \; >> mergedfile.sam
samtools view -bh mergedfile.sam > mergedfile.bam


Be the first to leave a comment. Don’t be shy.

You must be logged in to post a comment.