sampleRanges {TFBSTools} | R Documentation

## 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`.

### Author(s)

Ge Tan

### Examples

      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)

[Package TFBSTools version 1.18.0 Index]