###################################################
### chunk number 1: 
###################################################
#line 81 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
library(BayesPeak)


###################################################
### chunk number 2: ex1 eval=FALSE
###################################################
## #line 89 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## raw.output <- bayespeak("H3K4me3-chr16.bed", "Input-chr16.bed",
## 			chr = "chr16", start = 9.2E7, end = 9.5E7, job.size = 6E6)
## output <- summarize.peaks(raw.output, method = "lowerbound")


###################################################
### chunk number 3: ex2 eval=FALSE
###################################################
## #line 107 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## raw.output <- bayespeak("H3K4me3-chr16.bed", "Input-chr16.bed")
## output <- summarize.peaks(raw.output, method = "lowerbound")


###################################################
### chunk number 4: savetodisk eval=FALSE
###################################################
## #line 117 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## library(rtracklayer)
## export(output, "H3K4me3output.bed")
## export(output, "H3K4me3output.gff")


###################################################
### chunk number 5: savetodisk2 eval=FALSE
###################################################
## #line 125 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## write.table(as.data.frame(output), file = "H3K4me3output.txt", quote = FALSE)
## write.csv(as.data.frame(output), file = "H3K4me3output.csv", quote = FALSE)


###################################################
### chunk number 6: Help eval=FALSE
###################################################
## #line 152 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## raw.output <- bayespeak("H3K4me3-chr16.bed", "Input-chr16.bed")


###################################################
### chunk number 7: Help eval=FALSE
###################################################
## #line 180 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## library(multicore)
## raw.output <- bayespeak("H3K4me3-chr16.bed", "Input-chr16.bed",
## 	use.multicore = TRUE, mc.cores = 4)
## output <- summarize.peaks(raw.output, method = "lowerbound")


###################################################
### chunk number 8: PP1
###################################################
#line 214 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
data(raw.output)
raw.output$call


###################################################
### chunk number 9: PP3a
###################################################
#line 249 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
min.job <- min(raw.output$peaks$job)
max.job <- max(raw.output$peaks$job)

par(mfrow = c(2,2), ask = TRUE)
for(i in min.job:max.job) {plot.PP(raw.output, job = i, ylim = c(0,50))}


###################################################
### chunk number 10: job324
###################################################
#line 268 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
i <- 324
plot.PP(raw.output, job = i, ylim = c(0,50))


###################################################
### chunk number 11: job324fig
###################################################
#line 277 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
#line 268 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw#from line#277#"
i <- 324
plot.PP(raw.output, job = i, ylim = c(0,50))
#line 278 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"


###################################################
### chunk number 12: job325
###################################################
#line 295 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
i <- 325
plot.PP(raw.output, job = i, ylim = c(0,50))


###################################################
### chunk number 13: job325fig
###################################################
#line 304 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
#line 295 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw#from line#304#"
i <- 325
plot.PP(raw.output, job = i, ylim = c(0,50))
#line 305 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"


###################################################
### chunk number 14: OF1
###################################################
#line 324 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
data(raw.output)


###################################################
### chunk number 15: OF3
###################################################
#line 359 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"

plot.overfitdiag(raw.output, whatX = "calls", whatY = "lambda1",
	logX = TRUE, logY = TRUE)


###################################################
### chunk number 16: OF3b
###################################################
#line 364 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
plot.overfitdiag(raw.output, whatX = "calls", whatY = "score",
	logX = TRUE, logY = TRUE)


###################################################
### chunk number 17: OF3fig
###################################################
#line 374 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
#line 359 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw#from line#374#"

plot.overfitdiag(raw.output, whatX = "calls", whatY = "lambda1",
	logX = TRUE, logY = TRUE)
#line 375 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"


###################################################
### chunk number 18: OF3bfig
###################################################
#line 384 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
#line 364 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw#from line#384#"
plot.overfitdiag(raw.output, whatX = "calls", whatY = "score",
	logX = TRUE, logY = TRUE)
#line 385 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"


###################################################
### chunk number 19: OF3
###################################################
#line 396 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
plot.overfitdiag(raw.output, whatX = "calls", whatY = "score",
	logX = TRUE, logY = FALSE)


###################################################
### chunk number 20: OF3b
###################################################
#line 403 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
plot.overfitdiag(raw.output, whatX = "lambda1", whatY = "score",
	logX = TRUE, logY = TRUE)


###################################################
### chunk number 21: OF4
###################################################
#line 417 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
unreliable.jobs <- log(raw.output$QC$lambda1) < 1.5
output <- summarize.peaks(raw.output, method = "lowerbound",
	exclude.jobs = unreliable.jobs)


###################################################
### chunk number 22: OF5
###################################################
#line 425 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
unreliable.jobs2 <- log(raw.output$QC$lambda1) < 1.5 | log(raw.output$QC$calls) > 5
output.2 <- summarize.peaks(raw.output, method = "lowerbound",
	exclude.jobs = unreliable.jobs2)


###################################################
### chunk number 23: region.overfitdiag.help
###################################################
#line 433 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
unreliable.jobs3 <- region.overfitdiag(raw.output, whatX = "lambda1", whatY = "score",
	logX = TRUE, logY = TRUE)
##user defines a polygon on the resulting plot
##left-click to place each vertex, right-click to close polygon 
output.3 <- summarize.peaks(raw.output, method = "lowerbound",
	exclude.jobs = unreliable.jobs3)


###################################################
### chunk number 24: QCcommand
###################################################
#line 456 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
log(raw.output$QC[,c("calls", "score", "lambda1")])


###################################################
### chunk number 25: coda eval=FALSE
###################################################
## #line 496 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
## data(raw.output)
## library(coda)
## mcmc.job1 <- mcmc(raw.output$p.samples[[316]], thin = 10)
## geweke.diag(mcmc.job1)


###################################################
### chunk number 26: 
###################################################
#line 543 "E:/biocbld/bbs-2.7-bioc/tmpdir/RtmpJtf9lP/R.INSTALL1b6d6e1e/BayesPeak/inst/doc/BayesPeak.Rnw"
sessionInfo()


