Reputation: 61
when working with bedtools intersect , there are many options that you could use like setting minimum overlap as percentage of file A or B , or whether to write original A or B entries. I was wondering if there is a package in R that does the same
I would appreciate your answer
Upvotes: 1
Views: 2200
Reputation: 227
The bioconductor package GenomicRanges has a function to find overlaps: findOverlaps()
and intersect()
and you can set an option minoverlap
More info here.
You can also read bedFiles into GRanges using rtracklayer
Upvotes: 0
Reputation: 41
There is the 'valr' package, that allows you to execute some of the basic bedtools commands in R.
https://rnabioco.github.io/valr/
But I don't think it yet supports the percentage overlap -f option of bedtools unfortunately
You can code it yourself though:
library(tidyverse)
library(valr)
A <- tibble(chrom='chr1', start=100, end=900)
B <- tibble(chrom='chr1', start=700, end=1000) %>%
dplyr::mutate(width=end-start)
bed_intersect(A,B) %>%
dplyr::mutate(percent_overlap = .overlap / width.y) %>%
dplyr::filter(percent_overlap >= 0.5
Upvotes: 1