New Version of R cannot coerce "GRanges" to "RangesList"
1
1
Entering edit mode
hicklingmeb ▴ 10
@hicklingmeb-15847
Last seen 6.5 years ago

Hi, I have recently updated my R and am now getting an error message when I attempt to convert a GRanges value to a RangesList. This never happened in the older versions. Does anyone know a way around this? I'm using known human polyA sites. Here is a quick snippet of the code I've been using: 

ax1 = data.frame(reducedHumanPas, stringsAsFactors = F)
ax1p = ax1[ax1$strand == "+",]
ax1pr = makeGRangesFromDataFrame(ax1p, keep.extra.columns=TRUE, ignore.strand=FALSE, seqinfo=seq_info_object1, seqnames.field="seqnames", start.field="start", end.field="end", strand.field="strand", starts.in.df.are.0based=F)

ax1n = ax1[ax1$strand == "-",]
ax1nr = makeGRangesFromDataFrame(ax1n, keep.extra.columns=TRUE, ignore.strand=FALSE, seqinfo=seq_info_object1, seqnames.field="seqnames", start.field="start", end.field="end", strand.field="strand", starts.in.df.are.0based=F)

wp = as(ax1pr, "RangesList")
wn = as(ax1nr, "RangesList")

Error in as(ax1pr, "RangesList") : 
  no method or default for coercing “GRanges” to “RangesList”

The above is the error code I receive when I try and execute the final two commands. Is there a way around this? Many thanks. 

grangeslist irangeslist • 2.9k views
ADD COMMENT
0
Entering edit mode

Is there such a class as RangesList? Do you mean GRangesList?

ADD REPLY
0
Entering edit mode

Yes, RangesList is a thing. The Views() function could take an RLE coverage object and a RangesList, and return coverages on the ranges. I have a bunch of code to find coverage on regions that's all broken now because I can't convert GRanges to RangesList. Like hicklingmeb, I'm looking for whatever is the modern solution.

ADD REPLY
2
Entering edit mode
@herve-pages-1542
Last seen 8 hours ago
Seattle, WA, United States

Hi,

In BioC 3.7, the RangesList class was replaced with the IntegerRangesList class. So:

library(GenomicRanges)
gr <- GRanges(Rle(c("A", "B"), 3), IRanges(9:4, 10))
gr
# GRanges object with 6 ranges and 0 metadata columns:
#       seqnames    ranges strand
#          <Rle> <IRanges>  <Rle>
#   [1]        A      9-10      *
#   [2]        A      8-10      *
#   [3]        A      7-10      *
#   [4]        B      6-10      *
#   [5]        B      5-10      *
#   [6]        B      4-10      *
#   -------
#   seqinfo: 2 sequences from an unspecified genome; no seqlengths

as(gr, "IntegerRangesList")
# IRangesList of length 2
# $A
# IRanges object with 3 ranges and 1 metadata column:
#           start       end     width | strand
#       <integer> <integer> <integer> |  <Rle>
#   [1]         9        10         2 |      *
#   [2]         8        10         3 |      *
#   [3]         7        10         4 |      *
#
# $B
# IRanges object with 3 ranges and 1 metadata column:
#           start       end     width | strand
#       <integer> <integer> <integer> |  <Rle>
#   [1]         6        10         5 |      *
#   [2]         5        10         6 |      *
#   [3]         4        10         7 |      *

Cheers,

H.

ADD COMMENT
0
Entering edit mode

I am having issues using IRanges objects. Previously, I was able to give an IRanges object to Rsamtools::ScanBamParam(), and now get the 'no method or default for coercing “IRanges” to “IntegerRangesList” ' error.

ADD REPLY
0
Entering edit mode

Are you sure you used an IRanges() instance? The argument needs to know the chromosome to select, so something like IRangesList(chr1=IRanges(100, 1000)) would make sense, but IRanges(100, 1000) would not... and whether or not it made sense in the past, I think you don't have a choice but to use IRangesList / GRanges.

ADD REPLY
0
Entering edit mode

Previously, I passed a named IRanges object. Thanks for the feedback.

ADD REPLY

Login before adding your answer.

Traffic: 554 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6