This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extend bed intervals to a uniform size?

Is there a method similar to bedtools slop that allows extension of bed intervals to a set size?
My bed intervals are all different lengths and while I know slop can extend each by a set size, is there a method that can extend all to a uniform length?

Thanks

bedtools bed genome

I'm not aware of a tool to do this (but it's very well possible this exists).
If you know a bit of scripting this job is quite trivial (I can help with Python or R).

The only thing you have to decide is in which direction you want to extend the intervals.

2 answers

Read your file into R using the rtracklayer package and use the GenomicRanges package to resize your ranges to a fixed width:

library("rtracklayer")
userRanges <- import.bed("userFile.bed")

library("GenomicRanges")
resizeRanges <- resize(userRanges, width = 250)

export.bed(resizeRanges, "resizeFile.bed")

You could also check very good one-liner solution provided in this message Grow/shrink ranges in bed file to a specified length

Log in to answer this question.