7.0 years ago by
Not in the category of ready-made, but...
I have done this in R, but my code isn't really pretty. I'm sure there's better ways to do it in R (probably not involving slow for loops), but I'm still learning to use all these sequencing packages... Here's some crappy combination of R code and pseudocode as a start. Maybe someone else will be so annoyed by this that they post actual nice R code.
#First, I don't actually know if I'm using all these packages, I just include them in case.
#read in a bam file
#summarize into a coverage Rle
cvg <- coverage(temp)
#may want to scale coverage here based on number of reads
#then I loop through a bed file of genes pulling out the coverage values for each and sticking them in a data frame
for each gene i
#use approx to create the bins, in this case 20... and save it into some data frame...
Additionally you need to remember to use rev() on the coverage values for genes on the C/- strand... Also if you're adding bases up and downstream of a gene you need to check that you don't go past the start or end of the chromosome.
You may also take a look at the R package Repitools for a possibly more ready-made solution, but I haven't tried it...