# Generate artificial wig fixed step files with random counts
exampleFolder <- tempdir(); nbFiles=6; nbChromosomes=4
for(fileIndex in 1:nbFiles)
{
wigScoresContent <- lapply(as.list(1:nbChromosomes),
function(x) {sample(x=1:20, size=1000, replace=TRUE, prob=NULL)})
names(wigScoresContent)<- paste("chr", 1:nbChromosomes, sep="");
writeWIG(wigScoresContent,
paste("wigFileExample", fileIndex, sep=""),
folder=exampleFolder, fixedStep=200)
}
# Build a file list containing wig files to merge together, and a
# reference to the file to be used as input for score subtraction
wigFileList <- paste(exampleFolder,
"/",
"wigFileExample",
1:nbFiles,
".wig", sep="")
# Merge files together (average the scores at each coordinates),
# producing two WIG files
filesToMerge <- list()
filesToMerge[["MyEXP1"]] <- wigFileList[1:(nbFiles/2)]
filesToMerge[["MyEXP2"]] <- wigFileList[((nbFiles/2)+1):nbFiles]
mergeWigs(files=filesToMerge, binSize=200, outputFolder=exampleFolder)
Run the code above in your browser using DataLab