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

as.tbl_interval(x)

# S3 method for tbl_df
as.tbl_interval(x)

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

# S3 method for GRanges
as.tbl_interval(x)

Arguments

x

object to convert to tbl_interval.

Value

tbl_interval()

Examples

# 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))

# }