reduce2: Merge genomic regions

Description Usage Arguments Details Value Author(s) Examples

View source: R/genomic_region_merge.R

Description

Merge genomic regions

Usage

1
reduce2(gr, gap = 0.1, max_gap = Inf, .message = TRUE, .revmap = NULL, ...)

Arguments

gr

a GRanges object

gap

a numeric value means to extend each region by gap/2 times of its width before merging. If gap represents number of base pairs, use bp, kb or mb to wrap it. If gap represents absolute number of base pairs, the functionality is same as reduce (gap is sent to min.gapwidth).

max_gap

maximum distance to merge, measured in base pairs. Only work if gap is a ratio value.

.message

internal use

.revmap

internal use

...

further arguments passed to reduce (exclude min.gapwidth and with.revmap)

Details

reduce only merges regions with fixed gap width, but sometimes it is not reasonable to set gap to a same width for all regions. Assuming we have a list of differentially methylated regions (DMRs) and we want to reduce the number of DMRs by merging neighouring DMRs. DMRs distribute differently in different places in the genome, e.g. DMRs are dense and short in CpG-rich regions (e.g. CpG islands) while long and sparse in CpG-poor regions (e.g. gene bodies and intergenic regions), thus the merging should be applied based to the width of every DMR itself. reduce2 can merge regions by the width of every region itself. This type of merging is dynamic because after each iteration of merging, some regions are merged into a large region and it will has longer extension. The whole merging will proceed iteratively unless there is no new merging.

Note with.revmap is always set to TRUE when calling reduce, thus there is always a revmap meta column in the returned GRanges object.

Value

a GRanges object with a revmap meta column.

Author(s)

Zuguang Gu <z.gu@dkfz.de>

Examples

1
2
3
4
5
gr = GRanges(seqnames = "chr1", ranges = IRanges(start = c(1, 4, 8 ,16), 
    end = c(2, 5, 10, 30)), value = 1:4)
reduce2(gr, gap = bp(2))
reduce2(gr, gap = 0.6)
reduce2(gr, gap = 0.6, max_gap = 4)

jokergoo/epik documentation built on Sept. 28, 2019, 9:20 a.m.