Install
$ agentstack add skill-gptomics-bioskills-motif-deviation ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
Version Compatibility
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+.
Before using code patterns, verify installed versions match. If versions differ:
- R:
packageVersion('')then?function_nameto verify parameters
If code throws unexpected errors, introspect the installed package and adapt rather than retrying.
Motif Deviation (chromVAR)
"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.
- R:
chromVAR::computeDeviations(counts, motifs)-> per-sample z-scores - R:
chromVAR::computeVariability(dev)-> per-motif variance ranking - Single-cell alternative:
Signac::RunChromVAR()(wrapper with matched defaults) orArchR::addDeviationsMatrix()
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.
What chromVAR Computes
For each (motif, sample) pair:
- Raw deviation = Sum of accessibility at peaks containing the motif - expected from a matched-GC, matched-accessibility background.
- Bias-corrected deviation = Raw deviation / SD of background deviations.
- Z-score = (corrected deviation - mean across cells) / SD across cells. Reported as the principal output.
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.
Algorithmic Taxonomy
| Tool | Input | Background | Output | Best for | Fails when | |------|-------|------------|--------|----------|------------| | 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 | > 100; use footprinting when specific sites matter.
Per-Tool Failure Modes
chromVAR -- Too few peaks or too few reads
Trigger: ATAC peakset 5 (suspiciously high); top variable motifs are dominated by AT-rich or GC-rich sequences regardless of biology.
Fix: Verify peakset is at full ATAC scale (typically 50k-200k peaks). For sc ATAC, aggregate cells to clusters of >= 500 cells before running.
chromVAR background peaks -- Default is good, custom requires care
Trigger: Calling getBackgroundPeaks() with non-default niterations or bias.
Mechanism: Default 50 iterations × 10 bgd peaks per peak generates 500 background sets. Reducing niterations increases noise; increasing slows linearly without much accuracy gain.
Symptom: Custom backgrounds inflate variability when niterations 5x. Alternatively use ArchR's per-cluster background.
chromVAR on bulk samples without enough variation -- All z-scores near zero
Trigger: All bulk samples are technical replicates or very similar.
Mechanism: Z-scores normalize across the sample population; if there is no across-sample variability, all z-scores collapse to zero.
Symptom: Variability ranking is unstable across runs; top motifs change.
Fix: chromVAR is designed for variability; if the dataset has only one biological condition replicated, use footprinting or differential accessibility instead. chromVAR needs 6+ samples with biological variation to be informative.
Signac::RunChromVAR -- Motif matching mismatch
Trigger: Motif assay added before peak set finalized; peak coordinates change.
Mechanism: RunChromVAR matches motifs to peaks at the time it's called; if peaks change downstream (e.g., after merge), the motif annotations become stale.
Symptom: Some peaks have NA motif annotations; deviation matrix has missing entries.
Fix: Run AddMotifs() -> RunChromVAR() AFTER finalizing peakset. Re-run if peaks change.
ArchR::addDeviationsMatrix -- TileMatrix vs PeakMatrix
Trigger: Calling on tile matrix when peak matrix is more appropriate.
Mechanism: ArchR can compute deviations on either tiles (regular bins) or peaks. Peaks are biologically meaningful; tiles add noise from intergenic background.
Fix: Use matrixName='PeakMatrix' after addReproduciblePeakSet. Tile-based deviations are mainly for embedding, not biology.
Decision Tree by Setting
| Setting | Workflow | |---------|---------| | Bulk, 6+ samples, condition contrast | chromVAR + limma differential on z-scores; rank by FDR | | Bulk, 3-5 samples | chromVAR; report variability ranking; differential underpowered | | scATAC, Signac ecosystem | Signac AddMotifs + RunChromVAR; FindMarkers on motif assay | | scATAC, ArchR ecosystem | ArchR addPeakMatrix + addDeviationsMatrix + getMarkerFeatures | | Multimodal scATAC + scRNA | chromVAR + paired DE; consider SCENIC+ for TF -> target inference | | Plant / non-model organism | chromVAR with custom motif PFM (from CIS-BP); custom BSgenome | | Time-course bulk (5+ time points) | chromVAR z-scores -> spline regression on time; identify motifs with non-monotone trajectories |
chromVAR Workflow (Bulk)
Goal: Compute per-sample TF-motif accessibility z-scores corrected for GC bias and total signal.
Approach: Build a SummarizedExperiment from peak counts, add GC bias, filter sparse samples and peaks, match JASPAR motifs to peaks, sample matched background peaks, then compute deviations and per-motif variability.
library(chromVAR); library(motifmatchr); library(BSgenome.Hsapiens.UCSC.hg38)
library(JASPAR2024); library(TFBSTools); library(SummarizedExperiment)
peaks = 1500 reads/sample, FRiP >= 0.15, peak in >= 10% samples with >= 10 reads
se 5 | -5 to +10 | Major driver of cell-state differences; flagship hits |
Variability is the across-sample variance of z-scores; it ranks motifs without requiring condition labels. For unsupervised TF discovery (e.g., trajectory analysis) variability is the primary metric.
## Background Peak Matching Mathematics
**Trigger:** Tuning chromVAR's `getBackgroundPeaks` parameters; benchmarking against published results.
**Mechanism:** chromVAR matches each foreground peak to background peaks by GC content + total accessibility, in 25 GC bins x 25 accessibility bins (default). For each foreground peak, the algorithm samples k_iterations (default 50) replacement peaks from the matching bin. Variance across these matched samples becomes the null reference.
**Threshold tuning:**
- **bins=25** (default): each bin is ~4% GC range; works for >= 5,000 peaks. For very small peaksets (= 100 cells per cluster for stable projection |
| EnFormer-derived TF activity | Long-context Transformer | Cross-cell-type TF activity prediction; distal regulation | Pre-trained models cell-type-specific |
| DecoupleR ULM/MLM (Badia-i-Mompel 2022) | Multi-method consensus TF activity scoring | Multi-omics integration; aggregation across motif databases | Requires careful cell-x-motif input matrix |
For high-stakes per-cell TF activity, run chromVAR + scBasset and report the intersection. See atac-seq/deep-learning-atac for scBasset details.
## DecoupleR Multi-Method TF Activity
```python
import decoupler as dc
# adata: AnnData with motif_x_cell deviation matrix as input
acts_ulm = dc.run_ulm(mat=adata.obsm['chromvar'], net=collectri_net,
source='source', target='target')
acts_mlm = dc.run_mlm(mat=adata.obsm['chromvar'], net=collectri_net,
source='source', target='target')
acts_consensus = dc.run_consensus(mat=adata.obsm['chromvar'], net=collectri_net)
DecoupleR aggregates multiple TF-activity inference methods (ULM, MLM, viper, GSVA, etc.). The consensus output is more robust than any single method to motif database biases.
Common Errors
| Error / symptom | Cause | Solution | |-----------------|-------|----------| | Error in addGCBias: missing seqlengths | GRanges object lacks chrom sizes | Use `seqlengths(peaks) target inference
- chip-seq/motif-analysis - Alternative motif-enrichment approaches
- single-cell/clustering - Inputs for per-cluster motif activity
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: GPTomics
- Source: GPTomics/bioSkills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.