This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Merging bed intervals within a group

Hi,

I have a bed file like following:

PGRP-SA-PA  11561749    11561803
PGRP-SA-PA  11561806    11561873
PGRP-SA-PA  11561875    11561925
noc-PB  14490900    14490989
noc-PB  14491004    14491065
noc-PB  14491076    14491106
noc-PB  14491117    14491182
noc-PB  14491201    14491295

I would like to group intervals based on column 1 like following

PGRP-SA-PA  11561749    11561925
PB  14490900    14491295

I tried using bedtools groupBy like following

groupBy -g 1 -c 2,3 -o min,max

but I couldnt get my desired output. any suggestions? Kindly guide me.

bedtools bedops bed

That should work. I tried the following command with your example BED file:

groupBy -g 1 -c 2,3 -o min,max -i input.bed

Here is the output:

PGRP-SA-PA  11561749    11561925
noc-PB  14490900    14491295

What output do you get?

Hi, Thanks for your reply. I tried your code, it gave the following output

11561749    14491295

You might need to compile Bedtools from the latest source code. I remember the latest current release has a groupBy bug of some kind, but the latest commit version should have it fixed.

0 answers

No answers yet.

Log in to answer this question.