regionStats: Counts the Windows in Regions of Interest

Description Usage Arguments Value Author(s) See Also Examples

View source: R/qsea.makeTable.R

Description

This function takes a list of window indices and a list of ROIs and counts the number of overlapping windows

Usage

1
2
regionStats(qs, subsets = list(covered = which(rowSums(getCounts(qs)) >= 20)),
 ROIs = list(), minoverlap = 0, maxgap = -1)

Arguments

qs

A qsea Set object

subsets

A list of window indices

ROIs

A list of Regions of Interest

minoverlap

Passed to findOverlaps

maxgap

Passed to findOverlaps

Value

a matrix, containing the total number of windows overlapping the ROIs and the numbers of windows from the subset list overlapping ROIs

Author(s)

Mathias Lienhard

See Also

findOverlaps

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
qs=getExampleQseaSet()
#as an example, we analyze the fraction of reads covered by at least 10
#or at least 20 reads, for bins of CpG density
ROIs=list()
regs=getRegions(qs)
cpg=getRegions(qs)$CpG_density
bins=seq(0,30,5)
for(i in 1:(length(bins)-1)){
    n=paste0(bins[i],"-",bins[i+1]," CpGs")
    ROIs[[n]]=regs[which(cpg>=bins[i] & cpg < bins[i+1])]
}
subsets = list(
    ">10" = which(rowSums(getCounts(qs)) >= 10),
    ">20" = which(rowSums(getCounts(qs)) >= 20))
coverage_stats=regionStats(qs, subsets, ROIs)
coverage_stats_rel=coverage_stats[,-1]/coverage_stats[,1]
x=barplot(t(coverage_stats_rel)*100,ylab="fraction of windows[%]",
    beside=TRUE, legend=TRUE, las=2, args.legend=list(x="topleft"), 
    main="Covered Windows")

qsea documentation built on Nov. 8, 2020, 8:28 p.m.