Skip to contents

Get the ranges of sliding windows that overlap each range of an IRanges object.

Usage

getWinOverlapEachIRange(
  x,
  winWidth = 1000L,
  winStep = 100L,
  readProp = 0.5,
  maxWin = Inf
)

Arguments

x

an IRanges object containing the start and end position of each read fragment.

winWidth

the width of the sliding window, 1000 by default.

winStep

the step length to sliding the window, 100 by default.

readProp

A read is considered to be included in a window if at least readProp of it is in the window. Specified as a proportion.

maxWin

The maximum window ID

Value

An IRanges object containing the index of the windows overlapping each read fragment

Details

This finds the windows that overlap each range of the input IRanges object. Each range corresponds to a read fragment. This allows the total number of read fragments within a window to be calculated simply using coverage.

Examples

library(IRanges)
x <- IRanges(start=round(runif(100,1000,10000)),width=100)
getWinOverlapEachIRange(x)
#> IRanges object with 100 ranges and 0 metadata columns:
#>             start       end     width
#>         <integer> <integer> <integer>
#>     [1]        46        55        10
#>     [2]        44        53        10
#>     [3]        73        82        10
#>     [4]        30        39        10
#>     [5]        30        39        10
#>     ...       ...       ...       ...
#>    [96]        79        88        10
#>    [97]        45        54        10
#>    [98]        50        59        10
#>    [99]        62        71        10
#>   [100]        29        38        10