Please fix a small bug in the coveragePlot.R script: the plotting device is only closed if twoSamples is true. The dev.off()
should be moved out of the if(twoSamples)
block. Otherwise, the script fails with a 'Too many open devices error'. See snippet below:
I would do it myself but there seems to be a central place where this change has to be made and committed, and I am not sure how to do that.
for( i in names(sampleOneCon)){
chr.name = i
chr.name = gsub("^0*", "", i)
chr.name = paste("chr", chr.name, sep = "")
fname = outputFile
fname = gsub("\\.png", paste("_", chr.name, ".png", sep = ""), fname)
png(fname, width=1100,height=1000)
par(mfrow=c(3,1),cex=1.5,mar=c(2,4,2,0.1))#
#sampleOne#
plot(log(sampleOneCon[[i]]$reads+1,2),pch=".",main=paste(sampleOneName,"_", chr.name,sep=""),ylab=paste("log2 #",countType," per ",windowSize,"kb",sep=""),axes=FALSE)
box()#
axis(2)#
axis(1,at=pretty(c(0,nrow(sampleOneCon[[i]]))),labels=paste(pretty(c(0,nrow(sampleOneCon[[i]]))/bp_scale),"Mb",sep=""))#
#sampleTwo#
if (twoSamples) {
plot(log(sampleTwoCon[[i]]$reads+1,2),pch=".",main=paste(sampleTwoName,"_", chr.name,sep=""),ylab=paste("log2 #",countType," per ",windowSize,"kb",sep=""),axes=FALSE)
box()#
axis(2)#for( i in names(sampleOneCon)){
axis(1,at=pretty(c(0,nrow(sampleTwoCon[[i]]))),labels=paste(pretty(c(0,nrow(sampleTwoCon[[i]]))/bp_scale),"Mb",sep=""))#
#
#Ratio between the 2 samples normalized to #reads all chromosomes
plot(log(((sampleTwoCon[[i]]$reads)/sumSampleTwo)/((sampleOneCon[[i]]$reads)/sumSampleOne),2),pch=".",main=paste("log2 ratio ",sampleTwoName," vs. ", sampleOneName, " ", chr.name, sep=""),ylab=paste("#",countType," per ", windowSize, "kb normalized to total reads",sep=""),axes=FALSE)#
box()#
axis(2)#
axis(1,at=pretty(c(0,nrow(sampleOneCon[[i]]))),labels=paste(pretty(c(0,nrow(sampleOneCon[[i]]))/bp_scale),"Mb",sep=""))#
abline(h=0,col=2)#
dev.off() # THIS LINE HAS TO BE MOVED DOWN OUT OF THE IF BLOCK, SO THAT DEVICES ARE ALWAYS CLOSED
}
}