df.to.gr: Convert a data.frame to a GRanges object

Description Usage Arguments Value Author(s) Examples

View source: R/ngscopy.R

Description

Convert a data.frame to a GRanges object

Usage

1
2
3
df.to.gr(x, which.chr = "chr", which.start = "start", which.end = "end",
  which.width = "width", which.name = "name", chrlength = NULL,
  start0 = TRUE)

Arguments

x

data.frame or matrix

which.chr

character, the column name of 'chr'

which.start

character, the column name of 'start'

which.end

character, the column name of 'end'

which.width

character, the column name of 'width'

which.name

character, the column name of 'name'

chrlength

numeric, the lengths of the chromosomes

start0

logical, wheter the 'start' is 0-based.

Value

a GRanges object

Author(s)

Xiaobei Zhao

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
x <- data.frame(
  chr=c('chr1','chr2'),start=0,end=100,
  name=paste0('ID',1:2),score=1:2
  )
df.to.gr(x)
df.to.gr(x,chrlength=c(chr1=1000,chr2=1200))

## End(Not run)

Example output

Loading required package: stats4
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: S4Vectors

Attaching package: 'S4Vectors'

The following object is masked from 'package:base':

    expand.grid

Loading required package: IRanges
Loading required package: GenomeInfoDb
GRanges object with 2 ranges and 1 metadata column:
Found more than one class "List" in cache; using the first, from namespace 'Xmisc'
Also defined by 'S4Vectors'
      seqnames    ranges strand |     score
         <Rle> <IRanges>  <Rle> | <integer>
  ID1     chr1  [1, 100]      * |         1
  ID2     chr2  [1, 100]      * |         2
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths
GRanges object with 2 ranges and 1 metadata column:
Found more than one class "List" in cache; using the first, from namespace 'Xmisc'
Also defined by 'S4Vectors'
      seqnames    ranges strand |     score
         <Rle> <IRanges>  <Rle> | <integer>
  ID1     chr1  [1, 100]      * |         1
  ID2     chr2  [1, 100]      * |         2
  -------
  seqinfo: 2 sequences from an unspecified genome

NGScopy documentation built on May 6, 2019, 2:43 a.m.