Created
November 20, 2014 22:54
-
-
Save Jfortin1/cc03d5ecfa9cccc402f2 to your computer and use it in GitHub Desktop.
Extract a block from bigWig files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extract.block <- function(files, chr, start, end, verbose = TRUE){ | |
rl <- IRanges::RangesList(IRanges::IRanges(start=start, end=end)) | |
names(rl) <- chr | |
cat("[extract.block] Reading in the files \n") | |
rles <- lapply(files, function(xx) { | |
#if (verbose){ | |
# cat("Reading", xx, "\n") | |
#} | |
import(xx, as = "Rle", format = "bw", selection = BigWigSelection(rl)) | |
}) | |
cat("[extract.block] Building the block \n") | |
megaMatrix <- do.call(cbind, lapply(rles, function(xx) as.numeric(xx[[chr]][start:end]))) | |
megaMatrix | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment