Reduce a list of GRanges to unique, non-overlapping regions
Source:R/granges_functions.R
reduce_regions.Rd
Takes a list of GRanges objects (e.g., peak sets from multiple samples), combines them, and merges any overlapping or adjacent regions into a single, minimal set of genomic intervals.
Value
A GRanges object containing the reduced (union) regions, with a `name` metadata column in the format "chr:start-end".
Examples
# Create a list of GRanges objects with overlapping regions
gr1 <- GenomicRanges::GRanges("chr1", IRanges::IRanges(c(100, 200), width = 50))
gr2 <- GenomicRanges::GRanges("chr1", IRanges::IRanges(c(120, 300), width = 50))
gr_list <- list(gr1, gr2)
# Reduce the list to a single set of non-overlapping regions
reduced <- reduce_regions(gr_list)
print(reduced)
#> GRanges object with 3 ranges and 1 metadata column:
#> seqnames ranges strand | name
#> <Rle> <IRanges> <Rle> | <character>
#> [1] chr1 100-169 * | chr1:100-169
#> [2] chr1 200-249 * | chr1:200-249
#> [3] chr1 300-349 * | chr1:300-349
#> -------
#> seqinfo: 1 sequence from an unspecified genome; no seqlengths
# The result combines overlapping regions [100-149] and [120-169] into [100-169].