Question: Merging bed intervals within a group
0
gravatar for EVR
22 months ago by
EVR540
Earth
EVR540 wrote:

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.

bedops bed bedtools • 538 views
ADD COMMENTlink written 22 months ago by EVR540

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 22 months ago • written 22 months ago by James Ashmore2.6k

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

11561749    14491295
ADD REPLYlink written 22 months ago by EVR540

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 22 months ago by James Ashmore2.6k
Please log in to add an answer.

Help
Access

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