gintervals.covered_bp: Calculate total base pairs covered by intervals

View source: R/intervals-utils.R

gintervals.covered_bpR Documentation

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)

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.

Value

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

See Also

gintervals, gintervals.canonic, gintervals.coverage_fraction

Examples



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)


misha documentation built on Dec. 14, 2025, 9:06 a.m.