Hi guys,
I am trying to downsample a bam file with paired reads. Initially I was using samtools view -s, providing a fraction of reads I'd like to keep. But the caveat for this is that the output file will contain not only intact read pairs but also individual reads. It is bad for me because I am trying to use this downsampled bam file for analysis with packages that take as an input bed files (such as diffReps). In case when I have both paired and not paired reads in a bam file, there is no way I can convert it to bed 100% correctly.
Do you have any suggestions on how I could downsample a bam file keeping read pairs intact? I really struggled to find a ready solution for this by googling.
Many thanks in advance!
I am trying to downsample a bam file with paired reads. Initially I was using samtools view -s, providing a fraction of reads I'd like to keep. But the caveat for this is that the output file will contain not only intact read pairs but also individual reads. It is bad for me because I am trying to use this downsampled bam file for analysis with packages that take as an input bed files (such as diffReps). In case when I have both paired and not paired reads in a bam file, there is no way I can convert it to bed 100% correctly.
Do you have any suggestions on how I could downsample a bam file keeping read pairs intact? I really struggled to find a ready solution for this by googling.
Many thanks in advance!
Comment