makeGRanges: Make a sorted GRanges object from a dataframe.

Description Usage Arguments Value See Also Examples

View source: R/hiAnnotator.R

Description

The function converts a dataframe into a GRanges object without too much hassle of renaming column names. The function finds column names that sound like seqname, chromosome, start, stop, position, etc and puts them in respective slots to facilitate the conversion of a dataframe to a GRanges object. If more than one column that sounds like start, stop, or position is present, the function will use the first match as the representative. It is recommended to run this function before utilizing any other annotation functions since it will sort the object by chromosome and position for copying annotations back to their respective rows confidently.

Usage

1
2
3
makeGRanges(x, freeze = NULL, positionsOnly = FALSE,
  soloStart = FALSE, chromCol = NULL, strandCol = NULL,
  startCol = NULL, stopCol = NULL, keepFactors = FALSE)

Arguments

x

dataframe to be converted into a GRanges object

freeze

UCSC genome version of the data in x. Default is NULL. This parameter is generally used to populate seqinfo slot of GRanges objects.

positionsOnly

boolean flag indicating to return only position based data or everything from the dataframe. Defaults to FALSE.

soloStart

flag denoting whether only one position based column is available. In other words, only starts are present and no stops. Default=FALSE.

chromCol

use the defined column name for seqname/chromosome based data from the dataframe. Defaults to NULL.

strandCol

use the defined column name for strand or orientation from the dataframe. Defaults to NULL.

startCol

use the defined column name for start coordinate from the dataframe. Defaults to NULL.

stopCol

use the defined column name for stop coordinate from the dataframe. Defaults to NULL and not required if soloStart=TRUE.

keepFactors

keep vectors/columns stored as factors? Defaults to FALSE

Value

a GRanges object converted from x.

See Also

getNearestFeature, getFeatureCounts, getSitesInFeature.

Examples

1
2
3
4
5
6
7
# Convert a dataframe to GRanges object
data(genes)

makeGRanges(genes, soloStart = TRUE)
makeGRanges(genes)
#makeGRanges(genes, freeze = "hg18", soloStart = TRUE)
#makeGRanges(genes, freeze = "hg18")

hiAnnotator documentation built on Nov. 8, 2020, 7:27 p.m.