Closed bschilder closed 2 years ago
You can simplify looping over named lists with mapply. This can speed up your code, reduce the number of variables in your namespace (thus conserving memory), and makes it a bit easier to read.
mapply
For example:
ref_in_sample_list <- list() # obtain overlapping peaks for(file in peaklist_tidy){ ref_in_sample <- IRanges::subsetByOverlaps(x = reference_tidy[[1]], ranges = file) ref_in_sample_list <- c(ref_in_sample_list, ref_in_sample) } names(ref_in_sample_list) <- names(peaklist_tidy)
ref_in_sample_list <- mapply(peaklist_tidy, FUN = function(file){ IRanges::subsetByOverlaps(x = reference_tidy[[1]], ranges = file) })
This was actually in my list of things to do, I'll work on it now! Thank you!!
I got things started, so let me make my pushes first. Then you can pull down my changes and so what's left to do
You can simplify looping over named lists with
mapply
. This can speed up your code, reduce the number of variables in your namespace (thus conserving memory), and makes it a bit easier to read.For example:
Before
After