# NOT RUN {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# A) Open reader
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
bam <- system.file("extdata", "accepted_hits.bam", package="rbamtools")
idx<-paste(bam,"bai",sep=".")
# Open BAM file
reader<-bamReader(bam, idx=TRUE)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# B) Count range segment
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
coords <- c(0, 0, 2e4)
segments <- seq(14000, 20000, 20)
segcount<-rangeSegCount(reader, coords, segments)
segcount
dfr<-as.data.frame(segcount)
# }
# NOT RUN {
plot(count~position, dfr, type="l", las=1, bty="n", lwd=1.5)
# }
Run the code above in your browser using DataLab