Assigns each peak in a GRanges object to the chromatin state with
which it has the largest overlap from a ChromHMM GRanges annotation.
Supports filtering by both absolute and fractional overlap requirements.
Usage
AnnotatePeaks(
peaks_gr,
chromHMM_states,
state_col = "name",
keep_unannotated = FALSE,
min_overlap = 1,
min_overlap_frac = NULL,
verbose = TRUE
)Arguments
- peaks_gr
A
GRangesobject of peak regions to annotate.- chromHMM_states
A
GRangesobject of ChromHMM state annotations. Must contain a metadata column (default"name") specifying state names.- state_col
Character string specifying the metadata column in
chromHMM_statescontaining state labels. Default ="name".- keep_unannotated
Logical; if
TRUE, peaks without qualifying overlaps to any ChromHMM state are retained withNAin theirannotationcolumn. IfFALSE(default), unannotated peaks are dropped.- min_overlap
Numeric; minimum overlap width (in bp) required for a peak to be assigned to a ChromHMM state. Default =
1(any overlap).- min_overlap_frac
Optional numeric; minimum fraction of a peak's length that must overlap a ChromHMM state for assignment. Must be between 0 and 1. If
NULL(default), no fraction filter is applied.- verbose
Logical; if
TRUE(default), prints a summary message about peaks removed due to overlap thresholds.
Value
A GRanges object of peaks with added metadata columns:
annotation— the ChromHMM state label.overlap_width— width of overlap between the peak and its assigned ChromHMM state.overlap_frac— fraction of the peak length overlapping the state.
Details
For each peak:
The function finds all overlaps between peaks and ChromHMM states.
It computes the absolute overlap width and fractional overlap relative to peak length.
It assigns each peak to the state with the largest overlap, subject to
min_overlapandmin_overlap_fracthresholds.Overlap statistics are stored in new metadata columns.
Peaks that fail the filters are optionally retained (
keep_unannotated) or dropped (default).