colToRanges-methods: Coerce a column to a GRanges object

colToRangesR Documentation

Coerce a column to a GRanges object

Description

Coerce a column to a GRanges object from a rectangular object

Usage

colToRanges(x, ...)

## S4 method for signature 'DataFrame'
colToRanges(x, var, seqinfo = NULL, ...)

## S4 method for signature 'GRanges'
colToRanges(x, var, ..., keep_metadata = TRUE)

## S4 method for signature 'data.frame'
colToRanges(x, var, seqinfo = NULL, ...)

Arguments

x

A data-frame or GRanges object containing the column to coerce

...

Used to pass arguments to lower-level functions

var

The name of the column to coerce

seqinfo

A seqinfo object to be applied to the new GRanges object. Ignored if the column is already a GRanges object

keep_metadata

logical(1) If the original object is a GRanges object, retain all metadata from the original ranges in the replaced ranges

Details

Take a data.frame-like object and coerce one column to a GRanges object, setting the remainder as the mcols. A particularly useful application of this is when you have a GRanges object with one mcol being a secondary GRanges object.

Alternatively, if you have a data.frame with GRanges represented as a character column, this provides a simple method of coercion. In this case, no Seqinfo element will be applied to the GRanges element.

Value

A GenomicRanges object

Examples

set.seed(73)
x <- GRanges(c("chr1:1-10", "chr1:6-15", "chr1:51-60"))
seqinfo(x) <- Seqinfo("chr1", 60, FALSE, "Example")
df <- data.frame(logFC = rnorm(3), logCPM = rnorm(3,8), p = 10^-rexp(3))
mcols(x) <- df
gr <- mergeByCol(x, col = "logCPM", pval = "p")
colToRanges(gr, "keyval_range")


steveped/chipExtra documentation built on Aug. 1, 2024, 12:33 a.m.