Skip to content

Instantly share code, notes, and snippets.

@rcquan
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcquan/c5d7fc2199cbb88ad6b1 to your computer and use it in GitHub Desktop.
Save rcquan/c5d7fc2199cbb88ad6b1 to your computer and use it in GitHub Desktop.
library(BiSeq)
readBedgraph <- function(inputDirectory, nSamples = 8) {
## get list of file names
fileNames <- list.files(path = inputDirectory, pattern = ".bedGraph")
## parse sample name from file name
sampleNames <- sapply(fileNames,function(fileName) {
gsub("_r123_R1_val_1.fq_bismark_bt2_pe.bedGraph", "", fileName)
}, USE.NAMES = FALSE)
## label samples
colData <- data.frame(group = rep(c("control", "cancer"), nSamples), row.names = sampleNames)
rawBSObj <- readBismark(fileNames, colData)
return(rawBSObj)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment