Question: Trouble with bedtools groupby - not summarizing by columns
0
gravatar for yarmda
2.3 years ago by
yarmda0
yarmda0 wrote:

I'm trying to use bedtools intersect and group by to get a count of reads by region they overlap. This should be straightforward, but the output I'm getting is just a number (presumably, the count of all reads that overlapped any region).

Process:

bamToBed mybam.bam > mybam.bed
sort -k1,1 -k2,2n -k3,3n mybam.bed > sort.mybam.bed
bedtools intersect -a sort.mybam.bed -b regions.bed -wa -wb | groupBy -g 1-3 -c 8 -o count > groups.bed

As far as I can tell from the documentation, that should do just what I need. I receive no errors when running this, but no columns print in the output. I understand that the input files must be sorted on the columns to be output, but I think I've done that.

Any thoughts?

sort bam groupby bedtools • 1.5k views
ADD COMMENTlink modified 22 months ago by Eichan10 • written 2.3 years ago by yarmda0
1

I'm trying to use bedtools intersect and group by to get a count of reads by region they overlap

use GATK DepthOfCoverage

ADD REPLYlink written 2.3 years ago by Pierre Lindenbaum118k
2
gravatar for dariober
2.3 years ago by
dariober9.9k
WCIP | Glasgow | UK
dariober9.9k wrote:

What version of bedtools are you using? In v2.26.0 there are some issues with groupby and the one you describe may be similar to #435. If this is the case try downgrading to 2.25.

By the way, for what you need you could use intersectbed with -c option: For each entry in A, report the number of hits in B. I.e. like: intersectBed -c -a regions.bed -b sort.mybam.bed. Also consider using the -sorted option for speed.

ADD COMMENTlink written 2.3 years ago by dariober9.9k

Thanks! I didn't even see the -c option for intersectBed. And I do have v2.26 installed, which may have been the issue.

ADD REPLYlink written 2.3 years ago by yarmda0
0
gravatar for chycheng2012
23 months ago by
chycheng20120 wrote:

I had same problem. By using v2.25, I got expected result

ADD COMMENTlink written 23 months ago by chycheng20120
0
gravatar for Eichan
22 months ago by
Eichan10
Japan/Tokyo
Eichan10 wrote:

Yes, I got exactly the same problem today. Seems that Bedtools version v.2.26.0 still have the problem with groupby function. I tested with v.2.25 and worked.

ADD COMMENTlink modified 22 months ago • written 22 months ago by Eichan10
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: 1878 users visited in the last hour