I have a Run length encoded vector representing some value at every position on the genome, in order. As a toy example suppose I had just one chromosome of length 10, then I would have a vector looking like

```
library(GenomicRanges)
set.seed(1)
toyData = Rle(sample(1:3,10,replace=TRUE))
```

I would like to coerce this into a GRanges object. The best I can come up with is

```
gr = GRanges('toyChr',IRanges(start(toyData)-1,
width=runLength(toyData)),
toyData = runValue(toyData))
```

which works, but is quite slow. Is there a faster way to construct the same object?

For a chromosome length object, when I run this

topData = Rle(sample(1:3,1e8,replace=TRUE))

microbenchmark(GRanges('toyChr',IRanges(start(toyData)-1, width=runLength(toyData), toyData = runValue(toyData)), times = 3)

It takes roughly 15 seconds to convert

Unit: seconds

expr

GRanges("toyChr", IRanges(start(toyData) - 1, width = runLength(toyData)), toyData = runValue(toyData))

min lq mean median uq max neval

14.8322 15.21285 15.58755 15.5935 15.96522 16.33694 3

Thanks, I edited my answer.