This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Separate Bed File To Each 60Kb Bins

Dear all, Could you help me please with my problem? I would lie to separate one bed file for chr1 to bins, which have 60 kb. For example: First bed file for the first 60kb bin will have all reads from chr1 bed file from 0 - 60000 position Second bed file for another 60 kb will have all reads from chr1 bed file from 60000 - 120 000 position etc.....

I think I can use the bedtools, but how. And if it is possible to do this awk, I will be happy... Tahnk you so much. Best Filip

bed

2 answers

bedtools makewindows -g hg19.genome -w 60000 > hg19.60K.windows.bed

Or, if you want one file per interval:

bedtools makewindows -g hg19.genome -w 60000 | awk '{print $0 >> $1":"$2"-"$3".bed"}'

You should end up with many files named. e.g., chr1:0-60000.bed, chr1:60000-120000.bed, etc. I am not certain this is the best approach, as you will generate many, many files.

I have one question, I would like to separate to each bed files. I think If I have some reads from 0-60k position I receive one bed file, from 60k-120k I receive another one etc... And this beedtools command can't do this..

Do you really want that - it will generate thousands of files (assuming a fairly large eukaryotic genome)? If so, I have edited the answer.

Here is a straightforward way to do it with awk: A: Does bedops have a command similar to the bedtools makewindows?

Log in to answer this question.