R/intervals-utils.R
gintervals.coverage_fraction.RdReturns the fraction of a genomic space that is covered by a set of intervals.
gintervals.coverage_fraction(intervals1 = NULL, intervals2 = NULL)A single numeric value between 0 and 1 representing the fraction of 'intervals2' (or the genome) covered by 'intervals1'.
This function calculates what fraction of 'intervals2' is covered by 'intervals1'. If 'intervals2' is NULL, it calculates the fraction of the entire genome that is covered by 'intervals1'. Overlapping intervals in either set are automatically unified before calculation.
gdb.init_examples()
# Create some intervals
intervs1 <- gscreen("dense_track > 0.15")
intervs2 <- gintervals(c("chr1", "chr2"), 0, c(100000, 100000))
# Calculate fraction of intervs2 covered by intervs1
gintervals.coverage_fraction(intervs1, intervs2)
#> [1] 0.22325
# Calculate fraction of entire genome covered by intervs1
gintervals.coverage_fraction(intervs1)
#> [1] 0.1391