I am trying to find a way to efficiently extract a matrix showing '0' or '1' when comparing different GRange
objects. In my example:
gr.1 <- regioneR::createRandomRegions(nregions=1000, length.mean=500000, length.sd=30000)
gr.2 <- regioneR::createRandomRegions(nregions=1000, length.mean=500000, length.sd=30000)
gr.3 <- regioneR::createRandomRegions(nregions=1000, length.mean=500000, length.sd=30000)
I tried findOverlaps
to evaluate the overlaps among these regions but apparently it can't deal with more than two GRanges
:
> GenomicRanges::findOverlaps(gr.1, gr.2, gr.3)
> Error in IRanges:::NCList_find_overlaps_in_groups(ranges(query),
> q_space, : 'maxgap' must be a single integer
Moreover, my required output would be something like this example data-frame:
out <- "gr.1 gr.2 gr.3
chr1-1 1 0 1
chr1-2 1 1 0
chr10-3 0 1 0
chr10-4 1 1 0"
out <- read.table(text=out, header=TRUE)
Any idea to wisely export it using mainly functions from bioconductor packages?