as.tbl_interval: Coerce objects to tbl_intervals.

Description Usage Arguments Value Examples

View source: R/tbls.r

Description

This is an S3 generic. valr includes methods to coerce tbl_df and GRanges objects.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
as.tbl_interval(x)

## S3 method for class 'tbl_df'
as.tbl_interval(x)

## S3 method for class 'data.frame'
as.tbl_interval(x)

## S3 method for class 'GRanges'
as.tbl_interval(x)

Arguments

x

object to convert to tbl_interval.

Value

tbl_interval()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 
gr <- GenomicRanges::GRanges(
        seqnames = S4Vectors::Rle(
                     c("chr1", "chr2", "chr1", "chr3"),
                     c(1, 1, 1, 1)),
        ranges   = IRanges::IRanges(
                     start = c(1, 10, 50, 100),
                     end = c(100, 500, 1000, 2000),
                     names = head(letters, 4)),
        strand   = S4Vectors::Rle(
                     c("-", "+"), c(2, 2))
      )

as.tbl_interval(gr)

# There are two ways to convert a tbl_interval to GRanges:

gr <- GenomicRanges::GRanges(
        seqnames = S4Vectors::Rle(x$chrom),
        ranges   = IRanges::IRanges(
                     start = x$start + 1,
                     end = x$end,
                     names = x$name),
        strand   = S4Vectors::Rle(x$strand)
        )
# or:

gr <- GenomicRanges::makeGRangesFromDataFrame(dplyr::mutate(x, start = start +1))


## End(Not run)

rnabioco/valr documentation built on Jan. 6, 2019, 9:06 a.m.