### Install Arboreto from Built Source Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Install the Arboreto package after it has been built from source, using pip to install from the 'dist' directory. ```bash $ pip install dist/* ``` -------------------------------- ### Check Arboreto Installation Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Verify the installation of Arboreto by using 'pip show arboreto'. This command displays details about the installed package, including its version and dependencies. ```bash $ 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: scipy, scikit-learn, numpy, pandas, dask, distributed ``` -------------------------------- ### Install Arboreto Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Install the latest version of the Arboreto package using pip. Ensure the Anaconda module is loaded before installation. ```bash pip install arboreto ``` -------------------------------- ### Install Arboreto using Pip Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Install the Arboreto package from PyPI using the pip package manager. This is a straightforward installation method. ```bash $ pip install arboreto ``` -------------------------------- ### Show Arboreto Package Information Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Display detailed information about the installed Arboreto package, including its version, summary, homepage, author, license, location, and dependencies. This is useful for verifying the installation. ```bash pip show arboreto ``` -------------------------------- ### Build Arboreto from Source Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Build the Arboreto package from its source code using the provided build script. This step is necessary before installing from source. ```bash $ ./pypi_build.sh ``` -------------------------------- ### Start Dask Scheduler Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Launch the Dask scheduler on a designated node (e.g., r6i0n5). This command also starts the Dask diagnostics dashboard, which can be accessed via a web browser. ```bash dask-scheduler ``` -------------------------------- ### Launch Jupyter Lab Server Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Starts a Jupyter Lab server on a specified port, serving notebooks from the current directory. Access it via the provided URL with a token. ```bash jupyter lab --port 9999 --no-browser [I 12:16:08.725 LabApp] JupyterLab alpha preview extension loaded from /data/leuven/software/biomed/Anaconda/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 ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Steps to create a new conda environment named 'arboreto-env', activate it, and then install Arboreto within that environment. ```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 ``` -------------------------------- ### Clone Arboreto Repository Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Clone the Arboreto GitHub repository using git and navigate into the cloned directory. This is the first step for installing from source. ```bash $ git clone https://github.com/tmoerman/arboreto.git $ cd arboreto ``` -------------------------------- ### Add Arboreto to sys.path and Import Core Functions Source: https://github.com/aertslab/arboreto/blob/master/notebooks/tutorial.ipynb Appends the Arboreto root directory to the system path and imports core and utility functions. This is a setup step for using Arboreto in a Jupyter environment. ```python import sys sys.path.append('../') # path to the arboreto root folder from arboreto.core import * from arboreto.utils import * ``` -------------------------------- ### Install Arboreto using Conda Source: https://github.com/aertslab/arboreto/blob/master/docs/installation.md Install Arboreto from the bioconda channel using the conda package manager. This is the recommended installation method. ```bash $ conda install -c bioconda arboreto ``` -------------------------------- ### SSH port forwarding for Dask dashboard Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Provides an example SSH command for port forwarding, allowing remote access to the Dask dashboard. ```bash $ ssh -L 8000:localhost:8787 nostromo ``` -------------------------------- ### Import necessary libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_imbalance_estimate.ipynb Imports essential Python libraries for data manipulation, machine learning, and visualization. Ensure these libraries are installed before running. ```python import os import sys sys.path.append('../../') from arboreto.core import * from arboreto.utils import * from sklearn import preprocessing import pandas as pd import seaborn as sns import matplotlib.pyplot as plt ``` -------------------------------- ### Check Distributed Version Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/03_macosko_repartition_test.ipynb Verifies the installed version of the distributed computing library. This is useful for ensuring compatibility. ```python distributed.__version__ ``` -------------------------------- ### Load Anaconda Module Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Load the Anaconda module on the front nodes to prepare the environment. This is a prerequisite for installing and running Python-based tools like Arboreto. ```bash module load Anaconda/5-Python-3.6 ``` -------------------------------- ### Get Size of 5k Inner Merge Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Calculates and displays the number of common connections found between the first 5,000 entries of the GENIE3 network and the first 5,000 connections of the Zeisel top 100k network. ```python len(inner_5k) ``` -------------------------------- ### Read and Display Top GO Terms (SGBM Kcnip1) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Loads a GOrilla results file for 'SGBM Kcnip1' and displays the top 5 GO terms, their descriptions, and p-values. Ensure the 'GOrilla/SGBM/GOrilla/GOrilla_sgbm_Kcnip1.xls' file is accessible. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Kcnip1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Read and Display Top GO Terms (RF Myrf) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Loads a GOrilla results file for 'RF Myrf' and displays the top 5 GO terms, their descriptions, and p-values. Ensure the 'GOrilla/RF/GOrilla/GOrilla_rf_Myrf.xls' file is accessible. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Myrf.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Initialize Dask Local Cluster and Client Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM_dup.ipynb Initializes a local Dask cluster with a memory limit of 8GB and creates a client to connect to it. The client object is then displayed. ```python client = Client(LocalCluster(memory_limit=8e9)) client ``` -------------------------------- ### Read and Display Top GO Terms (RF Kcnip1) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Loads a GOrilla results file for 'RF Kcnip1' and displays the top 5 GO terms, their descriptions, and p-values. Ensure the 'GOrilla/RF/GOrilla/GOrilla_rf_Kcnip1.xls' file is accessible. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Kcnip1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Get Number of Zeisel Genes Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Calculates and displays the total number of genes in the Zeisel dataset. ```python len(zeisel_genes) ``` -------------------------------- ### Initialize Dask Client Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Connect to a Dask distributed scheduler to enable distributed computing. This is the first step to running Arboreto in distributed mode. ```python from distributed import Client ``` ```python client = Client('tcp://10.118.224.134:8786') ``` ```python client ``` -------------------------------- ### Get Zeisel Metadata Size Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Calculates and displays the number of entries in the Zeisel metadata DataFrame. ```python len(meta_df) ``` -------------------------------- ### Get the size of the inferred network Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_denormalized_window.ipynb Calculates and returns the number of edges in the inferred network graph for net1. ```python len(net1) ``` -------------------------------- ### Get Zeisel DataFrame shape Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM_sqrt.ipynb Displays the dimensions (number of rows and columns) of the loaded Zeisel expression DataFrame. ```python zeisel_df.shape ``` -------------------------------- ### Initialize Dask client Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_denormalized_window.ipynb Imports Dask distributed client and initializes a local cluster for parallel computation. ```python from dask.distributed import Client, LocalCluster ``` ```python client = Client(LocalCluster()) ``` -------------------------------- ### Get Number of Network Edges Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/03_macosko_repartition_test.ipynb Returns the number of edges in the computed network DataFrame. This provides a count of the regulatory interactions identified. ```python len(network_df) ``` -------------------------------- ### Inspect create_graph Function Documentation Source: https://github.com/aertslab/arboreto/blob/master/notebooks/tutorial.ipynb Use the question mark (?) in Jupyter environments to quickly access the documentation and signature of the `create_graph` function. ```python create_graph? ``` -------------------------------- ### Initialize Dask LocalCluster and Client Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Initializes a local Dask cluster with a memory limit of 8GB and creates a client to connect to this cluster. This enables distributed computation. ```python client = Client(LocalCluster(memory_limit=8e9)) ``` -------------------------------- ### Read and Display GOrilla SGBM Results (Olig1) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads the GOrilla SGBM analysis results for 'Olig1' from a tab-separated file and displays the first few rows, showing GO Term, Description, and P-value. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Olig1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Get Size of Inner Merge Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Calculates and displays the number of common connections found between the GENIE3 network and the full top 100k Zeisel network. ```python len(inner) ``` -------------------------------- ### Get total number of unique TFs in merged data Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Calculates and prints the total number of unique Transcription Factors (TFs) present in the merged dataset. ```python len(merged) ``` -------------------------------- ### Instantiate Dask Client with local_dir Source: https://github.com/aertslab/arboreto/blob/master/docs/troubleshooting.md Specify the 'local_dir' when creating a Dask distributed Client to 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 ``` -------------------------------- ### Get Set of All-Zero Column Names Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/01_nr_trees_plot.ipynb Retrieves a set of column names from the DataFrame that contain only zero values. This helps in identifying and potentially removing these columns. ```python set(all_zeros.columns) ``` -------------------------------- ### Write denormalized networks Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Writes the top 100,000 links for each of the original (denormalized) networks (net1, net3, net4) to their respective output files. ```python net1_path = out_wd + 'net1.tsv' net3_path = out_wd + 'net3.tsv' net4_path = out_wd + 'net4.tsv' write_top(net1, net1_path) write_top(net3, net3_path) write_top(net4, net4_path) ``` -------------------------------- ### Read and Display GOrilla SGBM Dlx1 Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for SGBM Dlx1 analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Dlx1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Dask Connection Refused Error Source: https://github.com/aertslab/arboreto/blob/master/docs/questions.md This error indicates a failure to connect to a Dask worker, often due to the worker not running or being inaccessible. It typically occurs during communication setup. ```text OSError: Timed out trying to connect to 'tcp://10.118.224.141:35656' after 3.0 s: in : ConnectionRefusedError: [Errno 111] Connection refused ``` -------------------------------- ### Define Input and Output File Paths Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/03_macosko_repartition_test.ipynb Sets the file paths for the input Macosko dataset, transcription factor list, and the desired output file. Ensure these paths are correct for your environment. ```python macosko_40k = '/media/tmo/data/work/datasets/macosko/in/macosko_40k.tsv.gz' tfs = '/media/tmo/data/work/datasets/macosko/in/mm9_TFs.upper.txt' out = 'mac_40k.tsv' ``` -------------------------------- ### Define Input File Paths Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_03_grnboost2_transposed_input_file.ipynb Sets the working directory and defines the paths for the transposed expression data and transcription factor files. Ensure the 'arboreto' directory is correctly located in the parent path. ```python wd = os.getcwd().split('arboreto')[0] + 'arboreto/resources/dream5/' net1_ex_path = wd + 'net1/net1_expression_data.transposed.tsv' net1_tf_path = wd + 'net1/net1_transcription_factors.tsv' ``` -------------------------------- ### Get Size of 10k Inner Merge Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Calculates and displays the number of common connections found between the first 10,000 entries of the GENIE3 network and the first 10,000 connections of the Zeisel top 100k network. ```python len(inner_10k) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Imports core Arboreto modules, utility functions, matplotlib for plotting, and pandas for data handling. ```python import os import sys sys.path.append('../../') from arboreto.core import * from arboreto.utils import * import matplotlib.pyplot as plt import pandas as pd ``` -------------------------------- ### Get Size of 50k Inner Merge Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Calculates and displays the number of common connections found between the first 50,000 entries of the GENIE3 network and the first 50,000 connections of the Zeisel top 100k network. ```python len(inner_50k) ``` -------------------------------- ### Missing Dependencies Error Source: https://github.com/aertslab/arboreto/blob/master/docs/questions.md Indicates that the system cannot locate the necessary dependencies for a specific task key. This often requires checking task configurations and available resources. ```log distributed.worker - INFO - Can't find dependencies for key infer_data-e613bb78d805c6895285531ee785bb0f distributed.worker - INFO - Can't find dependencies for key infer_data-a174ef22d844b96c0b16398131fba613 distributed.worker - INFO - Can't find dependencies for key infer_data-c8cc0618ceb72b2a7dea62009edc8f44 ``` -------------------------------- ### Read and Display GOrilla RF Results (Olig1) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads the GOrilla RF analysis results for 'Olig1' from a tab-separated file and displays the first few rows, showing GO Term, Description, and P-value. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Olig1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Display XGBoost Default Parameters Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/01_nr_trees_plot.ipynb Shows the default keyword arguments used for XGBoost models. This can be useful for understanding the baseline configuration. ```python XGB_KWARGS ``` -------------------------------- ### Read and Display GOrilla RF Dlx1 Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for RF Dlx1 analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Dlx1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Initialize Dask Local Cluster Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_n_estimators_plots.ipynb Creates a Dask Client instance connected to a LocalCluster. This allows for distributed execution of tasks across multiple cores on the local machine. ```python client = Client(LocalCluster()) ``` -------------------------------- ### Load and Prepare GENIE3 Network Data Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/RF_Genie3_equivalence_check.ipynb Reads the GENIE3 network data from a tab-separated file into a pandas DataFrame and assigns column names. This step is crucial for subsequent analysis. ```python VA_net1 = pd.read_csv(VANANH_genie3_net1, sep='\t', header=None) VA_net1.columns = ['TF', 'target', 'importance'] ``` -------------------------------- ### Read and Display GOrilla SGBM Lef1 Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for SGBM Lef1 analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Lef1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Create custom Dask Client Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_02_grnboost2_custom_client.ipynb Creates a Dask client connected to the previously configured local cluster. This client can be used to submit tasks to the cluster and monitor progress via its dashboard URL. ```python custom_client = Client(local_cluster) ``` -------------------------------- ### Read and Display GOrilla SGBM Myrf Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for SGBM Myrf analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Myrf.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Read and Display GOrilla SGBM Results (Gli3) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads the GOrilla SGBM analysis results for 'Gli3' from a tab-separated file and displays the first few rows, showing GO Term, Description, and P-value. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Gli3.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Read and Display GOrilla RF Lef1 Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for RF Lef1 analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Lef1.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Create Dask computation graphs for GRN inference Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM.ipynb Generates the Dask computation graphs for the network and metadata using the `create_graph` function with specified parameters for the SGBM algorithm. This step is timed to measure performance. ```python %%time network_graph, meta_graph = create_graph(zeisel_ex_matrix, zeisel_gene_names, zeisel_tf_names, "GBM", SGBM_KWARGS, target_genes='all', early_stop_window_length=25, include_meta=True) ``` -------------------------------- ### Read and Display GOrilla SGBM Results (Neurod2) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads the GOrilla SGBM analysis results for 'Neurod2' from a tab-separated file and displays the first few rows, showing GO Term, Description, and P-value. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Neurod2.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Create Dask Graph with create_graph Source: https://github.com/aertslab/arboreto/blob/master/notebooks/tutorial.ipynb Use the `create_graph` function to build a Dask computation graph. Ensure input data and regressor parameters are correctly formatted. ```python graph = create_graph(zeisel_ex_matrix, zeisel_gene_names, zeisel_tf_names, "GBM", SGBM_KWARGS) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/RF_Genie3_equivalence_check.ipynb Imports core Arboreto functionalities and utility functions, along with standard Python libraries for path manipulation. ```python import os import sys sys.path.append('../../') from arboreto.core import * from arboreto.utils import * ``` -------------------------------- ### Inspect create_graph Function Signature Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/03_macosko_repartition_test.ipynb Displays the signature and docstring of the `create_graph` function. This is helpful for understanding its parameters and usage. ```python create_graph?? ``` -------------------------------- ### Define data paths for DREAM5 networks Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_imbalance_estimate.ipynb Sets up the file paths for expression data and transcription factor information for different DREAM5 networks (net1, net3, net4). This is crucial for loading the correct datasets. ```python wd = os.getcwd().split('arboreto')[0] + 'arboreto/resources/dream5/' net1_ex_path = wd + 'net1/net1_expression_data.tsv' net1_tf_path = wd + 'net1/net1_transcription_factors.tsv' net3_ex_path = wd + 'net3/net3_expression_data.tsv' net3_tf_path = wd + 'net3/net3_transcription_factors.tsv' net4_ex_path = wd + 'net4/net4_expression_data.tsv' net4_tf_path = wd + 'net4/net4_transcription_factors.tsv' ``` -------------------------------- ### Read and Display GOrilla RF Results (Neurod2) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads the GOrilla RF analysis results for 'Neurod2' from a tab-separated file and displays the first few rows, showing GO Term, Description, and P-value. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Neurod2.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Create and configure Dask LocalCluster Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_02_grnboost2_custom_client.ipynb Initializes a local Dask cluster with a specified number of workers and threads per worker. It's recommended to choose a number of workers less than the available CPU threads. ```python local_cluster = LocalCluster(n_workers=10, threads_per_worker=1) ``` -------------------------------- ### Define Data Directory Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Sets the path to the directory containing the normalized and denormalized network data files. ```python data_wd = 'dream5_norm_vs_denorm/' ``` -------------------------------- ### Read and Display GOrilla SGBM Rel Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for SGBM Rel analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Rel.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Write normalized networks Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Applies the normalization function and then writes the top 100,000 links for each normalized network (net1, net3, net4) to their respective output files. ```python net1_norm_path = out_wd + 'net1.norm.tsv' net3_norm_path = out_wd + 'net3.norm.tsv' net4_norm_path = out_wd + 'net4.norm.tsv' write_top(normalized(net1, meta1), net1_norm_path) write_top(normalized(net3, meta1), net3_norm_path) write_top(normalized(net4, meta1), net4_norm_path) ``` -------------------------------- ### Import Arboreto and Utility Libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_n_estimators_plots.ipynb Imports necessary modules from Arboreto, scikit-learn, pandas, seaborn, and matplotlib. These are essential for data manipulation, visualization, and network inference. ```python import os import sys sys.path.append('../../') from arboreto.algo import * from arboreto.core import * from arboreto.utils import * from sklearn import preprocessing import pandas as pd import seaborn as sns import matplotlib.pyplot as plt ``` -------------------------------- ### Launch Dask scheduler with Bokeh disabled Source: https://github.com/aertslab/arboreto/blob/master/docs/troubleshooting.md Use this workaround when encountering Bokeh errors during Dask scheduler startup. This disables the Bokeh dashboard. ```bash dask-scheduler --no-bokeh ``` -------------------------------- ### Read and Display GOrilla RF Results (Gli3) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads the GOrilla RF analysis results for 'Gli3' from a tab-separated file and displays the first few rows, showing GO Term, Description, and P-value. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Gli3.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Import Libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_01_grnboost2_local.ipynb Imports necessary libraries for data manipulation and network inference. ```python import os import pandas as pd from arboreto.algo import grnboost2, genie3 from arboreto.utils import load_tf_names ``` -------------------------------- ### Define GOrilla Gene List 2 Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Initializes a second list of genes for GOrilla analysis. ```python GOrilla_GENES_2 = ['Ywhae', 'Myrf', 'Diablo', 'Kcnip1'] ``` -------------------------------- ### Read and Display GOrilla RF Rel Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for RF Rel analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Rel.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Create Dask computation graphs Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM_sqrt.ipynb Generates the Dask computation graphs for the network and meta-graph using the Zeisel data, gene names, TF names, and specified SGBM hyperparameters. This step measures the execution time. ```python %%time network_graph, meta_graph = create_graph(zeisel_ex_matrix, zeisel_gene_names, zeisel_tf_names, "GBM", SGBM_sqrt_KWARGS, target_genes='all', early_stop_window_length=25, include_meta=True) ``` -------------------------------- ### Read and Display GOrilla SGBM Tspan2 Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for SGBM Tspan2 analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/SGBM/GOrilla/GOrilla_sgbm_Tspan2.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Create Dask Computation Graphs Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM_dup.ipynb Generates the network and meta graphs using the create_graph function. This is the initial step in building the gene regulatory network. ```python network_graph, meta_graph = create_graph(zeisel_ex_matrix, zeisel_gene_names, zeisel_tf_names, "GBM", SGBM_KWARGS, target_genes='all', early_stop_window_length=25, include_meta=True) ``` -------------------------------- ### Display First Rows of Metadata Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/01_nr_trees_plot.ipynb Displays the first few rows of the loaded metadata DataFrame to give a preview of the data structure and content. ```python meta_df.head() ``` -------------------------------- ### Read and Display GOrilla RF Tspan2 Results Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Reads a tab-separated GOrilla results file for RF Tspan2 analysis and displays the top 5 GO terms, descriptions, and p-values. Ensure the file path is correct and pandas is imported. ```python pd.read_csv('GOrilla/RF/GOrilla/GOrilla_rf_Tspan2.xls', sep='\t')[['GO Term', 'Description', 'P-value']].head() ``` -------------------------------- ### Launch Dask Workers Source: https://github.com/aertslab/arboreto/blob/master/docs/lcb.md Launches 24 worker processes with 1 thread each, connected to the specified scheduler address. Use `--nthreads 1` for Arboreto. This command is optional and can be omitted. ```bash nice -n 10 dask-worker tcp://10.118.224.134:8786 --nprocs 24 --nthreads 1 ``` -------------------------------- ### Import necessary libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_denormalized_window.ipynb Imports core functionalities from arboreto and matplotlib for plotting. ```python import os import sys sys.path.append('../../') from arboreto.core import * from arboreto.utils import * import matplotlib.pyplot as plt ``` -------------------------------- ### Load Metadata Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Loads metadata files for networks net1, net3, and net4 into pandas DataFrames. Metadata typically contains information like 'n_estimators'. ```python net1_meta = pd.read_csv(data_wd + 'raw.meta1.tsv', sep='\t') net3_meta = pd.read_csv(data_wd + 'raw.meta3.tsv', sep='\t') net4_meta = pd.read_csv(data_wd + 'raw.meta4.tsv', sep='\t') ``` -------------------------------- ### Plot KDE of n_estimators with Bandwidth Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_n_estimators_plots.ipynb Generates kernel density plots for 'n_estimators' from three different meta-data sets (meta1, meta3, meta4) with a specified bandwidth. Saves the plot to a file. ```python f, ax = plt.subplots(ncols=3, figsize=(16,4)) bandwidth=10 ax1 = sns.kdeplot(meta1.n_estimators, shade=True, bw=bandwidth, ax=ax[0]) ax2 = sns.kdeplot(meta3.n_estimators, shade=True, bw=bandwidth, ax=ax[1]) ax3 = sns.kdeplot(meta4.n_estimators, shade=True, bw=bandwidth, ax=ax[2]) plt.savefig('dream5_n_estimators_bw_{}.svg'.format(bandwidth)) plt.show() ``` -------------------------------- ### Load GENIE3 Zeisel Network Data Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Reads a GENIE3 network file into a pandas DataFrame and assigns column names 'TF', 'target', and 'importance'. ```python z_genie3 = pd.read_csv('/media/tmo/data/work/datasets/benchmarks/genie3/zeisel/zeisel.filtered.genie3.txt', header=None, sep=' ') z_genie3.columns=['TF', 'target', 'importance'] ``` -------------------------------- ### Specify GENIE3 Network File Path Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/RF_Genie3_equivalence_check.ipynb Defines the file path for the GENIE3 network data. Ensure this path is correct for your system. ```python VANANH_genie3_net1 = '/media/tmo/data/work/datasets/WOTC/GENIE3/DREAM5_NetworkInference_Other1_Network1.txt' ``` -------------------------------- ### Define GOrilla Gene List 1 Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Initializes a list of genes for GOrilla analysis. ```python GOrilla_GENES = ['Olig1', 'Rel', 'Tspan2', 'Neurod2', 'Lef1', 'Gli3', 'Dlx1'] ``` -------------------------------- ### Display First 5 Transcription Factor Names Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_01_grnboost2_local.ipynb Prints the first 5 transcription factor names from the loaded list. ```python tf_names[:5] ``` -------------------------------- ### Import fixed_scoring module Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Imports the D5C4 class from the fixed_scoring module, which is used for evaluating the inferred networks. ```python from fixed_scoring import D5C4 ``` -------------------------------- ### Load Top 100k SGBM Network Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM_sqrt.ipynb Reads the previously saved top 100,000 network entries from a tab-separated file. ```python top_100k_10pct = pd.read_csv('zeisel_sgbm_100k.txt', sep=' ') ``` -------------------------------- ### Create Dask computation graphs for GRN inference Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_RF.ipynb Generates the Dask computation graphs for the GRN inference using the Random Forest (RF) algorithm. It includes the network graph and a meta-graph, with timing information. ```python %%time network_graph, meta_graph = create_graph(zeisel_ex_matrix, zeisel_gene_names, zeisel_tf_names, "RF", RF_KWARGS, target_genes='all', include_meta=True) ``` -------------------------------- ### Import Dask Distributed Client Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_n_estimators_plots.ipynb Imports the Client and LocalCluster classes from the dask.distributed library. These are used to set up a local Dask cluster for parallel computation. ```python from dask.distributed import Client, LocalCluster ``` -------------------------------- ### Define Zeisel Dataset Path Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_imbalance.ipynb Specifies the file path for the Zeisel dataset. Ensure this path is correct for your system. ```python zeisel_ex_path = '/media/tmo/data/work/datasets/zeisel/expression_sara_filtered.txt' ``` -------------------------------- ### Load Expression Data (Correct Orientation) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_03_grnboost2_transposed_input_file.ipynb Reads the expression data from a tab-separated file, specifying the first column as the index and indicating no header. The .T then transposes the matrix to have samples as rows and genes as columns, as expected by Arboreto. ```python ex_matrix = pd.read_csv(net1_ex_path, sep=' ', index_col=0, header=None).T ``` -------------------------------- ### Plot Target Count Histograms for Network 3 Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Generates and displays histograms for the target counts in both normalized (`net3_norm`) and denormalized (`net3_denorm`) SGBM networks using 50 and 40 bins, respectively. ```python count_by_target(net3_norm).hist(bins=50) count_by_target(net3_denorm).hist(bins=40) plt.show() ``` -------------------------------- ### Define GOrilla Gene List 3 Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Initializes a third list of genes for GOrilla analysis. ```python GOrilla_GENES_3 = ['Fubp1', 'Trim28', 'Ruvbl1', 'Zfp207', 'Crebzf', 'Gtf2b', 'Msra', 'Ubxn1', 'Prkrir', 'Otud4', 'Klf8'] ``` -------------------------------- ### Generate and Save GOrilla Lists (SGBM, TF Group 1) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Iterates through the first defined GOrilla gene list (GOrilla_GENES) to generate and save target/background gene lists for SGBM analysis. Each list is saved to a text file. ```python for go_TF in GOrilla_GENES: go_list = gorilla_list(net_sgbm_df, go_TF, zeisel_genes) pd.DataFrame(go_list).to_csv('GOrilla/SGBM/' + go_TF + '_sgbm_list.txt', index=False, header=False) ``` -------------------------------- ### Execute network inference and measure time Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_denormalized_window.ipynb Runs the network inference function for net1 and measures the execution time. ```python %%time net1, meta1 = infer_network_and_meta(net1_ex_path, net1_tf_path, client) ``` -------------------------------- ### Generate and Save GOrilla Lists (SGBM, TF Group 2) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Iterates through the second defined GOrilla gene list (GOrilla_GENES_2) to generate and save target/background gene lists for SGBM analysis. Each list is saved to a text file. ```python for go_TF in GOrilla_GENES_2: go_list = gorilla_list(net_sgbm_df, go_TF, zeisel_genes) pd.DataFrame(go_list).to_csv('GOrilla/SGBM/' + go_TF + '_sgbm_list.txt', index=False, header=False) ``` -------------------------------- ### Display Dask Client Information Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_n_estimators_plots.ipynb Prints the Dask client object, which provides information about the scheduler and the number of processes and cores available. This is useful for monitoring the Dask cluster. ```python client ``` -------------------------------- ### Display head of meta-data Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_denormalized_window.ipynb Shows the first few rows of the meta-data DataFrame, including 'n_estimators' and 'target'. ```python meta1.head() ``` -------------------------------- ### Generate and Save GOrilla Lists (SGBM, TF Group 3) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Iterates through the third defined GOrilla gene list (GOrilla_GENES_3) to generate and save target/background gene lists for SGBM analysis. Each list is saved to a text file. ```python for go_TF in GOrilla_GENES_3: go_list = gorilla_list(net_sgbm_df, go_TF, zeisel_genes) pd.DataFrame(go_list).to_csv('GOrilla/SGBM/' + go_TF + '_sgbm_list.txt', index=False, header=False) ``` -------------------------------- ### Basic Scatter Plot with Matplotlib Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_imbalance.ipynb Generates three scatter plots to visualize relationships between 'n_estimators', 'non_zero', and 'importance'. Uses a logarithmic color scale for 'importance' and a viridis colormap. ```python f, (ax1, ax2, ax3) = plt.subplots(1,3) color='importance' g1 = fused_df.plot.scatter(ax=ax1, x='n_estimators', y='non_zero', c=color, norm=mpl.colors.LogNorm(), alpha=0.1, cmap='viridis', figsize=(12,8)) g2 = fused_df.plot.scatter(ax=ax2, x='n_estimators', y='importance', c=color, norm=mpl.colors.LogNorm(), alpha=0.1, cmap='viridis', figsize=(12,8)) g3 = fused_df.plot.scatter(ax=ax3, y='non_zero', x='importance', c=color, norm=mpl.colors.LogNorm(), alpha=0.1, cmap='viridis', figsize=(12,8)) f.set_figwidth(33) plt.show() ``` -------------------------------- ### Run GRNBoost2 with a Dask Distributed Scheduler Source: https://github.com/aertslab/arboreto/blob/master/docs/userguide.md Use this snippet to perform gene regulatory network inference with Arboreto on a Dask distributed cluster. Ensure a Dask scheduler and workers are set up and accessible. ```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) ``` -------------------------------- ### Run GRNBoost2 Python Script Source: https://github.com/aertslab/arboreto/blob/master/docs/examples.md This Python script demonstrates how to run the GRNBoost2 algorithm using pandas for data manipulation and Dask for distributed computing. It loads expression data and transcription factor names, computes the GRN, and saves the output. ```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 ``` -------------------------------- ### Import Libraries for Zeisel Analysis Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_imbalance.ipynb Imports necessary libraries including pandas, numpy, matplotlib, and scikit-learn for data manipulation and visualization. ```python import pandas as pd import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import ipyvolume.pylab as p3 from sklearn import preprocessing ``` -------------------------------- ### Define Data Paths Source: https://github.com/aertslab/arboreto/blob/master/notebooks/examples/ex_01_grnboost2_local.ipynb Sets the working directory and defines the file paths for expression data and transcription factor names. ```python wd = os.getcwd().split('arboreto')[0] + 'arboreto/resources/dream5/' net1_ex_path = wd + 'net1/net1_expression_data.tsv' net1_tf_path = wd + 'net1/net1_transcription_factors.tsv' ``` -------------------------------- ### Initialize Delayed DataFrames for Network Inference Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/03_macosko_repartition_test.ipynb Initializes empty lists to store delayed DataFrames for links and metadata. This is a prerequisite for collecting results from parallel computations. ```python delayed_link_dfs = [] delayed_meta_dfs = [] ``` -------------------------------- ### Display Evaluation DataFrame Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_normalized.ipynb Displays the entire evaluation DataFrame, which contains performance metrics for different methods (GRNBoost, GENIE3). ```python eval_df ``` -------------------------------- ### Load Zeisel GENIE3 Data Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_SGBM_dup.ipynb Reads the Zeisel GENIE3 interaction data from a tab-separated file into a pandas DataFrame and assigns column names. ```python z_genie3 = pd.read_csv('/media/tmo/data/work/datasets/benchmarks/genie3/zeisel/zeisel.filtered.genie3.txt', header=None, sep='\t') z_genie3.columns=['TF', 'target', 'importance'] ``` -------------------------------- ### Plot Target Count Histograms for Network 1 Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Generates and displays histograms for the target counts in both normalized (`net1_norm`) and denormalized (`net1_denorm`) SGBM networks using 50 bins. ```python count_by_target(net1_norm).hist(bins=50) count_by_target(net1_denorm).hist(bins=50) plt.show() ``` -------------------------------- ### GENIE3 Results with STOCHASTIC_GBM_KWARGS (learning_rate=0.05) Source: https://github.com/aertslab/arboreto/blob/master/docs/DREAM5.md This snippet shows GENIE3 performance metrics and p-values with STOCHASTIC_GBM_KWARGS configured with 'learning_rate' set to 0.05. It includes overall scores, AUPR, AUROC, and network-specific metrics. ```text {'learning_rate': 0.05, 'max_features': 0.1, 'n_estimators': 10000, 'subsample': 0.9} Overall Score 3.435145e+01 - AUPR (pvalue) 3.633242e+01 - AUROC (pvalue) 3.237047e+01 - Net1 AUPR 2.642219e-01 - Net3 AUPR 1.148268e-01 + Net4 AUPR 2.169538e-02 + Net1 AUROC 7.968208e-01 - Net3 AUROC 6.258655e-01 + Net4 AUROC 5.216256e-01 + Net1 p-aupr 3.377141e-72 - Net3 p-aupr 2.067718e-36 + Net4 p-aupr 1.441108e-02 + Net1 p-auroc 2.120486e-78 - Net3 p-auroc 9.025234e-16 + Net4 p-auroc 4.042913e-05 + ``` -------------------------------- ### Display DataFrame Head Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_imbalance.ipynb Shows the first few rows of a pandas DataFrame. Useful for inspecting data after loading or manipulation. ```python meta_df.head() ``` ```python zeisel_sgbm_df.head() ``` ```python merged_df.head() ``` -------------------------------- ### Import Libraries for Analysis Source: https://github.com/aertslab/arboreto/blob/master/notebooks/analysis/01_nr_trees_plot.ipynb Imports pandas for data manipulation and matplotlib for plotting. Also imports core functionalities from the arboreto library. ```python import pandas as pd import matplotlib.pyplot as plt from arboreto.core import * ``` -------------------------------- ### Import Libraries Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Imports necessary libraries for data manipulation, numerical operations, and plotting. ```python import pandas as pd import numpy as np import matplotlib.pyplot as plt from random import shuffle ``` -------------------------------- ### Plot KDE for original and scaled data Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_imbalance_estimate.ipynb Generates Kernel Density Estimate plots for specified target genes in both original and scaled expression data. Requires matplotlib to display the plots. ```python targets = ['G1406', 'G687', 'G708'] for target in targets: net1_df[[target]].plot.kde() for target in targets: net1_scaled_df[[target]].plot.kde() plt.show() ``` -------------------------------- ### Score normalized networks Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Initializes the D5C4 scoring object and calculates the score for the normalized networks. The output shows the scores for each network and the scanning process. ```python s = D5C4() norm_score = s.score([net1_norm_path, net3_norm_path, net4_norm_path]) ``` -------------------------------- ### Plot Target Count Histograms for Network 4 Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Generates and displays histograms for the target counts in both normalized (`net4_norm`) and denormalized (`net4_denorm`) SGBM networks using 50 and 30 bins, respectively. ```python count_by_target(net4_norm).hist(bins=50) count_by_target(net4_denorm).hist(bins=30) plt.show() ``` -------------------------------- ### Write Top Network to TSV (Net3) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM.ipynb Writes the top ranked edges from the 'net3' network to a TSV file named 'net3.tsv'. ```python write_top(net3, 'net3.tsv') ``` -------------------------------- ### Create Denormalized Target Count DataFrame Source: https://github.com/aertslab/arboreto/blob/master/notebooks/dream5/DREAM5_SGBM_norm_vs_denorm.ipynb Creates a DataFrame `net3_denorm_count_by_target` containing sorted target counts for `net1_denorm`, potentially for comparison or further analysis. ```python net3_denorm_count_by_target = pd.DataFrame(net1_denorm.groupby(['target']).size(), columns=['count']).sort_values(by='count', ascending=False) ``` -------------------------------- ### Generate and Save GOrilla Lists (RF, TF Group 2) Source: https://github.com/aertslab/arboreto/blob/master/notebooks/zeisel/Zeisel_GOrilla_Analysis.ipynb Iterates through the second defined GOrilla gene list (GOrilla_GENES_2) to generate and save target/background gene lists for RF analysis. Each list is saved to a text file. ```python for go_TF in GOrilla_GENES_2: go_list = gorilla_list(net_rf_df, go_TF, zeisel_genes) pd.DataFrame(go_list).to_csv('GOrilla/RF/' + go_TF + '_rf_list.txt', index=False, header=False) ```