Question: How do I find the set of a genomicrange? (same as union(gr, gr))
2
gravatar for endrebak852
2.1 years ago by
endrebak852110
github.com/endrebak
endrebak852110 wrote:
library(GenomicRanges)
gr0 <- GRanges(Rle(c("chr2", "chr2", "chr1", "chr3"), c(1, 3, 2, 4)), IRanges(1:10, width=10:1))
union(gr0, gr0)
# GRanges object with 3 ranges and 0 metadata columns:
#      seqnames    ranges strand
#        <Rle> <IRanges>  <Rle>
# [1]     chr2   [1, 10]      *
# [2]     chr1   [5, 10]      *
# [3]     chr3   [7, 10]      *
# -------
#  seqinfo: 3 sequences from an unspecified genome; no seqlengths

The union operation is binary. Is there a unary union method?

genomicranges bioconductor R • 739 views
ADD COMMENTlink modified 2.1 years ago by Michael Dondrup48k • written 2.1 years ago by endrebak852110
5
gravatar for Michael Dondrup
2.1 years ago by
Bergen, Norway
Michael Dondrup48k wrote:

Possibly, you are referring to normalized ranges, see Section 2.1 in https://bioconductor.org/packages/release/bioc/vignettes/IRanges/inst/doc/IRangesOverview.pdf

Then, the function to use is reduce(gr0).

 > reduce(gr0)
GRanges object with 3 ranges and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr2      1-10      *
  [2]     chr1      5-10      *
  [3]     chr3      7-10      *
  -------
  seqinfo: 3 sequences from an unspecified genome; no seqlengths
  > identical(reduce(gr0), union(gr0,gr0))
  [1] TRUE
ADD COMMENTlink modified 2.1 years ago • written 2.1 years ago by Michael Dondrup48k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 958 users visited in the last hour