Question: Merging bed intervals within a group
gravatar for EVR
3.3 years ago by
EVR570 wrote:


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.

bedops bed bedtools • 860 views
ADD COMMENTlink written 3.3 years ago by EVR570

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?

ADD REPLYlink modified 3.3 years ago • written 3.3 years ago by James Ashmore3.0k

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

11561749    14491295
ADD REPLYlink written 3.3 years ago by EVR570

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.

ADD REPLYlink written 3.3 years ago by James Ashmore3.0k
Please log in to add an answer.


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