0
$\begingroup$

I have 2 bam files that belong to the same sample and I merged them with samtools merge. And after merging, I realized that the merged version is a bit smaller than the sum of the other two separate files' size. I also wonder if I merged "the fastq" files of this sample first and convert it to bam would the result be the same?

$\endgroup$
4
  • $\begingroup$ Perhaps the input was in .sam format and output in .bam? $\endgroup$
    – user438383
    Jul 30 at 10:04
  • $\begingroup$ @user438383 No, I had "the fastq" files but before getting ".bam files" I didn't know they belong to the same sample. So I converted them to ".sam" and then to ".bam" respectively. And now that I learned that they actually belong to the same sample I have to merge them. $\endgroup$ Jul 30 at 10:10
  • $\begingroup$ Converting fastqs to bams is technically doable, but why? Do you mean merging the fastqs and realigning? $\endgroup$
    – swbarnes2
    Jul 30 at 16:15
  • $\begingroup$ @swbarnes Yes, exactly. $\endgroup$ Jul 30 at 16:18
1
$\begingroup$

If you merge a lot of BAM files you lose the overhead of the header which depending on the size of your BAM files this can be a significant difference or not.

With FASTQ files there should be less difference (as they don't have an overall header). However, the compression ratio can change depending on how you zip your files. [EDIT: I just tested it merging two fastq.gz that were 357MB and 562MB - the result was fastq.gz that was smaller than the sum at only 826MB]

No, the BAM header information would be lost in the conversion from BAM -> FASTQ -> BAM.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.