This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Split a BAM within a chromosome without losing read pairs

I am trying to figure out a way to split up a BAM file into many small pieces without splitting up read pairs. The resulting BAM files needs to be name-sorted, although that operation could be performed on each chunk after the splitting process.

As far as I can tell, there aren't any existing tools that do this. Does anyone know of anything?

rna-seq bam

It would be highly likely that name sorting it first and then splitting will be much much easier as pairs have the same name in a BAM file!

First thing that comes to my mind is that you could probably split over the centromere without issues, but I assume you want to split more than once.

1 answer

Since you have RNA-Seq in your keywords I assume this is RNA-Seq data. If so, if you split at intergenic regions you should de-couple a relatively small number of pairs. You would probably obtain a few thousand files. You can then use samtools fixmate to keep only paired reads within files.

In general, I think finding the optimal solution that minimises the number of decouplings is quite a difficult problem and it may be anyway impractical.

Log in to answer this question.