dtToGr {GenomicDistributions} | R Documentation

## Converts a data.table (DT) object to a GenomicRanges (GR) object. Tries to be intelligent, guessing chr and start, but you have to supply end or other columns if you want them to be carried into the GR.

### Description

Converts a data.table (DT) object to a GenomicRanges (GR) object. Tries to be intelligent, guessing chr and start, but you have to supply end or other columns if you want them to be carried into the GR.

### Usage

    dtToGr(
      DT,
      chr = "chr",
      start = "start",
      end = NA,
      strand = NA,
      name = NA,
      splitFactor = NA,
      metaCols = NA
    )

### Arguments

`DT` | A data.table representing genomic regions.
`chr` | A string representing the chromosome column.
`start` | A string representing the name of the start column.
`end` | A string representing the name of the end column.
`strand` | A string representing the name of the strand column.
`name` | A string representing the name of the name column.
`splitFactor` | A string representing the name of the column to use to split the data.table into multiple data.tables.
`metaCols` | A string representing the name of the metadata column(s) to include in the returned GRanges object.

### Value

A GRanges object.

### Examples

    start1 = c(seq(from=1, to = 2001, by = 1000), 800)
    chrString1 = c(rep("chr1", 3), "chr2")
    dt = data.table::data.table(chr=chrString1,
                                start=start1,
                                end=start1 + 250)
    newGR = dtToGr(dt)

[Package GenomicDistributions version 1.2.0 Index]