binnedaverage - is it possible to add an na.rm option?
1
0
Entering edit mode
Janet Young ▴ 740
@janet-young-2360
Last seen 5.1 years ago
Fred Hutchinson Cancer Research Center,…

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

genomicranges • 768 views
ADD COMMENT
0
Entering edit mode
@herve-pages-1542
Last seen 1 day ago
Seattle, WA, United States

Hi Janet,

A very reasonable request. I just added this to GenomicRanges 1.28.2 (BioC release) and 1.29.4 (BioC devel). Please allow between 24 and 48 hours for these new versions to become available via biocLite().

Cheers,

H.

PS: Nice to see you back here!

ADD COMMENT

Login before adding your answer.

Traffic: 843 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6