data.frame2GRanges: Converts a data frame to a GRanges.

View source: R/utils.R

data.frame2GRangesR Documentation

Converts a data frame to a GRanges.

Description

Converting a data.frame to a GRanges object. The data.frame needs columns like chr, start and end (strand is optional). Additional columns may be kept in the GRanges object.

Usage

data.frame2GRanges(df, keepColumns = FALSE, ignoreStrand = FALSE)

Arguments

df

A data.frame with columns chr or seqnames, start, end and optionally a strand column.

keepColumns

In case df has additional columns, should these columns be stored as metadata columns on the return GRanges or should they be discarded.

ignoreStrand

In case df has a strand column, should this column be ignored.

Value

An object of class GRanges

Note

In case df has rownames, they will be used as names for the return object.

Author(s)

Kasper Daniel Hansen khansen@jhsph.edu

Examples

df <- data.frame(chr = "chr1", start = 1:3, end = 2:4,
                 strand = c("+","-","+"))
data.frame2GRanges(df, ignoreStrand = TRUE)

hansenlab/bsseq documentation built on Nov. 6, 2024, 2:59 p.m.