Last data update: 2014.03.03
|
R: Transform GRangesList to GRanges
Transform GRangesList to GRanges
Description
Transform GRangesList to GRanges.
Usage
flatGrl(object, indName = "grl_name")
Arguments
object |
a GRangesList object.
|
indName |
column named by 'indName' that groups the records by their
original element in 'object'.
|
Details
This method is different from default stack , it integrate
elementMetadata of GRangesList to the final coerced GRanges .
Value
A GRanges object.
Author(s)
Tengfei Yin
Examples
library(GenomicRanges)
gr1 <- GRanges("chr1", IRanges(1:10, width = 5))
gr2 <- GRanges("chr2", IRanges(1:10, width = 5))
obj <- GRangesList(gr1, gr2)
values(obj) <- data.frame(a = 1:2, b = letters[1:2])
stack(obj)
flatGrl(obj)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(biovizBase)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/biovizBase/flatGrl.Rd_%03d_medium.png", width=480, height=480)
> ### Name: flatGrl
> ### Title: Transform GRangesList to GRanges
> ### Aliases: flatGrl
>
> ### ** Examples
>
> library(GenomicRanges)
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, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, 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, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Loading required package: S4Vectors
Loading required package: stats4
Attaching package: 'S4Vectors'
The following objects are masked from 'package:base':
colMeans, colSums, expand.grid, rowMeans, rowSums
Loading required package: IRanges
Loading required package: GenomeInfoDb
> gr1 <- GRanges("chr1", IRanges(1:10, width = 5))
> gr2 <- GRanges("chr2", IRanges(1:10, width = 5))
> obj <- GRangesList(gr1, gr2)
> values(obj) <- data.frame(a = 1:2, b = letters[1:2])
> stack(obj)
GRanges object with 20 ranges and 1 metadata column:
seqnames ranges strand | sample
<Rle> <IRanges> <Rle> | <Rle>
[1] chr1 [1, 5] * | 1
[2] chr1 [2, 6] * | 1
[3] chr1 [3, 7] * | 1
[4] chr1 [4, 8] * | 1
[5] chr1 [5, 9] * | 1
... ... ... ... . ...
[16] chr2 [ 6, 10] * | 2
[17] chr2 [ 7, 11] * | 2
[18] chr2 [ 8, 12] * | 2
[19] chr2 [ 9, 13] * | 2
[20] chr2 [10, 14] * | 2
-------
seqinfo: 2 sequences from an unspecified genome; no seqlengths
> flatGrl(obj)
GRanges object with 20 ranges and 3 metadata columns:
seqnames ranges strand | grl_name a b
<Rle> <IRanges> <Rle> | <Rle> <integer> <factor>
[1] chr1 [1, 5] * | 1 1 a
[2] chr1 [2, 6] * | 1 1 a
[3] chr1 [3, 7] * | 1 1 a
[4] chr1 [4, 8] * | 1 1 a
[5] chr1 [5, 9] * | 1 1 a
... ... ... ... . ... ... ...
[16] chr2 [ 6, 10] * | 2 2 b
[17] chr2 [ 7, 11] * | 2 2 b
[18] chr2 [ 8, 12] * | 2 2 b
[19] chr2 [ 9, 13] * | 2 2 b
[20] chr2 [10, 14] * | 2 2 b
-------
seqinfo: 2 sequences from an unspecified genome; no seqlengths
>
>
>
>
>
> dev.off()
null device
1
>
|