[BioC] Lapply for two GRanges objects?

Hollis Wright wrighth at ohsu.edu
Mon Mar 28 23:41:02 CEST 2011


Hello; I apologize if this is an obvious question or more suited for the general R list, but I have not been able to find a good solution with the Google: it is possible to use lapply or relatives to speed up overlapping of multiple GRanges objects? Specifically, I'm getting methylation values from bisulfite sequencing CpGs over specific windows in the genome and I need to calculate means across the windows, so for right now what I have been doing is basically: 

for(i <= length(methyl))
methlymean <- mean(subsetByOverlaps(methyl, windows[i]);

but this is fairly slow. I tried something like: 


m <- lapply(windows, methylmeans(methyl, windows)

and defining:


methylmeans <- function(methyl, windows)
{
        return(mean(subsetByOverlaps(methyl, windows)@elementMetadata$methyl));
}

but this doesn't work. Mapply doesn't work since the window and methyl sizes aren't the same. Any thoughts? Is there anything inbuilt into GRanges for this kind of case?

Hollis Wright, PhD
Knight Cancer Center
Oregon Health and Science University


More information about the Bioconductor mailing list