On Thu, Jul 23, 2009 at 11:06 AM, Simon Anders <anders@ebi.ac.uk> wrote:

> Michael Lawrence wrote:
> > Oops, I meant:
> > y <- rep(score(chr1), width(chr1))
> >
> >
> >> x <- as.integer(unlist(ranges(chr1)))
> >> lo <- loess(y ~ x)
>
>
> But what if the intervals in the wiggle file contain gaps? That's
> perfectly legal, after all.
>

This is what the as.integer(...) is handling. 'x' will contain the actual
position of each value in 'y'.


>
> I also fail to see what the effect of as.integer on IRanges is supposed
> to be. For my wiggle file, I simply get
>
> > head( as.integer( unlist( ranges(w) ) ) )
> [1] 2 3 4 5 6 7
>

It's like calling seq(start, end) on each range in the IRanges and
concatenating the result.

It could be implemented as:
do.call("c", lapply(seq_along(chr1), function(i) seq(start(chr1)[i],
end(chr1)[i])))

But it's actually implemented in compiled code and is very fast.

> ir <- IRanges(c(5, 12), c(10, 15))
> as.integer(ir)
 [1]  5  6  7  8  9 10 12 13 14 15


>
>
>  Simon
>

	[[alternative HTML version deleted]]

