randomInterval: Get random intervals based on a set of regions

Description Usage Arguments Author(s) Examples

Description

Given a set of regions, generate genomic intervals uniformly at random from those regions. These can be strand specific or not.

Usage

1
2
randomInterval(I, n = 1, ms = 10000, strand.specific = FALSE,
  randomize.strand = FALSE)

Arguments

I

A GRanges object giving intervals from which to sample from.

n

Number of intervals to generate.

ms

Length of intervals to generate. It can be a vector but recycling rules will be used if ms is of a length smaller than n.

strand.specific

Whether the random intervals should have be strand specific or not.

randomize.strand

When strand.specific=TRUE, whether the strand should be randomized or depend on the strand from the regions in I.

Author(s)

Leonardo Collado-Torres

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Create some input ranges
library('GenomicRanges')
gr <- GRanges(c('chr1', 'chrX'), IRanges(c(1e6, 3e6), width = 1e5), strand =
    c('+', '-'))
gr

## Set the seed if you want to reproduce the random results
set.seed(20140728)

## Obtain 4 randomg intervals
randomInterval(gr, 4)

## Strand specific without randomizing the strand
randomInterval(gr, 4, strand.specific = TRUE)

## This function is a modified version of seqbias::random.intervals
## Check the original code below:
library('seqbias')
random.intervals
## Some key differences are that randomInterval works with repeated
## seqnames and starts at the beginning of the input ranges, not at base 1.

leekgroup/enrichedRanges documentation built on June 6, 2019, 7:37 a.m.