Annotate peaks with TF motif matches
add_motif_annotations.RdScans peaks against a PWMatrixList (from chromVARmotifs, JASPAR2020, or
user-supplied) and stores a peak x motif binary match matrix plus
per-motif position GRangesList on the project.
Usage
# S3 method for class 'MarchRProject'
add_motif_annotations(
proj,
motif_set = c("cisbp", "encode", "homer", "JASPAR2020"),
motif_pwms = NULL,
anno_name = "Motif",
species = NULL,
collection = "CORE",
cutoff = 5e-05,
width = 7L,
pwm_version = 2L,
bsgenome = NULL,
overwrite = FALSE,
verbose = getOption("MarchR.verbose", FALSE),
...
)Arguments
- proj
(MarchRProject) Project with a populated peak set.
- motif_set
(character) PWM source. One of
"cisbp","encode","homer","JASPAR2020". Ignored whenmotif_pwmsis supplied. Default"cisbp".- motif_pwms
(PWMatrixList or NULL) User-supplied PWMatrixList. When non-NULL, bypasses
motif_set.- anno_name
(character) Name to store under
proj$peak_annotations[[anno_name]]. Default"Motif".- species
(character or NULL) Species for chromVARmotifs/JASPAR2020 resolution. Auto-derived from the resolved BSgenome via
BSgenome::organism()when NULL.- collection
(character) JASPAR collection. Only used when
motif_set = "JASPAR2020". Default"CORE".- cutoff
(numeric) MOODS p-value cutoff for
motifmatchr::matchMotifs. Default5e-05(matches ArchR).- width
(integer)
wargument tomotifmatchr::matchMotifs. Default7L(matches ArchR).- pwm_version
(integer) chromVARmotifs PWM version. Used only for
motif_set = "cisbp". Default2L.- bsgenome
(BSgenome or NULL) Reference genome for sequence extraction. When
NULL(default), resolved fromproj$genome$sequence(set viaset_genome_sequence()).- overwrite
(logical) Overwrite existing annotation with the same name. Default
FALSE.- verbose
(logical) Print progress messages. Default
getOption("MarchR.verbose", FALSE).- ...
Currently unused.
Value
The modified MarchRProject with the motif annotation stored at
proj$peak_annotations[[anno_name]]. Match matrix rows carry
coordinate-key rownames (<chr>_<start>_<end>).
Details
Wraps motifmatchr::matchMotifs(..., out = "positions") to produce
per-motif GRangesList of hits, then builds a sparse Matrix::dgCMatrix
of size n_peaks x n_motifs. Motifs with zero peak overlaps are dropped
(matches ArchR's behavior).
The stored annotation also carries pwms, the motif profiles filtered to
the motifs that survive that overlap check, in the same order as
positions and the columns of matches. Profiles keep whichever scale
their source uses: motif_set = "JASPAR2020" yields counts (PFMatrix),
while "cisbp", "encode", and "homer" yield log2 odds (PWMatrix).
Because scanning runs against the peak set, stored positions only ever fall
inside called peaks.
Equivalent to ArchR's addMotifAnnotations() (AnnotationPeaks.R:355), whose
peakAnnotation[[annoName]]$motifs corresponds to pwms here.
See also
add_peak_annotations() for region-based annotations,
get_matches(), get_positions(), and get_motifs() for accessors,
plot_motif_logo() to render a stored profile.