Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bedtools merge output interval different by 1 in each direction #469

Closed
kszkop opened this issue Jan 17, 2017 · 4 comments
Closed

bedtools merge output interval different by 1 in each direction #469

kszkop opened this issue Jan 17, 2017 · 4 comments

Comments

@kszkop
Copy link

kszkop commented Jan 17, 2017

I have number of files in delimited format: chromosome start end . I would like to merge overlapping intervals between files, keeping option min distance between intervals to be merged. I cat all files , sorted and applied bedtools merge with option -d. All good, but the problem I have is that when interval is of length 1, the output from bedtools merge outputs it as +1 -1 interval. For example:
my input: chr 421 421
my output" chr 420 422

@tdelhomme
Copy link

I get the same problem.

bedtools v2.25.0

cat test.bed
chr12	25398284	25398284
chr12	25398285	25398285

bedtools merge -i test.bed
chr12	25398283	25398286

@ghuls
Copy link
Contributor

ghuls commented Feb 15, 2017

This is probably because BED is a zero-based half open interval (first base of chromosome = 0, end coordinate is not included in the interval):

chr 421 421 ==> is a region of length 0, starts at base 422 (421 + 1) in the chromosome and ends before base 422

so your regions all have a length of 0 basepares.

If you have BED regions which have a length of at least 1 basepare, it works fine.

$ printf 'chr1\t421\t422\nchr1\t422\t423\n'
chr1	421	422
chr1	422	423

$ printf 'chr1\t421\t422\nchr1\t422\t423\n' | ./bedtools2-git/bin/bedtools merge -i -
chr1	421	423

@tdelhomme
Copy link

@mfoll

@mfoll
Copy link

mfoll commented Feb 15, 2017

Indeed:

BED starts are zero-based and BED ends are one-based.

http://bedtools.readthedocs.io/en/latest/content/overview.html#bed-starts-are-zero-based-and-bed-ends-are-one-based

@arq5x arq5x closed this as completed Aug 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants