### Check Arboreto Installation Details Source: https://arboreto.readthedocs.io/en/latest/installation.html Verify the installation of the Arboreto package and display its metadata, including version, dependencies, and installation location. This is useful for confirming a successful installation. ```bash $ pip show arboreto ``` -------------------------------- ### Install and show Arboreto Source: https://arboreto.readthedocs.io/en/latest/lcb.html Install the latest version of Arboreto using pip and display its package information. ```bash $ pip install arboreto $ pip show arboreto Name: arboreto Version: 0.1.5 Summary: Scalable gene regulatory network inference using tree-based ensemble regressors Home-page: https://github.com/tmoerman/arboreto Author: Thomas Moerman Author-email: thomas.moerman@gmail.com License: BSD 3-Clause License Location: /vsc-hard-mounts/leuven-data/software/biomed/Anaconda/5-Python-3.6/lib/python3.6/site-packages Requires: scikit-learn, dask, numpy, scipy, distributed, pandas ``` -------------------------------- ### Install Arboreto from Built Source Source: https://arboreto.readthedocs.io/en/latest/installation.html Install the Arboreto package after building it from source using pip. This command installs the package from the local distribution files. ```bash $ pip install dist/* ``` -------------------------------- ### Build Arboreto from Source Source: https://arboreto.readthedocs.io/en/latest/installation.html Build the Arboreto package from the cloned source code using the provided build script. This prepares the package for installation. ```bash $ ./pypi_build.sh ``` -------------------------------- ### Start Jupyter Lab Server Source: https://arboreto.readthedocs.io/en/latest/lcb.html Launches a Jupyter Lab server on a specified port. Use this command in your terminal to begin a Jupyter session. ```bash $ jupyter lab --port 9999 --no-browser [I 12:16:08.725 LabApp] JupyterLab alpha preview extension loaded from /data/leuven/software/biAnaconda/5-Python-3.6/lib/python3.6/site-packages/jupyterlab JupyterLab v0.27.0 Known labextensions: [I 12:16:08.739 LabApp] Running the core application with no additional extensions or settings [I 12:16:08.766 LabApp] Serving notebooks from local directory: /ddn1/vol1/staging/leuven/stg_00002/lcb/tmoerman/nb [I 12:16:08.766 LabApp] 0 active kernels [I 12:16:08.766 LabApp] The Jupyter Notebook is running at: [I 12:16:08.766 LabApp] http://localhost:9999/?token=2dca6ce946265895846795c4983191c9f76ba954f414efdf [I 12:16:08.766 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 12:16:08.767 LabApp] Copy/paste this URL into your browser when you connect for the first time, to login with a token: http://localhost:9999/?token=2dca6ce946265895846795c4983191c9f76ba954f414efdf ``` -------------------------------- ### Install Arboreto using Pip Source: https://arboreto.readthedocs.io/en/latest/installation.html Install the Arboreto package from PyPI using the pip package manager. This is a straightforward method for installing Python packages. ```bash $ pip install arboreto ``` -------------------------------- ### Start Dask scheduler Source: https://arboreto.readthedocs.io/en/latest/lcb.html Launch the Dask scheduler on a VSC front node. This command also starts the Dask diagnostics dashboard. ```bash $ dask-scheduler distributed.scheduler - INFO - ----------------------------------------------- distributed.scheduler - INFO - Scheduler at: tcp://10.118.224.134:8786 distributed.scheduler - INFO - bokeh at: :35874 distributed.scheduler - INFO - Local Directory: /tmp/scheduler-wu5odlrh distributed.scheduler - INFO - ----------------------------------------------- distributed.worker - INFO - Registered to: tcp://10.118.224.134:8786 distributed.worker - INFO - ------------------------------------------------- distributed.worker - INFO - Registered to: tcp://10.118.224.134:8786 distributed.worker - INFO - ------------------------------------------------- ``` -------------------------------- ### Install Arboreto using Conda Source: https://arboreto.readthedocs.io/en/latest/installation.html Install the Arboreto package from the bioconda channel using the conda package manager. This is the recommended installation method. ```bash $ conda install -c bioconda arboreto ``` -------------------------------- ### Create and Activate Conda Environment for Arboreto Source: https://arboreto.readthedocs.io/en/latest/installation.html Create a new conda environment named 'arboreto-env', activate it, and then install Arboreto within this isolated environment. This ensures dependency management. ```bash # create the conda environment named "arboreto-env" $ conda create --name arboreto-env # activate the conda environment we just created $ source activate arboreto-env # note: your terminal will indicate which environment is active on the left (arboreto-env) $ ... # install arboreto into the "arboreto-env" environment (hit Y to proceed) (arboreto-env) $ conda install -c bioconda arboreto ``` -------------------------------- ### Connect to Dask Client in Jupyter Source: https://arboreto.readthedocs.io/en/latest/lcb.html Initializes a Dask client connection to a specified scheduler address within a Jupyter notebook. This code is used to verify the Dask cluster setup. ```python from distributed import Client client = Client('tcp://10.118.224.134:8786') client ``` -------------------------------- ### Read Transposed Gene Expression Matrix with Pandas Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html This example demonstrates how to read a transposed gene expression matrix using Pandas. The .T attribute transposes the DataFrame, aligning genes with columns and observations with rows, as expected by scikit-learn. ```python df = pd.read_csv(, index_col=0, sep='\t').T ``` -------------------------------- ### Instantiate Dask Client with Local Directory Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html Use this snippet to specify a local directory for Dask client operations, which can help resolve worker connection issues. Ensure the specified directory has sufficient space. ```python >>> from dask.distributed import Client, LocalCluster >>> worker_kwargs = {'local_dir': '/tmp'} >>> cluster = LocalCluster(**worker_kwargs) >>> client = Client(cluster) >>> client ``` -------------------------------- ### Initiate Arboreto GRN Inference with Dask Source: https://arboreto.readthedocs.io/en/latest/lcb.html Demonstrates how to specify a Dask client or address when calling the `genie3` function for distributed GRN inference. This enables parallel processing of the inference task. ```python network_df = genie3(expression_data=ex_matrix, tf_names=tf_names, client_or_address=client) ``` -------------------------------- ### Load Anaconda module Source: https://arboreto.readthedocs.io/en/latest/lcb.html Load the Anaconda module on VSC front nodes to prepare the environment for Python and Arboreto. ```bash $ module load Anaconda/5-Python-3.6 ``` -------------------------------- ### Load tmux module Source: https://arboreto.readthedocs.io/en/latest/lcb.html Load the tmux module on VSC front nodes to manage multiple SSH sessions. ```bash $ module load tmux/2.5-foss-2014a ``` -------------------------------- ### Enable Dask Diagnostics Dashboard with Custom Client Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html To enable the Dask diagnostics dashboard, create a LocalCluster without specifying 'diagnostics_port'. A custom Client connected to this cluster can then be passed to Arboreto's GRN inference algorithms. ```python local_cluster = LocalCluster() # diagnostics dashboard is enabled custom_client = Client(local_cluster) network = grnboost2(expression_data=ex_matrix, tf_names=tf_names, client=custom_client) # specify the custom client ``` -------------------------------- ### Clone Arboreto Repository Source: https://arboreto.readthedocs.io/en/latest/installation.html Clone the Arboreto GitHub repository locally using the git tool. This step is necessary before building from source. ```bash $ git clone https://github.com/tmoerman/arboreto.git $ cd arboreto ``` -------------------------------- ### Launch Dask Workers Source: https://arboreto.readthedocs.io/en/latest/lcb.html Launches 24 worker processes with 1 thread each, connected to the specified scheduler address. Use `--nthreads 1` for Arboreto. The `nice` command is optional for lower process priority. ```bash $ nice -n 10 dask-worker tcp://10.118.224.134:8786 --nprocs 24 --nthreads 1 ``` ```bash $ nice -n 10 dask-worker tcp://10.118.224.134:8786 --nprocs 24 --nthreads 1 ``` ```bash $ nice -n 10 dask-worker tcp://10.118.224.134:8786 --nprocs 24 --nthreads 1 ``` ```bash $ nice -n 10 dask-worker tcp://10.118.224.134:8786 --nprocs 24 --nthreads 1 ``` ```bash $ nice -n 10 dask-worker tcp://10.118.224.134:8786 --nprocs 24 --nthreads 1 ``` -------------------------------- ### Run GRNBoost2 with Python Script Source: https://arboreto.readthedocs.io/en/latest/examples.html This script demonstrates how to run the GRNBoost2 algorithm using a Python script. It loads expression data and transcription factor names, computes the gene regulatory network, and saves the output. Requires pandas and dask libraries. ```python import pandas as pd from distributed import Client, LocalCluster from arboreto.utils import load_tf_names from arboreto.algo import grnboost2 if __name__ == '__main__': in_file = 'net1_expression_data.tsv' tf_file = 'net1_transcription_factors.tsv' out_file = 'net1_grn_output.tsv' # ex_matrix is a DataFrame with gene names as column names ex_matrix = pd.read_csv(in_file, sep='\t') # tf_names is read using a utility function included in Arboreto tf_names = load_tf_names(tf_file) # instantiate a custom Dask distributed Client client = Client(LocalCluster()) # compute the GRN network = grnboost2(expression_data=ex_matrix, tf_names=tf_names, client_or_address=client) # write the GRN to file network.to_csv(out_file, sep='\t', index=False, header=False) ``` ```bash cd /resources/dream5/net1 python run_grnboost2 ``` -------------------------------- ### Running GRN Inference with Custom Dask Client Source: https://arboreto.readthedocs.io/en/latest/userguide.html This snippet demonstrates running GRN inference multiple times with different seed values using a single custom Dask client. Close the client and cluster after use. ```python import pandas as pd from arboreto.utils import load_tf_names from arboreto.algo import grnboost2 from distributed import LocalCluster, Client if __name__ == '__main__': # create custom LocalCluster and Client instances local_cluster = LocalCluster(n_workers=10, threads_per_worker=1, memory_limit=8e9) custom_client = Client(local_cluster) # load the data ex_matrix = pd.read_csv(, sep='\t') tf_names = load_tf_names() # run GRN inference multiple times network_666 = grnboost2(expression_data=ex_matrix, tf_names=tf_names, client_or_address=custom_client, # specify the custom client seed=666) network_777 = grnboost2(expression_data=ex_matrix, tf_names=tf_names, client_or_address=custom_client, # specify the custom client seed=777) # close the Client and LocalCluster after use client.close() local_cluster.close() network_666.to_csv('output_666.tsv', sep='\t', index=False, header=False) network_777.to_csv('output_777.tsv', sep='\t', index=False, header=False) ``` -------------------------------- ### Run GRNBoost2 with Dask Distributed Scheduler Source: https://arboreto.readthedocs.io/en/latest/userguide.html This snippet shows how to connect Arboreto's GRNBoost2 algorithm to a remote Dask distributed scheduler. Ensure a Dask scheduler and workers are running and accessible at the specified address. ```python import pandas as pd from arboreto.utils import load_tf_names from arboreto.algo import grnboost2 from distributed import Client if __name__ == '__main__': ex_matrix = pd.read_csv(, sep='\t') tf_names = load_tf_names() scheduler_address = 'tcp://10.118.224.134:8786' # example address of the remote scheduler cluster_client = Client(scheduler_address) # create a custom Client network = grnboost2(expression_data=ex_matrix, tf_names=tf_names, client_or_address=cluster_client) # specify Client connected to the remote scheduler network.to_csv('output.tsv', sep='\t', index=False, header=False) ``` -------------------------------- ### Dask Scheduler Bokeh Error Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html This log output indicates a 'TypeError: __init__() got an unexpected keyword argument 'host'' when the Dask scheduler attempts to launch the Bokeh service. This is a known issue fixed in Dask.distributed version 0.20.0. ```bash vsc12345@r6i0n5 ~ 12:00 $ dask-scheduler distributed.scheduler - INFO - ----------------------------------------------- distributed.scheduler - INFO - Could not launch service: ('bokeh', 8787) Traceback (most recent call last): File "/data/leuven/software/biomed/Anaconda/5-Python-3.6/lib/python3.6/site-packages/distributed/scheduler.py", line 430, in start_services service.listen((listen_ip, port)) File "/data/leuven/software/biomed/Anaconda/5-Python-3.6/lib/python3.6/site-packages/distributed/bokeh/core.py", line 31, in listen **kwargs) File "/data/leuven/software/biomed/Anaconda/5-Python-3.6/lib/python3.6/site-packages/bokeh/server/server.py", line 371, in __init__ tornado_app = BokehTornado(applications, extra_websocket_origins=extra_websocket_origins, prefix=self.prefix, **kwargs) TypeError: __init__() got an unexpected keyword argument 'host' distributed.scheduler - INFO - Scheduler at: tcp://10.118.224.134:8786 distributed.scheduler - INFO - http at: :9786 distributed.scheduler - INFO - Local Directory: /tmp/scheduler-y6b8mnih distributed.scheduler - INFO - ----------------------------------------------- distributed.scheduler - INFO - Receive client connection: Client-7b476bf6-c6d8-11e7-b839-a0040220fe80 distributed.scheduler - INFO - End scheduler at 'tcp://:8786' ``` -------------------------------- ### Run GRNBoost2 with Pandas DataFrame Source: https://arboreto.readthedocs.io/en/latest/userguide.html Launches GRNBoost2 inference using an expression matrix provided as a Pandas DataFrame. Ensure the DataFrame has gene names as column headers. The `if __name__ == '__main__':` block is necessary for Dask process management. ```python import pandas as pd from arboreto.utils import load_tf_names from arboreto.algo import grnboost2 if __name__ == '__main__': # ex_matrix is a DataFrame with gene names as column names ex_matrix = pd.read_csv(, sep='\t') # tf_names is read using a utility function included in Arboreto tf_names = load_tf_names() network = grnboost2(expression_data=ex_matrix, tf_names=tf_names) network.to_csv('output.tsv', sep='\t', index=False, header=False) ``` -------------------------------- ### Dask Scheduler Worker Connection Logs Source: https://arboreto.readthedocs.io/en/latest/lcb.html Logs indicating that worker processes have successfully connected to the Dask scheduler. ```log distributed.scheduler - INFO - Register tcp://10.118.224.134:43342 distributed.scheduler - INFO - Starting worker compute stream, tcp://10.118.224.134:43342 ``` -------------------------------- ### SSH port forwarding for Dask dashboard Source: https://arboreto.readthedocs.io/en/latest/lcb.html Use SSH port forwarding to access the Dask diagnostics dashboard running on a VSC front node from your local machine. ```bash ssh -L 8787:localhost:35874 hpc2-big3 ``` -------------------------------- ### Stabilize GRNBoost2 Output with a Seed Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html GRNBoost2 uses stochastic algorithms, leading to potentially different network outputs across runs. Providing a 'seed' value initializes the random number generator, ensuring reproducible results. ```python network_df = grnboost2(expression_data=ex_matrix, tf_names=tf_names, seed=777) ``` -------------------------------- ### Infer Gene Regulatory Network with GRNBoost2 Source: https://arboreto.readthedocs.io/en/latest/index.html This snippet shows how to load expression data and transcription factor names, then use the grnboost2 function to infer a gene regulatory network. Ensure you have pandas, arboreto.utils, and arboreto.algo imported. Replace and with your actual file paths. ```python # import python modules import pandas as pd from arboreto.utils import load_tf_names from arboreto.algo import grnboost2 if __name__ == '__main__': # load the data ex_matrix = pd.read_csv(, sep='\t') tf_names = load_tf_names() # infer the gene regulatory network network = grnboost2(expression_data=ex_matrix, tf_names=tf_names) network.head() ``` -------------------------------- ### SSH Port Forwarding for Jupyter Source: https://arboreto.readthedocs.io/en/latest/lcb.html Establishes an SSH tunnel to forward local port 9999 to the remote Jupyter server's port 9999. This is necessary to access the notebook server from your local machine. ```bash $ ssh -L 9999:localhost:9999 hpc2-big2 ``` -------------------------------- ### Expression Matrix as NumPy ndarray Source: https://arboreto.readthedocs.io/en/latest/userguide.html Use this snippet when your expression data is a NumPy ndarray. Ensure gene names are provided in the correct order corresponding to the matrix columns. ```python import numpy as np from arboreto.utils import load_tf_names from arboreto.algo import grnboost2 if __name__ == '__main__': # ex_matrix is a numpy ndarray, which has no notion of column names ex_matrix = np.genfromtxt(, delimiter='\t', skip_header=1) # we read the gene names from the first line of the file with open() as file: gene_names = [gene.strip() for gene in file.readline().split('\t')] # sanity check to verify the ndarray's nr of columns equals the length of the gene_names list assert ex_matrix.shape[1] == len(gene_names) # tf_names is read using a utility function included in Arboreto tf_names = load_tf_names() network = grnboost2(expression_data=ex_matrix, gene_names=gene_names, # specify the gene_names tf_names=tf_names) network.to_csv('output.tsv', sep='\t', index=False, header=False) ``` -------------------------------- ### Workaround for Dask Scheduler Bokeh Error Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html As a workaround for the Dask scheduler Bokeh error, you can launch the scheduler with the Bokeh dashboard disabled using the '--no-bokeh' flag. ```bash dask-scheduler --no-bokeh ``` -------------------------------- ### Disable Dask Diagnostics Dashboard Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html When Arboreto creates a LocalCluster instance, the diagnostics dashboard is disabled by default. This snippet shows how to explicitly disable it by setting 'diagnostics_port' to None. ```python local_cluster = LocalCluster(diagnostics_port=None) client = Client(local_cluster) ``` -------------------------------- ### Check DataFrame Shape Source: https://arboreto.readthedocs.io/en/latest/troubleshooting.html After reading or processing a gene expression matrix, it's crucial to verify its dimensions. This snippet shows how to check the shape of a Pandas DataFrame to ensure it matches expected dimensions (observations x genes). ```python df.shape ``` -------------------------------- ### Deactivate Conda Environment Source: https://arboreto.readthedocs.io/en/latest/installation.html Deactivate the currently active conda environment to return to the base environment. This is done after finishing work within the specific environment. ```bash # deactivate the current environment (arboreto-env) $ source deactivate # as you will see: the environment indication has disappeared. $ ... ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.