What if my bam files are not sorted, what actually does samtools merge do then? because I've just run samtools merge with unsorted bam files.
many thanks!
Hi,
Imagine that I have 20 bam files, which I want to change their header then merge them and then sort them! So I just wondering if these two scenarios make different output :
All bam files have the same read group, and I want to add sample name to each RG field
@RG ID:1120
Thanks
It shouldn't make any difference, but what I'd suggest doing is using samtools merge and passing the header you want to apply to the merged file through the -h argument. That will simplify your workflow. samtools merge does expect your input to be already sorted though. If your input is indeed sorted, then that will allow you to accomplish your goal with a single command.
For example, put the header you want in a file called header.sam:
samtools merge -h header.sam merged.bam 1.bam 2.bam 3.bam ... 20.bam
What if my bam files are not sorted, what actually does samtools merge do then? because I've just run samtools merge with unsorted bam files.
many thanks!
Log in to answer this question.