Hi there,
I'm using binnedAverage, and would love to see an na.rm option added if possible. I do have a hacked version of binnedAverage that I can use instead, but thought I'd suggest adding na.rm as an enhancement for the existing function.
My motivation is that I have a set of SNP genotype frequencies at points along the genome, and want to get windowed averages so I can plot them. Some fake code is below. It's possible I'm also missing a better way to do this - I'm very happy to hear alternative suggestions.
Thanks for considering it!
Janet
###
library(GenomicRanges)
library(BSgenome.Scerevisiae.UCSC.sacCer2)
#### make 20kb sliding windows on chrI
myWindows <- tileGenome(seqlengths(Scerevisiae), tilewidth=20000, cut.last.tile.in.chrom=TRUE)
myWindows <- myWindows[which(seqnames(myWindows)=="chrI")]
#### make some fake SNPs. for each one, we measure allele frequency in a pooled sample (call that parent1freq).
mySNPs <- GRanges(seqnames="chrI", ranges=IRanges( start=sort(sample(seqlengths(Scerevisiae)["chrI"],400)), width=1), seqinfo=seqinfo(Scerevisiae))
values(mySNPs)[,"parent1freq"] <- round(runif(400),3)
#### want window averages of parent1freq
mySNPs_Rle <- mcolAsRleList(mySNPs, "parent1freq")
binnedAverage(myWindows, mySNPs_Rle, "parent1freq")
### but we get NAs for all windows, because there's no na.rm option