Handcrafting pixels and bytes since 1995

Published: 2 years ago

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


Some HTML is OK