-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could GenomicRanges::binnedAverage()
be reused for other purposes?
#77
Comments
I just tried to use this function to compute averages for 15 million bins. |
I posted this function here without any warranty that works efficiently for all uses cases. Please keep in mind this is not part of Nevertheless, library(GenomicRanges)
bins <- unlist(tileGenome(seqinfo(BSgenome.Hsapiens.UCSC.hg38::Hsapiens), ntile=15e6))
signal <- GRanges("chr1:1") # a phony signal track
seqinfo(signal) <- seqinfo(bins)
system.time({
avg <- binnedAverage(bins, coverage(signal), "average_coverage")
})
|
Btw I just tried the function above ( system.time({
avg <- binnedView(bins, coverage(signal), "average_coverage", fun=IRanges::viewMeans)
})
user system elapsed
2.213 0.124 2.338 Perhaps your data (or data structures) are innappropriate? |
I must be doing something wrong then. I am using an Rle object. |
Hi Herve,
this is more of a suggestion rather than a bug.
Would it make sense to make the
binnedAverage()
function more general, in a way that it could compute more than just the mean? If I understand the code, it's relatively straightforward to call any function inIRanges::view*()
.Something like this (please notice the new parameter at the end of the header. Defaults to
IRanges::viewMeans
to mimic the behavior ofbinnedAveage()
):This would enable other ways of aggregating signal in bins (eg. by setting
fun=IRanges::viewSums
).cheers,
Sergi
The text was updated successfully, but these errors were encountered: