Question: Is BED file generated by bametobed sorted ?
0
gravatar for pacman
10 weeks ago by
pacman50
United States
pacman50 wrote:

We use bamtobed to covert bam files to bed files. I am wondering if the output is sorted by default , because our output bed files seems to be sorted by chromosome and position. I am asking this question because we are using bedtools to calculate coverage with large bam files which takes up a lot of memory. It was suggested to pre-sort the bed files before running bedtools coverage in the documentation to help reduce the memory usage. However, sorting on bash , even running parallel with 8 cores, is still time-consuming. So, it would be great if anyone can confirm bamtobed does that already .

ADD COMMENTlink modified 10 weeks ago by Alex Reynolds26k • written 10 weeks ago by pacman50

I don't think you need to convert BAM to BED in order to take advantage of the -sorted option of coverageBed. Just pass the bam file to -a with the -sortedand possibly the -g option enabled.

Anyway, I would guess the conversion BAM to BED doesn't change the order of records so if your BAM is sorted the BED output will be sorted as well.

ADD REPLYlink written 10 weeks ago by dariober9.7k
0
gravatar for Alex Reynolds
10 weeks ago by
Alex Reynolds26k
Seattle, WA USA
Alex Reynolds26k wrote:

You could use bam2bed to make a sort-bed-sorted file:

$ bam2bed < reads.bam > reads.bed
ADD COMMENTlink modified 10 weeks ago • written 10 weeks ago by Alex Reynolds26k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1490 users visited in the last hour