Question: Build GPos from IPos
0
gravatar for maltethodberg
9 months ago by
maltethodberg130
Sweden
maltethodberg130 wrote:

It would be great if one could construct a GPos from and IPos, similarly to how one can construct a GRanges from an IRanges:

GRanges(seqnames=rep("chr1", 3), ranges=IRanges(start=1:3, width=1)) # Works

GPos(seqnames=rep("chr1", 3), ranges=IPos(1:3)) # Doesn't work

genomicranges granges gpos • 230 views
ADD COMMENTlink modified 4 weeks ago by Hervé Pagès ♦♦ 14k • written 9 months ago by maltethodberg130
Answer: Build GPos from IPos
2
gravatar for Hervé Pagès
9 months ago by
Hervé Pagès ♦♦ 14k
United States
Hervé Pagès ♦♦ 14k wrote:

This is another reasonable feature request. Also added to the TODO list: https://github.com/Bioconductor/GenomicRanges/issues/13

Thanks,

H.

ADD COMMENTlink written 9 months ago by Hervé Pagès ♦♦ 14k
Answer: Build GPos from IPos
2
gravatar for Hervé Pagès
4 weeks ago by
Hervé Pagès ♦♦ 14k
United States
Hervé Pagès ♦♦ 14k wrote:

Hi,

This works with the latest devel version of GenomicRanges (1.37.13):

GPos("A", pos=IPos("3-8"))
# StitchedGPos object with 9 positions and 0 metadata columns:
#       seqnames       pos strand
#          <Rle> <integer>  <Rle>
#   [1]        A         3      *
#   [2]        A         4      *
#   [3]        A         5      *
#   [4]        A         6      *
#   [5]        A         7      *
#   [6]        A         8      *
#   -------
#   seqinfo: 1 sequence from an unspecified genome; no seqlengths

GPos("chr1", pos=IPos(1:3))
# UnstitchedGPos object with 3 positions and 0 metadata columns:
#       seqnames       pos strand
#          <Rle> <integer>  <Rle>
#   [1]     chr1         1      *
#   [2]     chr1         2      *
#   [3]     chr1         3      *
#   -------
#  seqinfo: 1 sequence from an unspecified genome; no seqlengths

However, please note that the 2nd argument of the GPos() constructor function is named pos rather than ranges:

args(GRanges)
# function (seqnames = NULL, ranges = NULL, strand = NULL, ..., 
#     seqinfo = NULL, seqlengths = NULL) 
# NULL

args(GPos)
# function (seqnames = NULL, pos = NULL, strand = NULL, ...,
#     seqinfo = NULL,  seqlengths = NULL, stitch = NA) 
# NULL

Also note that IPos and GPos objects now exist in 2 flavors: unstitched and stitched. The stitched flavor corresponds to what IPos and GPos objects used to be. See ?IPos and ?GPos for more information.

Best,

H.

ADD COMMENTlink modified 26 days ago • written 4 weeks ago by Hervé Pagès ♦♦ 14k
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 16.09
Traffic: 205 users visited in the last hour