Skip to contents

Uses the stored peak set (or user-supplied ranges) and fragment data to create a lazy IterableMatrix counting Tn5 insertions per peak per cell.

Usage

# S3 method for class 'MarchRProject'
add_peak_matrix(
  proj,
  peak_set = NULL,
  ceiling = 4L,
  binarize = FALSE,
  mode = c("insertions", "fragments"),
  output_assay_name = "PeakMatrix",
  frags_name = character(0),
  dataset_names = character(0),
  blacklist = TRUE,
  exclude_chr = c("chrM", "chrY"),
  overwrite = FALSE,
  verbose = getOption("MarchR.verbose", FALSE),
  ...
)

Arguments

proj

(MarchRProject) Project with fragments and a peak set.

peak_set

(data.frame; optional) Peak ranges with chr, start, end columns. If NULL, uses the stored peak set from add_reproducible_peak_set().

ceiling

(integer) Maximum count per cell per peak. Values above this are capped. Default is 4 (matching ArchR). Set to NULL to disable.

binarize

(logical) If TRUE, convert counts to 0/1 after applying ceiling. Default FALSE.

mode

(character) How to count overlaps: "insertions" counts each fragment end separately (0, 1, or 2 per fragment; matching ArchR), "fragments" counts at most 1 per fragment. Default "insertions".

output_assay_name

(character) Name of the assay to store. Default "PeakMatrix".

frags_name

(character) Fragment name. Auto-selected if only one.

dataset_names

(character) Datasets to include. Default all.

blacklist

(logical or data.frame) Blacklist filtering for fragments.

exclude_chr

(character) Chromosomes to exclude from fragments.

overwrite

(logical) Overwrite existing assay. Default FALSE.

verbose

(logical) Print progress messages. Default getOption("MarchR.verbose", FALSE).

...

Additional arguments.

Value

The modified MarchRProject with a PeakMatrix assay added to each dataset and peak annotations stored in proj$feature_metadata[["PeakMatrix"]].

Details

The peak matrix counts Tn5 insertions (both fragment ends) overlapping each peak, matching ArchR's addPeakMatrix() behavior. The matrix is created lazily via BPCells::peak_matrix() and remains disk-backed.

With the default ceiling = 4, any cell-peak count above 4 is capped to prevent outlier cells from dominating downstream analyses. This matches ArchR's default.

Methods (by class)

  • add_peak_matrix(MarchRProject): Create peak matrix for a MarchRProject.

See also

add_reproducible_peak_set for creating the peak set get_peak_set for retrieving the peak set