##BAM files
#get treatment and control test files
treat1file<-system.file("extdata","treat.bam",package="CoverageView")
control1file<-system.file("extdata","ctrl.bam",package="CoverageView")
#create two CoverageBamFile objects representing single-end alignments
trm1<-CoverageBamFile(treat1file,run_type="single")
ctl1<-CoverageBamFile(control1file,run_type="single")
#calculate the ratio of the coverages for the defined genomic interval using a bin_width equal to 10 nts
cov1=cov.interval(trm1,ctl1,chr="chrI",start=1,end=100,bin_width=10,do="ratio")
#create a WIG file with the obtained vector with the ratios
outfolder=system.file("extdata",package="CoverageView")
an_outfile1=paste(outfolder,"out.wig",sep="/")
export.wig(cov1,outfile=an_outfile1)
##BigWIG files
#get a treatment and control test files
treat2file<-system.file("extdata","treat.bw",package="CoverageView")
control2file<-system.file("extdata","ctrl.bw",package="CoverageView")
#create the 'treatment' and 'control' CoverageBigWigFile objects
trm2<-CoverageBigWigFile(path=treat2file,reads_mapped=28564510)
ctl2<-CoverageBigWigFile(path=control2file,reads_mapped=26713667)
#calculate the ratio of the coverages for the defined genomic interval
cov2=cov.interval(trm2,ctl2,bin_width=1,chr="chrI",start=1,end=1000,do='ratio')
Run the code above in your browser using DataLab