$npx -y skills add K-Dense-AI/scientific-agent-skills --skill arboretoInfer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Suppo
| 1 | # Arboreto |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Arboreto is a Python library from [Aerts Lab](https://github.com/aertslab/arboreto) for inferring gene regulatory networks (GRNs) from gene expression data. It parallelizes tree-based ensemble regression (GRNBoost2, GENIE3) with [Dask](https://distributed.dask.org/) across local cores or remote clusters. |
| 6 | |
| 7 | **Core capability**: Identify which transcription factors (TFs) regulate which target genes based on expression patterns across observations (cells, samples, conditions). |
| 8 | |
| 9 | **Upstream**: PyPI **0.1.6** (2021-02-09, latest). Docs: [arboreto.readthedocs.io](https://arboreto.readthedocs.io/en/latest/). Primary downstream consumer: [pySCENIC](https://github.com/aertslab/pySCENIC). |
| 10 | |
| 11 | ## Quick Start |
| 12 | |
| 13 | Install arboreto: |
| 14 | ```bash |
| 15 | uv pip install arboreto |
| 16 | ``` |
| 17 | |
| 18 | Basic GRN inference: |
| 19 | ```python |
| 20 | import pandas as pd |
| 21 | from arboreto.algo import grnboost2 |
| 22 | |
| 23 | if __name__ == '__main__': |
| 24 | # Load expression data (genes as columns) |
| 25 | expression_matrix = pd.read_csv('expression_data.tsv', sep='\t') |
| 26 | |
| 27 | # Infer regulatory network |
| 28 | network = grnboost2(expression_data=expression_matrix) |
| 29 | |
| 30 | # Save results (TF, target, importance) |
| 31 | network.to_csv('network.tsv', sep='\t', index=False, header=False) |
| 32 | ``` |
| 33 | |
| 34 | **Critical**: Always use `if __name__ == '__main__':` guard because Dask spawns new processes. |
| 35 | |
| 36 | ## Core Capabilities |
| 37 | |
| 38 | ### 1. Basic GRN Inference |
| 39 | |
| 40 | For standard GRN inference workflows including: |
| 41 | - Input data preparation (Pandas DataFrame or NumPy array) |
| 42 | - Running inference with GRNBoost2 or GENIE3 |
| 43 | - Filtering by transcription factors |
| 44 | - Output format and interpretation |
| 45 | |
| 46 | **See**: `references/basic_inference.md` |
| 47 | |
| 48 | **Use the ready-to-run script**: `scripts/basic_grn_inference.py` for standard inference tasks: |
| 49 | ```bash |
| 50 | python scripts/basic_grn_inference.py expression_data.tsv output_network.tsv --tf-file tfs.txt --seed 777 --limit 5000 |
| 51 | ``` |
| 52 | |
| 53 | ### 2. Algorithm Selection |
| 54 | |
| 55 | Arboreto provides two algorithms: |
| 56 | |
| 57 | **GRNBoost2 (Recommended)**: |
| 58 | - Fast gradient boosting-based inference |
| 59 | - Optimized for large datasets (10k+ observations) |
| 60 | - Default choice for most analyses |
| 61 | |
| 62 | **GENIE3**: |
| 63 | - Random Forest-based inference |
| 64 | - Original multiple regression approach |
| 65 | - Use for comparison or validation |
| 66 | |
| 67 | Quick comparison: |
| 68 | ```python |
| 69 | from arboreto.algo import grnboost2, genie3 |
| 70 | |
| 71 | # Fast, recommended |
| 72 | network_grnboost = grnboost2(expression_data=matrix) |
| 73 | |
| 74 | # Classic algorithm |
| 75 | network_genie3 = genie3(expression_data=matrix) |
| 76 | ``` |
| 77 | |
| 78 | **For detailed algorithm comparison, parameters, and selection guidance**: `references/algorithms.md` |
| 79 | |
| 80 | ### 3. Distributed Computing |
| 81 | |
| 82 | Scale inference from local multi-core to cluster environments: |
| 83 | |
| 84 | **Local (default)** - Uses all available cores automatically: |
| 85 | ```python |
| 86 | network = grnboost2(expression_data=matrix) |
| 87 | ``` |
| 88 | |
| 89 | **Custom local client** - Control resources: |
| 90 | ```python |
| 91 | from distributed import LocalCluster, Client |
| 92 | |
| 93 | local_cluster = LocalCluster(n_workers=10, memory_limit='8GB') |
| 94 | client = Client(local_cluster) |
| 95 | |
| 96 | network = grnboost2(expression_data=matrix, client_or_address=client) |
| 97 | |
| 98 | client.close() |
| 99 | local_cluster.close() |
| 100 | ``` |
| 101 | |
| 102 | **Cluster computing** - Connect to remote Dask scheduler: |
| 103 | ```python |
| 104 | from distributed import Client |
| 105 | |
| 106 | client = Client('tcp://scheduler:8786') |
| 107 | network = grnboost2(expression_data=matrix, client_or_address=client) |
| 108 | ``` |
| 109 | |
| 110 | **For cluster setup, performance optimization, and large-scale workflows**: `references/distributed_computing.md` |
| 111 | |
| 112 | ## Installation |
| 113 | |
| 114 | ```bash |
| 115 | uv pip install arboreto |
| 116 | ``` |
| 117 | |
| 118 | Conda (Bioconda): |
| 119 | |
| 120 | ```bash |
| 121 | conda install -c bioconda arboreto |
| 122 | ``` |
| 123 | |
| 124 | **Dependencies** (from upstream `requirements.txt`): `dask[complete]`, `distributed`, `numpy`, `pandas`, `scikit-learn`, `scipy` |
| 125 | |
| 126 | **Input formats**: pandas DataFrame, dense `numpy.ndarray`, or sparse `scipy.sparse.csc_matrix` (rows = observations, columns = genes). For array/matrix inputs, pass `gene_names` explicitly. |
| 127 | |
| 128 | ## Common Use Cases |
| 129 | |
| 130 | ### Single-Cell RNA-seq Analysis |
| 131 | ```python |
| 132 | import pandas as pd |
| 133 | from arboreto.algo import grnboost2 |
| 134 | |
| 135 | if __name__ == '__main__': |
| 136 | # Load single-cell expression matrix (cells x genes) |
| 137 | sc_data = pd.read_csv('scrna_counts.tsv', sep='\t') |
| 138 | |
| 139 | # Infer cell-type-specific regulatory network |
| 140 | network = grnboost2(expression_data=sc_data, seed=42) |
| 141 | |
| 142 | # Filter high-confidence links |
| 143 | high_confidence = network[network['importance'] > 0.5] |
| 144 | high_confidence.to_csv('grn_high_confidence.tsv', sep='\t', index=False) |
| 145 | ``` |
| 146 | |
| 147 | ### Bulk RNA-seq with TF Filtering |
| 148 | ```python |
| 149 | from arboreto.utils import load_tf_names |
| 150 | from arboreto.algo import grnboost2 |
| 151 | |
| 152 | if __name__ == '__main__': |
| 153 | # Load data |