Learn R Programming

TFBSTools (version 1.10.3)

sampleRanges: sampleRanges

Description

Sample ranges with same widths of input rannges from a set of subject ranges.

Usage

sampleRanges(inputGRanges, subjectGRanges, ignore.strand=TRUE)

Arguments

inputGRanges
The input GRanges.
subjectGRanges
The subject GRanges.
ignore.strand
When set to TRUE, the strand information is ignoreed during the sampling. Otherwise, the input ranges on positvie strand will only sample from subject ranges on positvie strand.

Value

A GRanges object with the same length and widths of inputGRanges.

Examples

Run this code
  library(GenomicRanges)
  inputGRanges <- GRanges(seqnames=c("chr1", "chr2"), 
                         range=IRanges(start=c(2L, 10L), end=c(6L, 15L)),
                          strand=c("+", "-"))

  subjectGRanges <- GRanges(
                            seqnames=c("chr1", "chr1", "chr1", "chr1", 
                                       "chr2", "chr2"),
                            ranges=IRanges(start=c(20L, 20L, 30L, 30L, 7L, 25L),
                                           end=c(50L, 50L, 32L, 32L,9L, 55L)),
                            strand=c("+","-", "+", "-", "+","-"))
  set.seed(16)
  sampleRanges(inputGRanges, subjectGRanges, ignore.strand=TRUE)
  sampleRanges(inputGRanges, subjectGRanges, ignore.strand=FALSE)

Run the code above in your browser using DataLab