Question: bedtools intersectBed and GRanges countOverlaps
1
gravatar for User 7754
3.0 years ago by
User 7754230
United Kingdom
User 7754230 wrote:

Hi,

I am generating overlaps using this command in bedtools:

intersectBed -a snps.bed -b region.bed -wb

And now I am trying to compare the same files using the R package GenomicRanges, countOverlaps(snps, region.bed, type=c("within"), but I am not getting the same results.

In particular, it seems as the positions at the borderline of the region.bed are not counted as overlaps, for example this entry in snps.bed: 1 112162878 112162879

and this entry in region.bed: 1 112162834 112162878

Is this what others have seen as well? How can I get bedtools to count these entries as overlaps, without adding flanking bases? Thank you

bed genomicranges R bedtools • 1.4k views
ADD COMMENTlink modified 3.0 years ago by Alex Reynolds28k • written 3.0 years ago by User 7754230
3
gravatar for Alex Reynolds
3.0 years ago by
Alex Reynolds28k
Seattle, WA USA
Alex Reynolds28k wrote:

BED files are generally 0-indexed, so you're generally not going to get overlaps with applications that do operations on input files that use 0-based indexing, which generally do not count endpoints in calling overlaps. GRanges documentation says it uses 1-based indexing, so it will include endpoints in generating overlaps.

Your solution is perhaps not to count those kinds of overlaps in BED file inputs using GRanges, by specifying that your (BED-formatted) inputs are 0-based and need adjustment in R. The documentation for GRanges explains this in more detail; see the starts.in.df.are.0based option.

ADD COMMENTlink written 3.0 years ago by Alex Reynolds28k

Thank you Alex! I understand now. Apart from the difference in 1 base for snps, also the last position of the region.bed range and the first position do not count as overlaps using bedtools. Something to keep in mind. Thank you

ADD REPLYlink modified 3.0 years ago • written 3.0 years ago by User 7754230
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: 1091 users visited in the last hour