I am trying to calculate the mappability adjusted length of introns as described by Boutz et al.
Briefly, for each intron I wish to calculate the length minus the number of bases that are non-uniquely mappable. Mappability tracks can be downloaded as bigWigs from here. The the score at each base is 1/number of mapping positions, so 1 indicates a read can be uniquely mapped at this location.
I am struggling to do this computation in either a reasonable amount of time, or a reasonable amount of memory.
First I tried importing the whole bigwig:
library(rtracklayer)
mappability <- import(BigWigFile("wgEncodeCrgMapabilityAlign50mer.bigWig"),
as="NumericList",
selection=BigWigSelection(intron_ranges))
where intron_ranges
is a GRanges
object with the introns (about 800,000 of them).
This used way too much memory, and soon caused by machine to fall over.
Second I tried processing one intron at a time:
mappability_file = BigWigFile("wgEncodeCrgMapabilityAlign50mer.bigWig")
effective_length <- function (gr) {
intron_selection <- BigWigSelection(gr)
scores <- import(mappability_file, as="NumericList", selection=intron_selection)
non_unique <- sum(scores[[1]] < 1.0)
eff_len = width(gr)[1] - non_unique
return(eff_len)
}
mappability <- sapply(intron_ranges, effective_length)
This has been running for hours and shows no sign of finishing.
Is there a way to do this that uses less than, say 4GB of RAM, but finishes in say less than 30 minutes? It feels like there should be.
I'm not tied to R, just what I've tried so far. Happy with answers using binary packages, common shell tools, python or R.
GRanges
isn’t all that much (I’m working with repeat elements, I have a lot more). … What I’m trying to say: time to upgrade your hardware. $\endgroup$ – Konrad Rudolph Jun 14 '17 at 10:17