biovizBase (version 1.20.0)

splitByFacets: 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

"splitByFacets"(object, facets) "splitByFacets"(object, facets) "splitByFacets"(object, facets) "splitByFacets"(object, facets)

Arguments

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

Value

A GRangesList.

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.

Examples

Run this code
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)

Run the code above in your browser using DataCamp Workspace