On 7 January 2013 16:00, Dario Strbenac <D.Strbenac@garvan.org.au> wrote:

> Anything neater than this available ?
>
> g <- GRanges(c("chr1", "chr2"), IRanges(c(10, 50), c(15, 55)), scores =
> c(20, 10))
> seqlengths(g) <- c(100, 100)
> chrRanges <- split(g, seqnames(g))
> lapply(chrRanges, function(x)
> {
>     scoreVect <- rep(NA, seqlengths(x)[1])
>     invisible(mapply(function(st, end, score) scoreVect[st:end] <<- score,
> start(x), end(x), values(x)[,1]))
>     Rle(scoreVect)
> })
>
> Then, code to define views on these Rle and calculate view summaries.
>
>
Hey Dario,

If I understand what you want to do correctly (your goal is not obvious)
this one liner should work for integer/numeric metadata columns, and even
handles overlapping scores gracefully.

#define the ranges/scores
g <- GRanges(c("chr1", "chr2"), IRanges(c(10, 50), c(15, 55)), scores =
c(20, 10))
seqlengths(g) <- c(100, 100)

#Rles of scores
coverage(g, weight=values(g)$scores)

Cheers,
Aaron


> --------------------------------------
> Dario Strbenac
> PhD Student
> University of Sydney
> Camperdown NSW 2050
> Australia
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>



-- 
Aaron Statham
Postgraduate Scholar, Cancer Epigenetics
Garvan Institute of Medical Research   Tel: (02) 9295 8393
384 Victoria St Darlinghurst 2010   Fax: (02) 9295 8316
NSW Australia         email: a.statham@garvan.org.au

	[[alternative HTML version deleted]]

