xGR | R Documentation

## Function to create a GRanges object given a list of genomic regions

### Description

`xGR` is supposed to create a GRanges object given a list of genomic regions.

### Usage

    xGR(data, format = c("chr:start-end", "data.frame", "bed", "GRanges"),
    build.conversion = c(NA, "hg38.to.hg19", "hg18.to.hg19"),
    add.name = T, remove.mcol = F, include.strand = F, verbose = T,
    RData.location = "http://galahad.well.ox.ac.uk/bigdata")

### Arguments

`data`

input genomic regions (GR). If formatted as "chr:start-end" (see the next parameter 'format' below), GR should be provided as a vector in the format of 'chrN:start-end', where N is either 1-22 or X, start (or end) is genomic positional number; for example, 'chr1:13-20'. If formatted as a 'data.frame', the first three columns correspond to the chromosome (1st column), the starting chromosome position (2nd column), and the ending chromosome position (3rd column). If the format is indicated as 'bed' (browser extensible data), the same as 'data.frame' format but the position is 0-based offset from chromomose position. If the genomic regions provided are not ranged but only the single position, the ending chromosome position (3rd column) is allowed not to be provided. The data could also be an object of 'GRanges' (in this case, formatted as 'GRanges')

`format` | the format of the input data. It can be one of "chr:start-end", "data.frame", "bed" or "GRanges"
`build.conversion` | the conversion from one genome build to another. The conversions supported are "hg38.to.hg19" and "hg18.to.hg19". By default it is NA (no need to do so)
`add.name` | logical to add names. By default, it sets to true
`remove.mcol` | logical to remove meta-columns. By default, it sets to false
`include.strand` | logical to include strand. By default, it sets to false. It only works when the format is "data.frame" or "bed" and the input data has 4 columns
`verbose` | logical to indicate whether the messages will be displayed in the screen. By default, it sets to true for display
`RData.location` | the characters to tell the location of built-in RData files. See `xRDataLoader` for details

### Value

a GenomicRanges object

### See Also

`xRDataLoader`

### Examples

    ## Not run:
    # Load the XGR package and specify the location of built-in data
    library(XGR)
    RData.location <- "http://galahad.well.ox.ac.uk/bigdata"

    # a) provide the genomic regions
    ## load ImmunoBase
    ImmunoBase <- xRDataLoader(RData.customised='ImmunoBase',
    RData.location=RData.location)
    ## get lead SNPs reported in AS GWAS and their significance info (p-values)
    gr <- ImmunoBase$AS$variant
    df <- as.data.frame(gr, row.names=NULL)
    chr <- df$seqnames
    start <- df$start
    end <- df$end
    data <- paste(chr,':',start,'-',end, sep='')

    # b) create a GRanges object
    GR <- xGR(data=data, format="chr:start-end",
    RData.location=RData.location)

    ## End(Not run)