Collapse core regions from a BED file with score-based filtering
plc_coreovl_with_d.RdThis function reads a BED file, filters regions by score, resizes them to a fixed core width, and merges overlapping cores selectively based on score differences. It supports chromosome-wise parallel processing and optional output to a BED file with logging throughout.
Usage
plc_coreovl_with_d(
bed_file,
score_threshold = 0.75,
score_diff = 0.1,
core_width = 151,
return_gr = TRUE,
output_dir = NULL,
save_rds = FALSE,
num_cores = NULL,
processing_method = "multisession"
)Arguments
- bed_file
Path to the input BED file.
- score_threshold
Numeric threshold for filtering regions by score from 0-1. Default is 0.75.
- score_diff
Maximum allowed score difference between overlapping regions for merging. Default is 0.1.
- core_width
Width to which each region should be resized (centered). Default is 151.
- return_gr
Logical. If TRUE, returns the final collapsed GRanges object. Default is TRUE.
- output_dir
Optional directory path to write BED output. If NULL, no output is written.
- num_cores
Number of CPU cores to use. If NULL, will use half of available cores (up to 25). Default is NULL.
Value
If `return_gr = TRUE`, returns a `GRanges` object containing the collapsed regions. Otherwise, returns `NULL`.
Details
The function performs the following steps:
Loads and filters BED entries by score.
Resizes regions to a fixed core width centered on each region.
Merges overlapping cores selectively per chromosome using a parallel backend.
Logs progress and optionally writes output to BED format.
If no regions pass the score filter, the function exits early with a warning.