$npx -y skills add GPTomics/bioSkills --skill motif-deviationAnalyze TF motif accessibility variability across samples or single cells using chromVAR. Use when identifying TF motifs whose accessibility correlates with conditions, computing per-sample motif z-scores after matched background correction, comparing to ArchR / Signac equivalent
| 1 | ## Version Compatibility |
| 2 | |
| 3 | Reference examples tested with: chromVAR 1.24+, motifmatchr 1.24+, JASPAR2024 0.99+, TFBSTools 1.40+, BSgenome.Hsapiens.UCSC.hg38 1.4+, SummarizedExperiment 1.32+, limma 3.58+, ggplot2 3.5+, Matrix 1.6+, ArchR 1.0.2+, Signac 1.13+. |
| 4 | |
| 5 | Before using code patterns, verify installed versions match. If versions differ: |
| 6 | - R: `packageVersion('<pkg>')` then `?function_name` to verify parameters |
| 7 | |
| 8 | If code throws unexpected errors, introspect the installed package and adapt rather than retrying. |
| 9 | |
| 10 | # Motif Deviation (chromVAR) |
| 11 | |
| 12 | **"Which TF motifs explain accessibility variation across my samples or cells?"** -> Compute per-sample (or per-cell) deviation z-scores: how many standard deviations above expectation each TF motif's accessibility falls, controlling for GC content and overall accessibility via matched background peak sets. |
| 13 | |
| 14 | - R: `chromVAR::computeDeviations(counts, motifs)` -> per-sample z-scores |
| 15 | - R: `chromVAR::computeVariability(dev)` -> per-motif variance ranking |
| 16 | - Single-cell alternative: `Signac::RunChromVAR()` (wrapper with matched defaults) or `ArchR::addDeviationsMatrix()` |
| 17 | |
| 18 | chromVAR answers a different question than footprinting: footprinting asks "is this specific motif site bound?", chromVAR asks "do peaks containing this motif have systematically more or less accessibility than expected?" The two are complementary. |
| 19 | |
| 20 | ## What chromVAR Computes |
| 21 | |
| 22 | For each (motif, sample) pair: |
| 23 | - **Raw deviation** = Sum of accessibility at peaks containing the motif - expected from a matched-GC, matched-accessibility background. |
| 24 | - **Bias-corrected deviation** = Raw deviation / SD of background deviations. |
| 25 | - **Z-score** = (corrected deviation - mean across cells) / SD across cells. Reported as the principal output. |
| 26 | |
| 27 | Z-scores are signed: positive = motif more accessible in this sample than population average; negative = less. Magnitudes 2-5 are typical for biologically interesting motifs; >5 indicates strong covariation with sample state. |
| 28 | |
| 29 | ## Algorithmic Taxonomy |
| 30 | |
| 31 | | Tool | Input | Background | Output | Best for | Fails when | |
| 32 | |------|-------|------------|--------|----------|------------| |
| 33 | | chromVAR | Peak count matrix + motif annotations | Matched GC + accessibility (50 peaks per match by default) | Per-sample motif z-score | Bulk + single-cell (sparse-aware); cross-sample variability | < 1500 reads/sample (bulk) or < 500 cells/cluster (sc); too few peaks (< 5000) | |
| 34 | | Signac::RunChromVAR | Seurat single-cell ATAC object | Same as chromVAR (delegated) | Motif assay in Seurat object | Standard single-cell workflows in Seurat ecosystem | Same as chromVAR; needs Seurat object setup | |
| 35 | | ArchR::addDeviationsMatrix | ArrowFile + tile/peak matrix | ArchR's getBgdPeaks (matched on GC + log accessibility) | Per-cell deviation matrix in ArchR project | ArchR ecosystem; faster on large scATAC | ArchR-specific format; not portable to chromVAR objects | |
| 36 | | Signac::FindMarkers (with motifs as features) | Motif accessibility matrix from RunChromVAR | Per-cell-cluster | Differential motifs per cluster | Cluster-level differential | Differential test must be on z-scores; raw counts will mislead | |
| 37 | | TF activity inference (DecoupleR / SCENIC+) | Gene expression + motif activity | Multi-modal | TF activity score | Multi-omics integration | Requires paired RNA-seq; chromVAR alone is insufficient | |
| 38 | |
| 39 | Methodology evolves; verify against current chromVAR (Schep 2017), ArchR (Granja 2021), and Signac (Stuart 2021) benchmarks before locking pipelines. |
| 40 | |
| 41 | ## chromVAR vs Footprinting -- Different Questions |
| 42 | |
| 43 | | Question | Tool | |
| 44 | |----------|------| |
| 45 | | Does the bulk pattern of motif-containing peaks vary with condition? | chromVAR | |
| 46 | | Is THIS specific motif site bound by a TF? | TOBIAS / HINT-ATAC | |
| 47 | | Per-cell TF activity in scATAC | chromVAR (via Signac/ArchR) | |
| 48 | | Per-cell TF binding at specific sites | scprinter | |
| 49 | | TF activity correlated with gene expression | chromVAR + co-expression OR SCENIC+ | |
| 50 | | Which TF families distinguish my cell clusters? | chromVAR per-cluster z-scores | |
| 51 | | Differential bound vs unbound between conditions | TOBIAS BINDetect | |
| 52 | |
| 53 | chromVAR is fundamentally a *summary statistic* over many motif sites. Footprinting is per-site classification. Use chromVAR when motif site count >> 100; use footprinting when specific sites matter. |
| 54 | |
| 55 | ## Per-Tool Failure Modes |
| 56 | |
| 57 | ### chromVAR -- Too few peaks or too few reads |
| 58 | |
| 59 | **Trigger:** ATAC peakset < 5000 peaks; per-sample read depth < 1500 in peaks. |
| 60 | |
| 61 | **Mechanism:** chromVAR's background sampling requires enough peaks to find matched GC + access |