Thanks Herve, that's very helpful, and that does answer my question. Thanks.
Andrew 2010/6/28 Hervé Pagès <[email protected]> > Hi Andrew, > > > On 06/27/2010 08:30 PM, Andrew Yee wrote: > >> Herve, thanks for your help. To follow up some more, is there a way to >> directly specify the start and end in coverage(), without using shift >> and width? >> > > No, you need to use shift and width. However, translating your > start/end into shift/width is straightforward. If you have the > start and end, do: > > coverage(r, shift=1-start, width=end-start+1) > > > >> Or alternatively, as Martin suggests, >> >> r <- IRanges(start = c(30, 60, 70, 100), width = c(20, 18, 20, 18)) >> roi = IRanges(c(60, 68), width=5) ## 'regions of interest' >> v = Views(coverage(r), roi) >> >> but in this case, extract the coverage information from v in the above >> example? >> > > 'v' is a set of views defined on the full coverage vector for 'r': > > > v > Views on a 117-length Rle subject > > views: > start end width > [1] 60 64 5 [1 1 1 1 1] > [2] 68 72 5 [1 1 2 2 2] > > To extract the coverage spanning the i-th view, use v[[i]]: > > > v[[1]] > 'integer' Rle of length 5 with 1 run > Lengths: 5 > Values : 1 > > v[[2]] > 'integer' Rle of length 5 with 2 runs > Lengths: 2 3 > Values : 1 2 > > Does this answer your question? > > H. > > >> Thanks, >> Andrew >> >> >> 2010/6/25 Hervé Pagès <[email protected] <mailto:[email protected]>> >> >> >> Hi Andrew, >> >> One way to specify directly the window of interest when calling >> coverage() is to use the 'shift' and 'width' arguments. >> 'shift' allows you to shift the ranges contained in the first >> argument to the left (negative shift) or to the right (positive >> shift) before extracting the coverage: >> >> ## Coverage from positions 60 to 65: >> > as.integer(coverage(r, shift=-59, width=6)) >> [1] 1 1 1 1 1 1 >> >> ## Coverage from positions 68 to 73: >> > as.integer(coverage(r, shift=-67, width=6)) >> [1] 1 1 2 2 2 2 >> >> Note that coverage(r, shift=-59, width=6) is equivalent to >> coverage(shift(r, -59), width=6). >> >> Cheers, >> H. >> >> >> >> On 06/23/2010 02:02 PM, Andrew Yee wrote: >> >> Hi, I'm trying to figure out the coverage for a specific range. >> >> Take for example, >> >> r<- IRanges(start = c(30, 60, 70, 100), width = c(20, 18, 20, 18)) >> >> I'm interested in the coverage from positions 60 to 65, which in >> this case >> is 1. I'm also interested in the coverage say from positions 68 >> to 73, >> which goes from 1 to 2. >> >> While I can use coverage(r) and then use runLength() and >> runValue() to >> ultimately extract this information, is there a way to use >> coverage so that >> you can directly specify the positions of interest? >> >> Thanks, >> Andrew >> >> sessionInfo() >> >> R version 2.11.0 (2010-04-22) >> x86_64-unknown-linux-gnu >> >> locale: >> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C >> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 >> [5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8 >> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C >> [9] LC_ADDRESS=C LC_TELEPHONE=C >> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods >> base >> >> other attached packages: >> [1] IRanges_1.6.0 >> >> loaded via a namespace (and not attached): >> [1] tools_2.11.0 >> >> [[alternative HTML version deleted]] >> >> _______________________________________________ >> Bioc-sig-sequencing mailing list >> [email protected] >> <mailto:[email protected]> >> >> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing >> >> >> >> > > -- > Hervé Pagès > > Program in Computational Biology > Division of Public Health Sciences > > Fred Hutchinson Cancer Research Center > 1100 Fairview Ave. N, M2-B876 > P.O. Box 19024 > Seattle, WA 98109-1024 > > E-mail: [email protected] > Phone: (206) 667-5791 > Fax: (206) 667-1319 > [[alternative HTML version deleted]]
_______________________________________________ Bioc-sig-sequencing mailing list [email protected] https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
