Learn R Programming

misha (version 5.3.1)

gintervals.covered_bp: Calculate total base pairs covered by intervals

Description

Returns the total number of base pairs covered by a set of intervals.

Usage

gintervals.covered_bp(intervals = NULL)

Value

A single numeric value representing the total number of base pairs covered by the intervals.

Arguments

intervals

set of one-dimensional intervals

Details

This function first canonicalizes the intervals to remove overlaps and touching intervals, then sums up the lengths of all resulting intervals. Overlapping intervals are counted only once.

See Also

gintervals, gintervals.canonic, gintervals.coverage_fraction

Examples

Run this code
# \dontshow{
options(gmax.processes = 2)
# }

gdb.init_examples()

# Create some intervals
intervs <- gintervals(
    c("chr1", "chr1", "chr2"),
    c(100, 150, 1000),
    c(200, 250, 2000)
)

# Calculate total bp covered
# Note: intervals [100,200) and [150,250) overlap,
# so total is (200-100) + (250-150) + (2000-1000) = 100 + 100 + 1000 = 1200
# But after canonicalization: [100,250) + [1000,2000) = 150 + 1000 = 1150
gintervals.covered_bp(intervs)

Run the code above in your browser using DataLab