Call peaks and build a reproducible peak set
add_reproducible_peak_set.RdCalls peaks per pseudobulk replicate (from add_group_coverages),
filters for peaks reproduced across replicates within each group, then
merges across groups into a single non-overlapping peak set.
Usage
# S3 method for class 'MarchRProject'
add_reproducible_peak_set(
proj,
group_by = character(0),
peak_method = c("macs3", "macs2"),
reproducibility = "2",
peaks_per_cell = 500L,
max_peaks = 150000L,
extend_summits = 250L,
effective_genome_size = NULL,
additional_params =
"--call-summits --keep-dup all --shift -75 --extsize 150 --nomodel --nolambda",
exclude_chr = c("chrM", "chrY"),
blacklist = TRUE,
min_cells = 25L,
promoter_region = c(2000L, 100L),
frags_name = character(0),
dataset_names = character(0),
macs_executable = NULL,
threads = get_threads(),
verbose = getOption("MarchR.verbose", FALSE),
...
)Arguments
- proj
(MarchRProject) Project with group coverages already computed.
- group_by
(character) Name of the grouping used in
add_group_coverages(). Auto-selected if only one exists.- peak_method
(character) Peak calling method. One of
"macs3"(default) or"macs2". Both callBPCells::call_peaks_macs()with the corresponding executable name; seemacs_executablefor custom install paths.- reproducibility
(character or numeric) Minimum number of pseudobulk replicates in which a peak must appear. Evaluated per group as an R expression via
eval(parse(text = reproducibility))in an environment wherenis bound to the number of replicates in that group, so"(n+1)/2"requires a majority and"2"requires at least two. Numeric values are coerced to character. Default is"2"(matching ArchR).- peaks_per_cell
(integer) Maximum peaks per group is capped at
min(max_peaks, n_cells * peaks_per_cell). Default is 500.- max_peaks
(integer) Hard cap on peaks per group. Default is 150000.
- extend_summits
(integer) For MACS method: extend each 1bp summit to a fixed-width peak of
2 * extend_summits + 1bp. Default is 250 (producing 501bp peaks, matching ArchR).- effective_genome_size
(numeric) Effective genome size for MACS. If
NULL, computed as sum of chromosome sizes from the project genome.- additional_params
(character) Additional MACS command-line flags. Default matches ArchR:
"--call-summits --keep-dup all --shift -75 --extsize 150 --nomodel --nolambda".- exclude_chr
(character) Chromosomes to exclude. Default
c("chrM", "chrY").- blacklist
(logical or data.frame) If
TRUE, uses project blacklist. If a data.frame with chr/start/end, uses those regions. IfFALSE, no blacklist filtering.- min_cells
(integer) Groups with fewer unique cells are skipped. Default 25 (matching ArchR).
- promoter_region
(numeric) Two-element vector: upstream and downstream distances from TSS to define promoter regions for peak annotation. Default
c(2000, 100)(matching ArchR).- frags_name
(character) Fragment name to use. Auto-selected if only one exists.
- dataset_names
(character) Datasets to include. Default all.
- macs_executable
(character) Path or command name for the MACS executable. If
NULL(default), resolves frompeak_method:"macs3"->"macs3","macs2"->"macs2". When MACS is installed under a non-standard name or path (e.g., a conda env or Python venv), pass the full path explicitly:macs_executable = "/path/to/bin/macs3".- threads
(integer) Threads for parallel MACS execution. Default 1.
- verbose
(logical) Print progress messages. Default
getOption("MarchR.verbose", FALSE).- ...
Additional arguments.
Value
The modified MarchRProject with the peak set stored in
proj$peak_set as a tibble with columns: chr, start,
end, group_name, groupScoreQuantile,
replicateScoreQuantile, reproducibility, and optionally
peakType.
Details
Algorithm (matching ArchR's addReproduciblePeakSet()):
Retrieve pseudobulk replicate assignments from
add_group_coverages().For each replicate, subset fragments and call peaks using
BPCells::call_peaks_macs().Extend 1bp summits to fixed-width peaks (501bp default).
Per group: resolve intra-replicate overlaps via
BPCells::merge_peaks_iterative()(highest score wins), compute replicate score quantiles, then merge across replicates.Filter peaks found in fewer than
reproducibilityreplicates.Cap per-group peaks at
min(max_peaks, n_cells * peaks_per_cell).Merge all group peaks into a union set via
BPCells::merge_peaks_iterative()(highestgroupScoreQuantilewins).Annotate peaks as Promoter/Intronic/Distal using gene annotations (if available in the project genome).
Differences from ArchR:
Uses
BPCells::call_peaks_macs()instead of manual BED writing and shell invocation. BPCells handles compressed BED I/O and threading.No intermediate HDF5 coverage files. Fragments stream directly to MACS input.
No k-mer bias computation (orthogonal to peak calling; needed only for footprinting).
MACS3 auto-detected before MACS2 (BPCells default), since MACS2 is no longer maintained.
Peak annotation uses Promoter/Intronic/Distal (no Exonic category unless transcript annotations with exon boundaries are available).
Methods (by class)
add_reproducible_peak_set(MarchRProject): Build a reproducible peak set for a MarchRProject.
See also
add_group_coverages for creating pseudobulk replicates
get_peak_set for retrieving the stored peak set
add_peak_matrix for creating the peaks x cells count matrix