Condense a GRanges object by taking the min/max position per chromosome. This helps to reduce the total number of queries, which can cause memory allocation problems due to repeated calls to the underlying C libraries.
condense_granges(gr, split_chromosomes = FALSE)
A GRanges object.
Split into a named list by chromosome.
gr <- unlist(
GenomicRanges::GRangesList(
"gr1"=GenomicRanges::GRanges("4:1-100"),
"gr2"=GenomicRanges::GRanges("4:300-500"),
"gr3"=GenomicRanges::GRanges("8:40-10000"))
)
gr2 <- condense_granges(gr = gr)