Skip to content

Instantly share code, notes, and snippets.

@Jfortin1
Created November 20, 2014 22:54
Show Gist options
  • Save Jfortin1/394b68ef34f31f927eb8 to your computer and use it in GitHub Desktop.
Save Jfortin1/394b68ef34f31f927eb8 to your computer and use it in GitHub Desktop.
Extract only a portion of a bigWig file
extract.portion <- function(file, chr, start, end, verbose = TRUE){
rl <- IRanges::RangesList(IRanges::IRanges(start=start, end=end))
names(rl) <- chr
portion <- import(file, as="Rle",format = "bw", selection = BigWigSelection(rl))
portion <- portion[chr]
portion <- as.numeric(portion[[chr]])
portion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment