[BioC] Transformation of Grange object to density per bin

Dario Strbenac D.Strbenac at garvan.org.au
Fri Jan 18 00:00:15 CET 2013


Assuming that you are working with hg19,

library(BSgenome.Hsapiens.UCSC.hg19)

chrLengths <- seqlengths(Hsapiens)
chrLengths <- chrLengths[paste("chr", c(1:22, 'X', 'Y'), sep = '')]
Gcoverage <- coverage(testset.gr)

coverageMeans <- unlist(mapply(function(x, y) 
                 {
		 	starts = seq(1, y, 200)
			ends = starts + 199
                        mean(Views(start = starts, end = ends, subject = Gcoverage[[x]]), na.rm = TRUE)
                 }, names(chrLengths), chrLengths), use.names = FALSE)

> coverageMeans[51]
[1] 0.285
> coverageMeans[52]
[1] 0.765



More information about the Bioconductor mailing list