I've got a few thousand small bam files produced against the exact same reference, and I want to merge them into one single big bam file. What is the best way to do that?
Should I do this iteratively or can I pass a long list of bam files to samtools/picard/etc in one go?
Edited, since this is now partially solved. In my terminal, the methods below works for up to 4092 files. More than that raises an error:
samtools merge all.bam *.bam samtools merge all.bam `find /basedir/ -name "*myfiles*.bam"` samtools merge all.bam /basedir/*/???/*myfiles*.bam