splitByFacets {biovizBase} | R Documentation

## split a GRanges by formula

### Description

Split a GRanges by formula into GRangesList. Parse variables in formula and form a interaction factors then split the `GRanges` by the factos.

### Usage

    ## S4 method for signature 'GRanges,formula'
    splitByFacets(object, facets)
    ## S4 method for signature 'GRanges,GRanges'
    splitByFacets(object, facets)
    ## S4 method for signature 'GRanges,NULL'
    splitByFacets(object, facets)
    ## S4 method for signature 'GRanges,missing'
    splitByFacets(object, facets)

### Arguments

`object` | `GRanges` object.
`facets` | formula object, such as . ~ seqnames. Or `GRanges` object, or `NULL`.

### Details

if facets is formula, factors are crreated based on interaction of variables in formula, then split it with this factor. If facets is `GRanges` object, it first subset the original data by facets `GRanges`, then split by each region in the facets. If facets is `NULL`, split just by seqnames. This function is used to perform computation in conjunction with facets argments in higher level graphic function.

### Value

A `GRangesList`.

### Author(s)

Tengfei Yin

### Examples

    library(GenomicRanges)
    N <- 1000
    gr <- GRanges(seqnames =
                  sample(c("chr1", "chr2", "chr3"),
                         size = N, replace = TRUE),
                  IRanges(
                          start = sample(1:300, size = N, replace = TRUE),
                          width = sample(70:75, size = N,replace = TRUE)),
                  strand = sample(c("+", "-", "*"), size = N,
                    replace = TRUE),
                  value = rnorm(N, 10, 3), score = rnorm(N, 100, 30),
                  sample = sample(c("Normal", "Tumor"),
                    size = N, replace = TRUE),
                  pair = sample(letters, size = N,
                    replace = TRUE))
    facets <- sample ~ seqnames
    splitByFacets(gr, facets)
    splitByFacets(gr)
    gr.sub <- GRanges("chr1", IRanges(c(1, 200, 250), width = c(50, 10,
    30)))
    splitByFacets(gr, gr.sub)

[Package biovizBase version 1.34.1 Index]