ranges_for_coords: Construct GRanges objects from coordinate strings

Description Usage Arguments Details Value See Also Examples

View source: R/utils.R

Description

Construct GRanges objects from coordinate strings

Usage

1
2
ranges_for_coords(coord_strings, meta_data_df = NULL,
  with_names = FALSE)

Arguments

coord_strings

A list of coordinate strings (in the form "chr1:500000-1000000")

meta_data_df

A data frame with any meta data columns you want included with the ranges. Must be in the same order as coord_strings.

with_names

logical - should meta data include coordinate string (field coord_string)?

Details

Coordinate strings consist of three pieces of information: chromosome, start, and stop. These pieces of information can be separated by the characters ":", "_", or "-". Commas will be removed, not used as separators (ex: "chr18:8,575,097-8,839,855" is ok).

Value

GRanges object of the input strings

See Also

GRanges-class

Examples

1
2
3
4
5
6
7
  ran1 <- ranges_for_coords("chr1:2039-30239", with_names = TRUE)
  ran2 <- ranges_for_coords(c("chr1:2049-203902", "chrX:489249-1389389"),
                            meta_data_df = data.frame(dat = c("1", "X")))
  ran3 <- ranges_for_coords(c("chr1:2049-203902", "chrX:489249-1389389"),
                            with_names = TRUE,
                            meta_data_df = data.frame(dat = c("1", "X"),
                                           stringsAsFactors = FALSE))

cicero documentation built on Dec. 7, 2018, 6 p.m.