This function takes a given GRanges and returns another GRanges object. The new GRanges has the same number of ranges and the same chromosome, width and strand distributions than the original GRanges.

sampleGRanges(
  x,
  n = NULL,
  width = NULL,
  exclude = FALSE,
  avoid_overlap = FALSE
)

Arguments

x

GRanges object

n

Integer, number of sampled GRanges

width

Integer, width of sampled GRanges

exclude

Boolean, should the original GRanges be excluded?

avoid_overlap

Boolean, should the sampled GRanges not be overlapping?

Value

A GRanges object of length n

Examples

data(ce11_proms)
sampleGRanges(ce11_proms, 100)
#> GRanges object with 100 ranges and 0 metadata columns:
#>         seqnames            ranges strand
#>            <Rle>         <IRanges>  <Rle>
#>     [1]     chrI   1610448-1610598      +
#>     [2]     chrI   2544450-2544600      +
#>     [3]     chrI   2794866-2795016      +
#>     [4]     chrI   3864466-3864616      +
#>     [5]     chrI   6057549-6057699      +
#>     ...      ...               ...    ...
#>    [96]     chrX 14099795-14099945      -
#>    [97]     chrX 14254630-14254780      -
#>    [98]     chrX 16527369-16527519      -
#>    [99]     chrX 17597686-17597836      -
#>   [100]     chrX 17699646-17699796      -
#>   -------
#>   seqinfo: 6 sequences from an unspecified genome; no seqlengths