snapatac2.PyDNAMotif#
- class snapatac2.PyDNAMotif(id, pwm)#
Represent a DNA motif as a position weight matrix.
Use this class when a Python workflow needs to scan DNA sequences or test motif enrichment from an explicit PWM. The PWM must have one row per motif position and exactly four columns in A/C/G/T order. Rows are normalized to probabilities during construction.
Anti-Patterns#
Do NOT pass columns in alphabetical ambiguity-code order or any order other than A/C/G/T.
Do NOT pass log-odds scores to
pwm; pass nonnegative weights or probabilities that can be normalized row by row.Do NOT use this object directly for scanning. Create a scanner with
with_nucl_probfirst.
- type id:
- param id:
Unique identifier of the motif.
- type pwm:
- param pwm:
Position weight matrix as a 2D numpy array of shape
(length, 4).
See also
Examples
>>> import numpy as np >>> import snapatac2 as snap >>> motif = snap.PyDNAMotif( ... "example", ... np.array([ ... [0.9, 0.05, 0.03, 0.02], ... [0.1, 0.8, 0.05, 0.05], ... ]), ... ) >>> scanner = motif.with_nucl_prob() >>> scanner.exist("ACGTACGT", pvalue=1e-5)
Attributes
Return the optional motif family label.
Return the unique motif identifier.
Return the optional display name of the motif.
Methods
Return the information content of the motif.
with_nucl_prob([a, c, g, t])Create a motif scanner with specified nucleotide background probabilities.