{"id":"arboreto","name":"arboreto","summary":"スケーラブルなアルゴリズム(GRNBoost2、GENIE3)を用いて遺伝子発現データから遺伝子調節ネットワーク(GRN)を推定します。","body":"# Arboreto\n\n## Overview\n\nArboreto 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.\n\n**Core capability**: Identify which transcription factors (TFs) regulate which target genes based on expression patterns across observations (cells, samples, conditions).\n\n**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).\n\n## Quick Start\n\nInstall arboreto:\n```bash\nuv pip install arboreto\n```\n\nBasic GRN inference:\n```python\nimport pandas as pd\nfrom arboreto.algo import grnboost2\n\nif __name__ == '__main__':\n    # Load expression data (genes as columns)\n    expression_matrix = pd.read_csv('expression_data.tsv', sep='\\t')\n\n    # Infer regulatory network\n    network = grnboost2(expression_data=expression_matrix)\n\n    # Save results (TF, target, importance)\n    network.to_csv('network.tsv', sep='\\t', index=False, header=False)\n```\n\n**Critical**: Always use `if __name__ == '__main__':` guard because Dask spawns new processes.\n\n## Core Capabilities\n\n### 1. Basic GRN Inference\n\nFor standard GRN inference workflows including:\n- Input data preparation (Pandas DataFrame or NumPy array)\n- Running inference with GRNBoost2 or GENIE3\n- Filtering by transcription factors\n- Output format and interpretation\n\n**See**: `references/basic_inference.md`\n\n**Use the ready-to-run script**: `scripts/basic_grn_inference.py` for standard inference tasks:\n```bash\npython scripts/basic_grn_inference.py expression_data.tsv output_network.tsv --tf-file tfs.txt --seed 777 --limit 5000\n```\n\n### 2. Algorithm Selection\n\nArboreto provides two algorithms:\n\n**GRNBoost2 (Recommended)**:\n- Fast gradient boosting-based inference\n- Optimized for large datasets (10k+ observations)\n- Default choice for most analyses\n\n**GENIE3**:\n- Random Forest-based inference\n- Original multiple regression approach\n- Use for comparison or validation\n\nQuick comparison:\n```python\nfrom arboreto.algo import grnboost2, genie3\n\n# Fast, recommended\nnetwork_grnboost = grnboost2(expression_data=matrix)\n\n# Classic algorithm\nnetwork_genie3 = genie3(expression_data=matrix)\n```\n\n**For detailed algorithm comparison, parameters, and selection guidance**: `references/algorithms.md`\n\n### 3. Distributed Computing\n\nScale inference from local multi-core to cluster environments:\n\n**Local (default)** - Uses all available cores automatically:\n```python\nnetwork = grnboost2(expression_data=matrix)\n```\n\n**Custom local client** - Control resources:\n```python\nfrom distributed import LocalCluster, Client\n\nlocal_cluster = LocalCluster(n_workers=10, memory_limit='8GB')\nclient = Client(local_cluster)\n\nnetwork = grnboost2(expression_data=matrix, client_or_address=client)\n\nclient.close()\nlocal_cluster.close()\n```\n\n**Cluster computing** - Connect to remote Dask scheduler:\n```python\nfrom distributed import Client\n\nclient = Client('tcp://scheduler:8786')\nnetwork = grnboost2(expression_data=matrix, client_or_address=client)\n```\n\n**For cluster setup, performance optimization, and large-scale workflows**: `references/distributed_computing.md`\n\n## Installation\n\n```bash\nuv pip install arboreto\n```\n\nConda (Bioconda):\n\n```bash\nconda install -c bioconda arboreto\n```\n\n**Dependencies** (from upstream `requirements.txt`): `dask[complete]`, `distributed`, `numpy`, `pandas`, `scikit-learn`, `scipy`\n\n**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.\n\n## Common Use Cases\n\n### Single-Cell RNA-seq Analysis\n```python\nimport pandas as pd\nfrom arboreto.algo import grnboost2\n\nif __name__ == '__main__':\n    # Load single-cell expression matrix (cells x genes)\n    sc_data = pd.read_csv('scrna_counts.tsv', sep='\\t')\n\n    # Infer cell-type-specific regulatory network\n    network = grnboost2(expression_data=sc_data, seed=42)\n\n    # Filter high-confidence links\n    high_confidence = network[network['importance'] > 0.5]\n    high_confidence.to_csv('grn_high_confidence.tsv', sep='\\t', index=False)\n```\n\n### Bulk RNA-seq with TF Filtering\n```python\nfrom arboreto.utils import load_tf_names\nfrom arboreto.algo import grnboost2\n\nif __name__ == '__main__':\n    # Load data\n    expression_data = pd.read_csv('rnaseq_tpm.tsv', sep='\\t')\n    tf_names = load_tf_names('human_tfs.txt')\n\n    # Infer with TF restriction\n    network = grnboost2(\n        expression_data=expression_data,\n        tf_names=tf_names,\n        seed=123\n    )\n\n    network.to_csv('tf_target_network.tsv', sep='\\t', index=False)\n```\n\n### Comparative Analysis (Multiple Conditions)\n```python\nfrom arboreto.algo import grnboost2\n\nif __name__ == '__main__':\n    # Infer networks for different conditions\n    conditions = ['control', 'treatment_24h', 'treatment_48h']\n\n    for condition in conditions:\n        data = pd.read_csv(f'{condition}_expression.tsv', sep='\\t')\n        network = grnboost2(expression_data=data, seed=42)\n        network.to_csv(f'{condition}_network.tsv', sep='\\t', index=False)\n```\n\n## Output Interpretation\n\nArboreto returns a DataFrame with regulatory links:\n\n| Column | Description |\n|--------|-------------|\n| `TF` | Transcription factor (regulator) |\n| `target` | Target gene |\n| `importance` | Regulatory importance score (higher = stronger) |\n\n**Filtering strategy**:\n- `limit=N` at inference time (return top N links globally)\n- Post-hoc importance threshold (e.g., > 0.5)\n- Top links per target via `groupby('target')`\n- Statistical significance testing (permutation tests, external tools)\n\n## Integration with pySCENIC\n\nArboreto powers the GRN inference step in [pySCENIC](https://github.com/aertslab/pySCENIC). pySCENIC 0.11+ passes sparse expression matrices to `grnboost2` / `genie3`; pySCENIC 0.12+ defaults to `arboreto_with_multiprocessing.py` (no Dask) for compatibility — use standalone arboreto when you need Dask scaling.\n\n```python\n# Standalone: infer co-expression modules before pySCENIC cisTarget pruning\nfrom arboreto.algo import grnboost2\n\nnetwork = grnboost2(expression_data=expression_df, tf_names=tf_list, limit=5000)\n\n# Downstream: pySCENIC ctx pruning, regulon definition, AUCell (see pySCENIC docs)\n```\n\nConvert AnnData to a DataFrame for arboreto directly:\n\n```python\nexpression_df = adata.to_df()  # cells x genes\n```\n\n## Reproducibility\n\nAlways set a seed for reproducible results:\n```python\nnetwork = grnboost2(expression_data=matrix, seed=777)\n```\n\nRun multiple seeds for robustness analysis:\n```python\nfrom distributed import LocalCluster, Client\n\nif __name__ == '__main__':\n    client = Client(LocalCluster())\n\n    seeds = [42, 123, 777]\n    networks = []\n\n    for seed in seeds:\n        net = grnboost2(expression_data=matrix, client_or_address=client, seed=seed)\n        networks.append(net)\n\n    # Consensus: links recurring across runs (example: mean importance per TF-target pair)\n    import pandas as pd\n    combined = pd.concat(networks)\n    consensus = (\n        combined.groupby(['TF', 'target'], as_index=False)['importance']\n        .mean()\n        .query('importance > 0.5')\n    )\n```\n\n## Troubleshooting\n\n**Memory errors**: Reduce dataset size by filtering low-variance genes or use distributed computing\n\n**Slow performance**: Use GRNBoost2 instead of GENIE3, enable distributed client, filter TF list\n\n**Dask errors**: Ensure `if __name__ == '__main__':` guard is present in scripts (required on Windows/macOS with spawn-based multiprocessing)\n\n**Empty results**: Check data format (genes as columns), verify TF names match column names in the expression matrix\n\n**Sparse data**: Use `scipy.sparse.csc_matrix` and pass matching `gene_names`; supported since arboreto 0.1.6 / pySCENIC 0.11","author":"@K-Dense-AI","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/arboreto","license":"MIT","category":"document","lang":"en","tokens":2006,"stars":0,"calls30d":2,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"references/algorithms.md","size":4670,"sha256":"5facef4b0cf558eded6455f0154f48ba91e76567e27c10c87df9674d2ea89549"},{"path":"references/basic_inference.md","size":4605,"sha256":"0a7500fa1a20c376fd732b9bc78c3f4de5505b3e920398e591f9f057bb180007"},{"path":"references/distributed_computing.md","size":6734,"sha256":"9ce12f1c0279dd783ce3ecf240bff0fc02e1e44a32471cc44d361b40a0d4c683"},{"path":"scripts/basic_grn_inference.py","size":3318,"sha256":"4e184a0411ec6a81719591092db29dd51beb43b9b0639eae669d565cdb6d3ddb"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[{"code":"net.endpoints","kind":"exfiltration","excerpt":"arboreto.readthedocs.io, distributed.dask.org","message":"bundled scripts reach 2 external host(s)","severity":"warn"}],"scannedAt":"2026-08-22","hasScripts":true,"networkEndpoints":["arboreto.readthedocs.io","distributed.dask.org"]}}