library(CoverageView)
##draw a coverage plot for a test case BAM file
#get a BAM test file
treatBAMfile<-system.file("extdata","treat.bam",package="CoverageView")
#create the CoverageBamFile object
trm<-CoverageBamFile(treatBAMfile)
#draw the plot
genome.covplot.depth(trm,outfile="test.png")
#draw the plot setting the max_depth parameter (70X in this case)
genome.covplot.depth(trm,outfile="test.png",max_depth=70)
##draw two overlapping coverage plots for two different test BAM files
#get a first BAM test file
treatBAMfile<-system.file("extdata","treat.bam",package="CoverageView")
#create the CoverageBamFile object
trm<-CoverageBamFile(treatBAMfile)
#get a second BAM test file
ctrlBAMfile<-system.file("extdata","ctrl.bam",package="CoverageView")
#create the CoverageBamFile object
ctl<-CoverageBamFile(ctrlBAMfile)
#create a list with the two files
input_d=list(trm,ctl)
#draw the plot
genome.covplot.depth(input_d,outfile="test.png")
Comments
Tutorial at https://bioconductor.org/packages/devel/bioc/vignettes/CoverageView/inst/doc/CoverageView.pdf