splitByFacets-method: split a GRanges by formula

Description Usage Arguments Details Value Author(s) Examples

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

1
2
3
4
5
6
7
8
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

biovizBase documentation built on Nov. 8, 2020, 8:01 p.m.