This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fastq file size after splitting bam

I have a bam file of roughly 75GB size. I wanted to check the read quality and so I split it using bedtools bamtofastq command.
bedtools bamtofastq -i t.bam -fq r1.fq -fq2 r2.fq
Now after checking the sizes of the fastq files, I found out that they are of 1.2GB size each. Isn't this unexpected? I was expecting larger file sizes. Where am I going wrong? Thanks!

software error sequencing

You don't need to convert the file. The BAM file includes the quality info.

Most common way to check quality is with FastQC and that will accept BAM files.

I wanted to realign my bam files with hg38 reference. Hence I am splitting

Can you try reformat.sh in=your.bam out1=R1.fq.gz out2=R2.fq.gz to see if you get files of the right size (from BBMap suite)? You could have a lot of secondary alignments etc and the fastq files you get may look much smaller since reads would be present more than once in your BAM file.

Thanks for your reply. I got fasta files after using samtools that were of proper sizes.(~108GB each). So those who encounter this problem please try to use samtools instead.

1 answer

I was expecting larger file sizes. Where am I going wrong? Thanks!

This bedtools documentation has this to say about it:

When using this option, it is required that the BAM file is sorted/grouped by the read name. This keeps the resulting records in the two output FASTQ files in the same order. One can sort the BAM file by query name with samtools sort -n aln.bam aln.qsort.

It appears you did not follow the bedtools documentation and sort by queryname first.

Log in to answer this question.