gr.sample: Randomly sample 'GRanges' intervals within territory

View source: R/gUtils.R

gr.sampleR Documentation

Randomly sample GRanges intervals within territory

Description

Samples k intervals of length "len" from a pile of GRanges.

  • If k is a scalar then will (uniformly) select k intervals from the summed territory of GRanges

  • If k is a vector of length(gr) then will uniformly select k intervals from each.

Usage

gr.sample(gr, k, wid = 100, replace = TRUE)

Arguments

gr

Granges defining the territory to sample from

k

integer Number of ranges to sample

wid

integer Length of the GRanges element to produce (default = 100)

replace

boolean If TRUE, will bootstrap. If FALSE, otherwise will sample without replacement. (default = TRUE)

Value

GRanges of max length sum(k) [if k is vector) or k*length(gr) (if k is scalar) with labels indicating the originating range.

Note

This is different from GenomicRanges::sample function, which just samples from a pile of GRanges

Author(s)

Marcin Imielinski

Examples


## sample 5 \code{GRanges} of length 10 each from territory of RefSeq genes
gr.sample(reduce(example_genes), k=5, wid=10)


mskilab/gUtils documentation built on June 6, 2023, 12:08 a.m.