sc-grn
Infer gene regulatory networks from scRNA-seq using the pySCENIC workflow: GRNBoost2 for adjacency inference, cisTarget-style motif pruning, and AUCell regulon scoring.
SKILL.mdSkills/singlecell/scrna/sc-grn/SKILL.md
GitHubSingle-Cell GRN
Why This Exists
- Without it: regulon analysis requires several external resources and multi-step orchestration.
- With it: pySCENIC-style GRN outputs are standardized into one wrapper contract.
- Why OmicsClaw: tables, figures, and AnnData outputs are bundled together.
Core Capabilities
- Implementation-aligned pySCENIC workflow: adjacency inference, motif pruning, and regulon scoring.
- Explicit external-resource contract: TF list, cisTarget databases, and motif annotations are surfaced as real prerequisites.
- Regulon-centric outputs: adjacency, regulon, target, and AUCell tables.
- Direct figure exports: regulon activity UMAP, regulon heatmap, and network plot.
- Downstream-ready export: writes
adata_with_grn.h5ad, report, result JSON, README, and notebook artifacts.
Scope Boundary
This skill currently exposes one public workflow: pyscenic_workflow.
That workflow covers:
- GRNBoost2 adjacency inference
- motif-based pruning
- AUCell regulon scoring
Input Formats
| Format | Extension / form | Current wrapper support | Notes |
|---|---|---|---|
| AnnData | .h5ad |
preferred | most realistic path for preprocessed scRNA-seq |
| Shared-loader formats | .h5, .loom, .csv, .tsv, 10x directory |
technically loadable | usually still need preprocessing and external GRN resources |
| Demo | --demo |
yes | bundled lightweight fallback |
Input Expectations
- The current skill expects a preprocessed scRNA-seq object.
- Required external resources: TF list, cisTarget database files, and motif annotations.
- The wrapper does not automatically fetch pySCENIC resources for the user.
Workflow
- Load preprocessed expression data.
- Run adjacency inference.
- Prune candidate targets with motif evidence.
- Score regulon activity per cell.
- Export
adata_with_grn.h5ad, tables, figures,report.md, andresult.json.
CLI Reference
python omicsclaw.py run sc-grn \
--input <processed.h5ad> \
--tf-list <tfs.txt> \
--db '<db_glob>' \
--motif <motif.tbl> \
--output <dir>
Public Parameters
| Parameter | Role | Notes |
|---|---|---|
--tf-list |
transcription-factor list | core prerequisite for adjacency inference |
--db |
cisTarget database selector | usually a glob or database path |
--motif |
motif annotation table | required for pruning |
--n-top-targets |
wrapper-level export cap | limits exported targets per regulon |
--n-jobs |
parallelism control | runtime knob for pySCENIC steps |
--seed |
reproducibility control | affects stochastic components |
Algorithm / Methodology
Current OmicsClaw pyscenic_workflow runs:
- GRNBoost2 adjacency inference from expression data
- motif-based pruning using the supplied cisTarget and motif resources
- AUCell regulon scoring per cell
- export of regulon activity and target summaries back into the output AnnData
Important implementation notes:
n_top_targetsis a wrapper-level export control, not a full pySCENIC science knob.- Resource availability matters more than fine parameter tuning for first-pass success.
Output Contract
Successful runs write:
adata_with_grn.h5adreport.mdresult.jsontables/grn_adjacencies.csvtables/grn_regulons.csvtables/grn_regulon_targets.csvtables/grn_auc_matrix.csvfigures/
Visualization Contract
The current wrapper writes direct figure outputs rather than a recipe-driven gallery:
figures/regulon_activity_umap.pngfigures/regulon_heatmap.pngfigures/regulon_network.png
What Users Should Inspect First
report.mdtables/grn_regulons.csvfigures/regulon_activity_umap.pngtables/grn_auc_matrix.csvadata_with_grn.h5ad
Current Limitations
- This skill depends on external pySCENIC resources and does not download them automatically.
- This skill writes
README.mdand notebook-style reproducibility artifacts when notebook export dependencies are available.
Safety And Guardrails
- Verify the TF list, cisTarget databases, and motif annotations before promising a full run.
- Do not present
n_top_targetsas a full pySCENIC science parameter; it is a wrapper-level export control. - For short execution guardrails, see
knowledge_base/knowhows/KH-sc-grn-guardrails.md. - For longer method and interpretation guidance, see
knowledge_base/skill-guides/singlecell/sc-grn.md.
CLI Parameters
| Flag | Type | Default | Description | Validation |
|---|---|---|---|---|
--input |
str | None | Input AnnData file (.h5ad) |
Required unless --demo |
--output |
str | — | Output directory | Required |
--demo |
flag | off | Run with built-in demo data (GRNBoost2 only) | — |
--tf-list |
str | None | TF list file (one TF gene symbol per line) | Optional; required for full pySCENIC run |
--db |
str | None | cisTarget database glob pattern | Optional; required for motif pruning |
--motif |
str | None | Motif annotations file (.tbl) |
Optional; required for motif pruning |
--n-top-targets |
int | 50 | Maximum targets exported per regulon | Wrapper-level cap, not a pySCENIC science knob |
--n-jobs |
int | 4 | Number of parallel jobs for pySCENIC steps | — |
--seed |
int | 42 | Random seed for reproducibility | — |
--cluster-key |
str | leiden |
adata.obs column for cell grouping in figures |
— |
--allow-simplified-grn |
flag | off | Accept correlation-based GRN fallback when no TF/database/motif files are provided | Enables demo_mode logic without --demo |
--r-enhanced |
flag | off | Generate R Enhanced plots (requires R + ggplot2) | — |
R Enhanced Plots
| Renderer | Output file | Description |
|---|---|---|
plot_embedding_discrete |
figures/r_enhanced/r_embedding_discrete.png |
UMAP colored by discrete cluster labels |
plot_embedding_feature |
figures/r_enhanced/r_embedding_feature.png |
UMAP colored by a continuous feature (AUC score) |
Special Requirements
External pySCENIC Database Files
A full pySCENIC run with motif enrichment requires three external resource files that OmicsClaw does not download automatically:
| Resource | Flag | Example download |
|---|---|---|
| TF list (one TF per line) | --tf-list |
wget https://raw.githubusercontent.com/aertslab/pySCENIC/master/resources/hs_hgnc_tfs.txt |
cisTarget database (.feather) |
--db |
See https://resources.aertslab.org/cistarget/ |
Motif annotations (.tbl) |
--motif |
wget https://resources.aertslab.org/cistarget/motif2tf/motifs-v9-nr.hgnc-m0.001-o0.0.tbl |
Store downloaded files under examples/databases/motifs/ or provide explicit paths via the flags above.
Simplified / Fallback Mode
When --tf-list, --db, and --motif are all absent and --allow-simplified-grn is passed, the wrapper accepts a correlation-based fallback GRN (no motif pruning). This is useful for quick exploratory analysis or when pySCENIC databases are not yet available.
# Full pySCENIC run
python omicsclaw.py run sc-grn \
--input processed.h5ad \
--tf-list hs_hgnc_tfs.txt \
--db 'databases/*.feather' \
--motif motifs-v9-nr.hgnc-m0.001-o0.0.tbl \
--output results/
# Simplified fallback (no external databases needed)
python omicsclaw.py run sc-grn \
--input processed.h5ad \
--allow-simplified-grn \
--output results/
Workflow Position
Upstream: sc-clustering or sc-cell-annotation Downstream: Terminal analysis.