randomIRanges {biocDatasets}R Documentation

Random IRanges

Description

Create random IRanges

Usage

randomIRanges(n, width, from, to, replace = TRUE)

Arguments

n number of IRanges
width width for the IRanges
from starting index value for the sequence to be covered by IRanges
to ending index value for the sequence to be covered by IRanges
replace sampling with replacement if TRUE (see Details)

Details

The from and to parameters describe the underlying sequence to be covered by the ranges. To prevent having ranges outside the sequence, the end of the IRanges returned cannot be greater than end - width.

If replace is TRUE, several IRanges can have the same starting value.

Value

An IRanges object of length n.

See Also

IRanges

Examples


n <- 10
rir <- randomIRanges(n, 5, 1, 33)

# ASCII-art view
reference <- paste("|",
                   paste(rep("-", 33-2), collapse=""),
                   "|",
                   sep = "")
regions <- vector("character", length=n)
for (i in 1:n) {
  regions[i] <- paste(
                   paste(rep(" ", start(rir)[i]), collapse=""),
                   paste(rep("-", width(rir)[i]), collapse=""),
                   sep = ""
                   )
}

cat(reference, regions, sep="\n")


[Package biocDatasets version 1.0.0 Index]