Loading package

devtools::load_all()
## Loading DEScan2
## 

computing coverages

file="inst/extdata/Bed/P43615_Sample_FC1_Input_fwd_chr19_Smartfilter.bed.zip"

chr="chr19"; filetype="bed"; fragmentLength=200;
binSize=50; minWin=50; maxWin=1000; genomeName="mm9";
minCompWinWidth=5000; maxCompWinWidth=10000;
zthresh=5; minCount=0.1; verbose=TRUE; save=FALSE
onlyStdChrs=TRUE
fileGRangesList <- NULL
winVector <- c( (minWin/50):(maxWin/50))


bedGRanges <- constructBedRanges(filename=file, filetype=filetype,
                             genomeName=genomeName,
                             onlyStdChrs=onlyStdChrs)
## processing inst/extdata/Bed/P43615_Sample_FC1_Input_fwd_chr19_Smartfilter.bed.zip
## Get seqlengths from genome mm9
bedGrangesChrsList <- cutGRangesPerChromosome(bedGRanges)
if(!is.null(chr)) bedGrangesChrsList <- keepRelevantChrs(bedGrangesChrsList, chr)


chrGRanges=bedGrangesChrsList[[1]]

chrBedGRanges=chrGRanges
minWinWidth=minWin
maxWinWidth=maxWin
binWidth=binSize

minWinWidth <- minWinWidth/binWidth
maxWinWidth <- maxWinWidth/binWidth

## dividing chromosome in bins of binWidth dimention each
binnedChromosome <- GenomicRanges::tileGenome(seqlengths=chrBedGRanges@seqinfo,
                                          tilewidth=binWidth,
                                          cut.last.tile.in.chrom=TRUE)
#
st.tm=Sys.time()
olap <- GenomicAlignments::summarizeOverlaps(features=binnedChromosome,
                                         reads=chrBedGRanges,
                                         ignore.strand=TRUE,
                                         inter.feature=FALSE,
                                         mode="IntersectionNotEmpty")
#
# test the coverages with the old coverages using a small amount of reads
chrCovRle1 <- as(SummarizedExperiment::assays(olap)$counts, "Rle")
ed.tm=Sys.time()
message("Summ overl time: ", ed.tm-st.tm)
## Summ overl time: 3.10484218597412
st.tm=Sys.time()
## computing coverage per single base on bed
chrCoverage <- GenomicRanges::coverage(x=chrBedGRanges)
## computing coverage per each bin on chromosome
chrCovRle <- binnedCovOnly(bins=binnedChromosome,
                       numvar=chrCoverage,
                       mcolname="bin_cov")
ed.tm=Sys.time()
message("binned Cov time: ", ed.tm-st.tm)
## binned Cov time: 0.422784805297852
message("correlation is: ", cor(as.vector(chrCovRle), as.vector(chrCovRle1)))
## correlation is: 0.995080549112632