## Define an artificial wig list
generateWigScores <- function(scores=1:20, lengthTrack=1000)
{
return(sample(scores, lengthTrack, replace=TRUE))
}
myWig <- list("chr1"=generateWigScores(), "chr2"=generateWigScores())
# Write a wig file that can be read in genome browsers
writeWIG(myWig, "myWigFixedSteps", folder=tempdir(), fixedStep=200)
# Read the file generated
myWigFromFile <- readWIG(file.path(tempdir(), "myWigFixedSteps.wig"))
# Check that scores are equal for all chromosomes
if(!all(mapply(all.equal,myWig,myWigFromFile))) stop ("Error, the original
generated data look different from what has been read");
Run the code above in your browser using DataLab