Entering edit mode
Vince S. Buffalo
▴
40
@vince-s-buffalo-6592
Last seen 10.3 years ago
Hi All,
I'm thinking there might be a clever way to do something that I'm not
aware
of. The setup is that I frequently find myself using using Views and
viewMeans, viewSums, etc. to calculate summary statistics by tiles on
sequences. I have a GRanges object with 1-width ranges (but this
should
apply more generally), and metadata columns have some measurement (GC
content, pairwise diversity, some quality metric, etc). I need to go
from a
quantitative variable tied to specific ranges to an Rle sequence
across an
entire chromosome to use Views/viewMeans (e.g. the binnedAverages
example
in the How to) . Right now I approach this with something like:
data <- Rle(NA, length=seqlengths(txdb)['chr1'])
data[start(my_rngs)] <- my_rngs$variable # simple, since my features
are
are 1-width
# or more generally:
data2 <- Rle(NA, length=seqlengths(txdb)['chr1'])
data2[ranges(my_rngs)] <- my_rngs$variable
identical(as.vector(data), as.vector(data2)) # returns TRUE
(contingent on
all widths = 1)
Then, I can convert these to Views on a set of bins/tiles created with
tileGenome, and use the viewMean, viewSums, etc. functions (removing
NAs).
So my question is â are there better methods for creating sequence-
length
Rle from metadata columns? Or another way of saying this is taking
some
metadata column corresponding to ranges and mapping it to coordinate
space
(maybe in one call)? It seems like if seqlengths is set in the GRanges
object, there's sufficient information to go directly from a GRanges
metadata column to an Rle vector (and I might be missing a more
obvious
solution). My example assumed a single chromosome, but an approach
that
knows to handle multiple sequences through RleLists seems like it
would be
helpful.
thanks,
Vince
PS: My apologies if you've received this message twice, I had to
resend
after it appears that I sent it to the wrong list.
--
Vince Buffalo
Ross-Ibarra Lab www.rilab.org)
Plant Sciences, UC Davis
[[alternative HTML version deleted]]