Compute per-cell ChromVAR-style motif deviations
add_deviations_matrix.RdBuilds two motif x cell BPCells matrices per dataset: raw deviations
(<matrix_name>Deviations) and bias-corrected z-scores
(<matrix_name>ZScore).
Arguments
- proj
(MarchRProject) Project with peak_annotations[TFBSTools::name], background_peaks, and a PeakMatrix assay.
- peak_annotation
(character) Name of the stored peak annotation.
- matrix_name
(character or NULL) Base name for output assays. When NULL (default), uses
peak_annotation.- dataset_names
(character) Datasets to compute on. Default: all datasets that have a PeakMatrix. This selects output datasets, not the reference population configured by
add_background_peaks().- chunk_size
(integer) Cells per chunk; bounds dense per-chunk memory. Default 20000.
- overwrite
(logical) Replace existing matrices. Default FALSE.
- verbose
(logical) Print progress messages. Default
getOption("MarchR.verbose", FALSE).- ...
Unused.
Details
All output datasets use the pooled peak-accessibility expectation
from the stored background reference, with each cell's own total counts.
Backgrounds must have current reference provenance, and sampled
backgrounds at least two iterations. Regenerate legacy or stale
backgrounds with add_background_peaks(overwrite = TRUE). Cells are
processed chunk_size at a time. Chunk results, and a column-major copy
of the PeakMatrix when it is stored row-major, are written to a temporary
directory under proj$dir and removed on exit, including on error. The
stored PeakMatrix is unchanged.
ArchR correspondence: with a "chromVAR" or "bpcells" background,
this corresponds to ArchR's addDeviationsMatrix().
betterChromVAR correspondence: with a "betterChromVAR" background,
background moments are computed in closed form as in the betterChromVAR
package (Wang et al., bioRxiv 2026), so results are deterministic; see the
preprint for the method. Unlike betterChromVAR::computeBackgrounds(), the
variance includes the between-bin term. z-scores run slightly narrower than
sampled ones, whose spread includes Monte Carlo noise. The bin moments are
dense bins x chunk matrices (bin_size^2 bins, set in
add_background_peaks()), about 1.2 GB per 10,000 cells at
bin_size = 50; lower chunk_size to reduce this.
References
Schep AN, Wu B, Buenrostro JD, Greenleaf WJ (2017). chromVAR: inferring transcription-factor-associated accessibility from single-cell epigenomic data. Nature Methods 14(10), 975-978. doi:10.1038/nmeth.4401
Wang J, Sonder E, Domcke S, Robinson MD, Germain P-L (2026). Addressing technical variations in ATAC-seq data and improving motif accessibility analyses. bioRxiv. doi:10.64898/2026.08.21.746151