request: calculate coverage with weight on RangedData object
0
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 4.5 years ago
Fred Hutchinson Cancer Research Center,…
Hi, I'm trying to calculate coverage using weights on a RangedData object (seems to work for simple IRanges objects, but not on RangedData). I've found a workaround, but wanted to request an enhancement to be able to do this directly without the workaround. I think the code below should show you what I'm talking about. thanks very much, Janet Young ------------------------------------------------------------------- Dr. Janet Young (Trask lab) Fred Hutchinson Cancer Research Center 1100 Fairview Avenue N., C3-168, P.O. Box 19024, Seattle, WA 98109-1024, USA. tel: (206) 667 1471 fax: (206) 667 6524 email: jayoung ...at... fhcrc.org http://www.fhcrc.org/labs/trask/ ------------------------------------------------------------------- library(IRanges) ### coverage with weights works for IRanges object x <- IRanges(start=1:5,end=3:7) coverage(x,weight=1:5) ### 'integer' Rle of length 7 with 7 runs ### Lengths: 1 1 1 1 1 1 1 ### Values : 1 3 6 9 12 9 5 ### but is not so well on RangedData y <- RangedData(IRanges(start=c(1:5,1:5),end=c(3:7,3:7)), space=c(rep("chrA",5),rep("chrB",5)), score=c(1:5,1:5) ) coverage(y) ## works, produces SimpleRleList coverage(y,weight=y$score) ## does not work ### Error in weight[[i]] : subscript out of bounds coverage(y,weight=rep(1,10)) ## does not work ### Error in weight[[i]] : subscript out of bounds ### temporary workaround - iterate through spaces mycov <- list() for (thisspace in names(y)) { mycov[[thisspace]] <- coverage(ranges(y[thisspace]) [[1]],weight=y[thisspace]$score) } mycov ### $chrA ### 'integer' Rle of length 7 with 7 runs ### Lengths: 1 1 1 1 1 1 1 ### Values : 1 3 6 9 12 9 5 ### ### $chrB ### 'integer' Rle of length 7 with 7 runs ### Lengths: 1 1 1 1 1 1 1 ### Values : 1 3 6 9 12 9 5 sessionInfo() R version 2.10.1 (2009-12-14) i386-apple-darwin8.11.1 locale: [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] IRanges_1.4.15
Coverage Cancer IRanges Coverage Cancer IRanges • 916 views
ADD COMMENT

Login before adding your answer.

Traffic: 906 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