### Training Progress Example 2 Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Example output showing training progress, indicating the current epoch, completion percentage, and time. ```text Epoch 1424/1500: 95%|█████████▍| 1424/1500 [46:44<02:29, 1.97s/it, v_num=1] Monitored metric elbo_validation did not improve in the last 45 records. Best score: -4652.919. Signaling Trainer to stop. ``` -------------------------------- ### Training Progress Example 3 Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Example output showing training progress, indicating the current epoch, completion percentage, and time. ```text Epoch 1050/1500: 70%|███████ | 1050/1500 [35:02<15:00, 2.00s/it, v_num=1] ``` -------------------------------- ### Training Progress Example 1 Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Example output showing the training progress, including the current epoch, percentage completion, and time elapsed. ```text Epoch 1369/1500: 91%|█████████▏| 1369/1500 [45:44<04:22, 2.01s/it, v_num=1] Monitored metric elbo_validation did not improve in the last 45 records. Best score: -4881.255. Signaling Trainer to stop. ``` -------------------------------- ### Install Latest RegVelo Release Source: https://github.com/theislab/regvelo/blob/main/README.md Install the latest stable version of regvelo from PyPI. This is the recommended method for most users. ```bash pip install regvelo ``` -------------------------------- ### Training Output Example 1 Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Example output from the model training process, indicating seed, GPU availability, and potential data loading bottlenecks. ```text [rank: 0] Seed set to 0 GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores HPU available: False, using: 0 HPUs You are using a CUDA device ('NVIDIA A100 80GB PCIe') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0] SLURM auto-requeueing enabled. Setting signal handlers. /home/icb/yifan.chen/miniconda3/envs/regvelo_env/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. /home/icb/yifan.chen/miniconda3/envs/regvelo_env/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py:310: The number of training batches (2) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. /home/icb/yifan.chen/miniconda3/envs/regvelo_env/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. ``` -------------------------------- ### Training Output Example 2 Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Another example output from the model training process, similar to the first, detailing system configuration and potential performance warnings. ```text [rank: 0] Seed set to 0 GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores HPU available: False, using: 0 HPUs LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0] SLURM auto-requeueing enabled. Setting signal handlers. /home/icb/yifan.chen/miniconda3/envs/regvelo_env/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. /home/icb/yifan.chen/miniconda3/envs/regvelo_env/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py:310: The number of training batches (2) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. /home/icb/yifan.chen/miniconda3/envs/regvelo_env/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. ``` -------------------------------- ### Setup AnnData and Initialize RegVelo Model Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/03_perturbation_tutorial_murine.ipynb Sets up the AnnData object for RegVelo and initializes the VAE model with the prepared GRN. ```python REGVELOVI.setup_anndata(adata_baseline, spliced_layer="Ms", unspliced_layer="Mu") vae = REGVELOVI(adata_baseline, W=W, regulators=TF) ``` -------------------------------- ### Install Latest RegVelo Development Version Source: https://github.com/theislab/regvelo/blob/main/README.md Install the latest development version of regvelo directly from its GitHub repository. Use this if you need the newest features or bug fixes. ```bash pip install git+https://github.com/theislab/regvelo.git@main ``` -------------------------------- ### Import Libraries for SCENIC Tutorial Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/01_SCENIC_tutorial.ipynb Imports necessary Python libraries for data manipulation, analysis, and SCENIC integration. Ensure these libraries are installed in your environment. ```python import os import numpy as np import pandas as pd import scanpy as sc import loompy as lp import glob ``` -------------------------------- ### Model Download Confirmation Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This output indicates that a required model file has already been downloaded, confirming successful setup for subsequent analysis. ```text Finished hoxc3a -> elf1\nINFO  File rgv_model/model.pt already downloaded \n ``` -------------------------------- ### Progress Bar Example Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/humanlimb/Limb_ModelComp.ipynb This snippet shows a typical progress bar output during a computation, indicating the percentage of completion and the rate of cells processed per second. ```text 0%| | 0/12207 [00:00 elf1') and notes that the required model file is already downloaded, indicating efficient setup. ```text Finished sox9b -> elf1\nINFO  File rgv_model/model.pt already downloaded \n ``` -------------------------------- ### PETSC Error Handling Example (glb1l) Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This output shows a PETSC error related to a 'Broken Pipe' signal, likely occurring during socket operations. It suggests options for debugging and provides links to PETSC FAQs. ```text 100%|██████████| 697/697 [00:00<00:00, 2890.70cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 697/697 [00:00<00:00, 2874.07cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 4/4 [00:00<00:00, 57.42/s]\n ``` -------------------------------- ### Initialize Stepwise Simulation Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/tutorial.ipynb Sets up the simulation method and prepares data for a perturbed model by removing the TF 'nr2f5'. Computes the transition matrix for the perturbed system. ```python method = "stepwise" TF = "nr2f5" ada_perturb = adata_perturb_dict[TF].copy() ada_perturb.obs["cell_type"] = adata.obs["cell_type"].copy() vk_p = cr.kernels.VelocityKernel(ada_perturb).compute_transition_matrix() vkt_p = vk_p.transition_matrix.A ``` -------------------------------- ### Prepare data for one-step simulation Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/tutorial.ipynb Sets up the simulation method and prepares a copy of the AnnData object for perturbation analysis. This involves copying data and computing the transition matrix. ```python method = "one-step" TF = "nr2f5" adata_perturb = adata_perturb_dict[TF].copy() adata_perturb.obs["cell_type"] = adata.obs["cell_type"].copy() vk_p = cr.kernels.VelocityKernel(adata_perturb).compute_transition_matrix() vkt_p = vk_p.transition_matrix.A ``` -------------------------------- ### Load and Set Up Model for Perturbation Analysis Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/humanlimb/Limb_ModelComp.ipynb Reloads a pre-trained model and sets up the necessary parameters for subsequent analyses, including the number of samples and batch size. ```python vae_sr0 = REGVELOVI.load('vae_sr0', adata) rgv.tl.set_output(adata, vae_sr0, n_samples=30, batch_size=adata.n_obs) ``` -------------------------------- ### Run SCENIC Context Generation Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/01_SCENIC_tutorial.ipynb Executes the SCENIC context generation step using specified databases and input files. Ensure all file paths and database names are correctly set. ```python !pyscenic ctx "adj.csv" \ {f_db_names} \ --annotations_fname {f_motif_path} \ --expression_mtx_fname {f_loom_path_scenic} \ --output "reg.csv" \ --all_modules \ --num_workers 24 ``` -------------------------------- ### Training Output and Progress Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/humanlimb/Limb_ModelComp.ipynb This output shows the progress of the model training process, including seed initialization, GPU availability, and training progress bars. It indicates that the training is running and monitoring metrics. ```text Output: [rank: 0] Seed set to 0 GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores HPU available: False, using: 0 HPUs You are using a CUDA device ('NVIDIA A100 80GB PCIe') that has Tensor Cores. To properly utilize them, you should set `torch.set_float32_matmul_precision('medium' | 'high')` which will trade-off precision for performance. For more details, read https://pytorch.org/docs/stable/generated/torch.set_float32_matmul_precision.html#torch.set_float32_matmul_precision LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0] SLURM auto-requeueing enabled. Setting signal handlers. /home/icb/yifan.chen/miniconda3/envs/regvelo-py310-v2/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. /home/icb/yifan.chen/miniconda3/envs/regvelo-py310-v2/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py:310: The number of training batches (1) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. /home/icb/yifan.chen/miniconda3/envs/regvelo-py310-v2/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. ``` ```text Result: Training: 0%| | 0/1500 [00:00 sash1b INFO  File rgv_model/model.pt already downloaded ``` -------------------------------- ### Download and Verify Model Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This snippet indicates that the rgv_model.pt file has already been downloaded and is ready for use. No action is required if the file exists. ```text Finished elf1 -> sema3d INFO  File rgv_model/model.pt already downloaded ``` -------------------------------- ### Identify Terminal and Start Indices Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb Identifies indices for terminal states and specific cell types (e.g., 'NPB_nohox') from the AnnData object. These are used in subsequent simulations. ```python terminal_indices = np.where(adata.obs["term_states_fwd"].isin(TERMINAL_STATES))[0] start_indices = np.where(adata.obs["cell_type"].isin(["NPB_nohox"]))[0] ``` -------------------------------- ### Download and Verify Model Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This snippet indicates that the rgv_model.pt file has already been downloaded and is ready for use. No action is required if the file exists. ```text Finished elf1 -> sema4ba INFO  File rgv_model/model.pt already downloaded ``` -------------------------------- ### Train Models and Compare Results Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/hindbrain/modelcomparison.ipynb This snippet shows the training process for different model types and displays the resulting labels. It's useful for initial exploration of model performance. ```python adata = sc.read_csv("adata.csv") adata.obs["cell_type"] = adata.obs["cell_type"].astype("category") adata.var_names = [f"gene_{i}" for i in range(adata.shape[1])] adata.write("adata.h5ad") adata = sc.read_h5ad("adata.h5ad") # Train soft clustering model adata = sc.tl.regvelo.train(adata, model="soft_0") # Train hard clustering model adata = sc.tl.regvelo.train(adata, model="hard_0") # Train regularized soft clustering model adata = sc.tl.regvelo.train(adata, model="soft_regularized\nlam2:1.0_0") print(adata.obs["regvelo_model"]) ``` -------------------------------- ### Initialize ModelComparison Object Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/hindbrain/modelcomparison.ipynb Initializes the ModelComparison object from the regvelo library. This object is used to compare different model setups on the provided AnnData object and state transitions. ```python comp = ModelComparison(adata = adata, state_transition=STATE_TRANSITIONS) ``` -------------------------------- ### Download Pre-trained Model Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This command downloads a pre-trained GRN model. Ensure the file path is correct. ```bash Finished elf1 -> fhl3a\nINFO  File rgv_model/model.pt already downloaded \n\n ``` -------------------------------- ### PETSC Error Output (variant) Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This snippet presents another instance of the PETSC 'Broken Pipe' error, similar to the first example. It also provides guidance on debugging and troubleshooting. ```text 100%|██████████| 697/697 [00:00<00:00, 2405.58cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 697/697 [00:00<00:00, 2907.64cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 4/4 [00:00<00:00, 63.70/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash. ``` -------------------------------- ### PETSC Error during GRN Analysis (final variant) Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This snippet shows a PETSC error related to a 'Broken Pipe' signal, similar to previous examples. It includes progress bars and debugging suggestions. ```text 100%|██████████| 697/697 [00:00<00:00, 3109.97cell/s] [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/ [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run [0]PETSC ERROR: to get more information on the crash. 100%|██████████| 697/697 [00:00<00:00, 3333.38cell/s] [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket ``` -------------------------------- ### Download Pre-trained Model (fli1a) Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This command downloads a pre-trained GRN model for the gene 'fli1a'. The 'INFO' message indicates the model file is already present. ```bash Finished elf1 -> fli1a\nINFO  File rgv_model/model.pt already downloaded \n\n ``` -------------------------------- ### PETSC Error Handling Example Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This output shows a PETSC error related to a 'Broken Pipe' signal, likely occurring during socket operations. It suggests options for debugging and provides links to PETSC FAQs. ```text 100%|██████████| 697/697 [00:00<00:00, 1644.58cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 697/697 [00:00<00:00, 2734.33cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 4/4 [00:00<00:00, 61.10/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n ``` -------------------------------- ### Initialize and Train Model Comparison Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/humanlimb/Limb_ModelComp.ipynb Initialize the `ModelComparison` object with the annotated data, terminal states, and number of states. Then, train the models using a list of specified model types, lambda values, and number of repeats. ```python comp = ModelComparison(adata = adata,terminal_states=TERMINAL_STATES, n_states=n_STATES) comp.train(model_list=['soft','hard','soft_regularized'], lam2=[1.0], n_repeat=3) ``` -------------------------------- ### Instantiate RegVelo Model (REGVELOVI) Source: https://context7.com/theislab/regvelo/llms.txt Creates a REGVELOVI model that incorporates a GRN prior into the velocity VAE. The weight matrix `W` encodes the GRN skeleton, and `lam`/`lam2` control regularization strength. ```python import torch import regvelo as rgv # Example instantiation (parameters may vary) # model = rgv.REGVELOVI(adata, W=adata.uns["skeleton"], lam=1.0, lam2=0.0) ``` -------------------------------- ### PETSC Error Handling Example (fzd3a) Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This output shows a PETSC error related to a 'Broken Pipe' signal, likely occurring during socket operations. It suggests options for debugging and provides links to PETSC FAQs. ```text 100%|██████████| 697/697 [00:00<00:00, 3138.32cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 697/697 [00:00<00:00, 2760.82cell/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n100%|██████████| 4/4 [00:00<00:00, 57.42/s]\n[0]PETSC ERROR: ------------------------------------------------------------------------\n[0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket\n[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger\n[0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/\n[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run \n[0]PETSC ERROR: to get more information on the crash.\n ``` -------------------------------- ### PyTorch Lightning Trainer Configuration and Warnings Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/modelcomparison/ModelComp.ipynb Shows the configuration of the PyTorch Lightning Trainer, including GPU availability and potential performance bottlenecks related to DataLoader workers and logging intervals. It's recommended to increase `num_workers` for DataLoaders and adjust `log_every_n_steps` if needed. ```text GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores HPU available: False, using: 0 HPUs LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0] SLURM auto-requeueing enabled. Setting signal handlers. /home/icb/yifan.chen/miniconda3/envs/regvelo-test/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. /home/icb/yifan.chen/miniconda3/envs/regvelo-test/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py:310: The number of training batches (1) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. /home/icb/yifan.chen/miniconda3/envs/regvelo-test/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. ``` -------------------------------- ### Analysis Completion and Model Download Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This output confirms the completion of an analysis step (e.g., 'sox10 -> elf1') and indicates that the necessary model file was already downloaded, streamlining the process. ```text Finished sox10 -> elf1\nINFO  File rgv_model/model.pt already downloaded \n ``` -------------------------------- ### Initialize REGVELOVI Model Source: https://context7.com/theislab/regvelo/llms.txt Loads the GRN skeleton and initializes the REGVELOVI model with specified parameters. Ensure AnnData is set up with spliced and unspliced layers. ```python W = torch.tensor(adata.uns["skeleton"].values, dtype=torch.float32) TF_list = adata.uns["regulators"].tolist() rgv.REGVELOVI.setup_anndata(adata, spliced_layer="Ms", unspliced_layer="Mu") model = rgv.REGVELOVI( adata, W=W, # GRN weight matrix (targets x regulators) regulators=TF_list, # list of TF gene names soft_constraint=True, # use soft GRN constraint (recommended) lam=1.0, # GRN prior regularization strength lam2=0.0, # L1 Jacobian regularization n_hidden=256, n_latent=10, n_layers=1, dropout_rate=0.1, ) print(model) ``` -------------------------------- ### Initialize ModelComparison object Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Initializes the `ModelComparison` class from `regvelo` with the loaded AnnData object. ```python comp = ModelComparison(adata = adata) ``` -------------------------------- ### Seed Initialization Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/modelcomparison/ModelComp.ipynb Confirms that a random seed has been set for the training process, ensuring reproducibility. ```text [rank: 0] Seed set to 2 ``` -------------------------------- ### Download Model File Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb Indicates that the model file 'rgv_model/model.pt' has already been downloaded and is ready for use. ```text Output: Finished tfap2a -> elf1 INFO  File rgv_model/model.pt already downloaded ``` -------------------------------- ### Model Training Output Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/tutorial.ipynb This output indicates the progress and status of the model training process, including GPU availability and potential performance bottlenecks. ```text training model... ``` ```text GPU available: True (cuda), used: True TPU available: False, using: 0 TPU cores HPU available: False, using: 0 HPUs LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0] SLURM auto-requeueing enabled. Setting signal handlers. /home/icb/yifan.chen/miniconda3/envs/regvelo-py310-v2/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'train_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. /home/icb/yifan.chen/miniconda3/envs/regvelo-py310-v2/lib/python3.10/site-packages/lightning/pytorch/loops/fit_loop.py:310: The number of training batches (1) is smaller than the logging interval Trainer(log_every_n_steps=10). Set a lower value for log_every_n_steps if you want to see logs for the training epoch. /home/icb/yifan.chen/miniconda3/envs/regvelo-py310-v2/lib/python3.10/site-packages/lightning/pytorch/trainer/connectors/data_connector.py:425: The 'val_dataloader' does not have many workers which may be a bottleneck. Consider increasing the value of the `num_workers` argument` to `num_workers=7` in the `DataLoader` to improve performance. ``` ```text Result: 0%| | 0/1500 [00:00 fhod1\nINFO  File rgv_model/model.pt already downloaded \n\n ``` -------------------------------- ### Load Schwann cell dataset Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Loads the preprocessed mouse neural crest and Schwann cell dataset using `regvelo.datasets.schwann()`. ```python adata = rgv.datasets.schwann() ``` -------------------------------- ### Load and Prepare Prior GRN Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/03_perturbation_tutorial_murine.ipynb Loads the prior GRN from adata_baseline.uns['skeleton'], converts it to a PyTorch tensor, and transposes it for RegVelo. ```python W = adata_baseline.uns["skeleton"].copy() W = torch.tensor(np.array(W)).int() W = W.T ``` -------------------------------- ### Configure Plotting Parameters Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/tutorial.ipynb Sets up matplotlib parameters for generating publication-quality figures, including font type, DPI, transparency, and colormap. ```python plt.rcParams["svg.fonttype"] = "none" scv.settings.set_figure_params("scvelo", dpi=100, transparent=True, fontsize=14, color_map="viridis") ``` -------------------------------- ### Train Models Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Initiates the training process for specified models. It's recommended to set batch_size to min(adata.shape[0], 5000) to prevent out-of-memory errors. ```python comp.train(model_list=['soft','hard','soft_regularized'], lam2=[1.0], n_repeat=1, batch_size=min(adata.shape[0], 5000)) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Imports all required libraries for data analysis, including scanpy, cellrank, scvi, scvelo, and regvelo. ```python import numpy as np import scanpy as sc import cellrank as cr import scvi import scvelo as scv import regvelo as rgv from regvelo import REGVELOVI from regvelo import ModelComparison ``` -------------------------------- ### Load a Trained Model and Set Output Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/schwann/modelcomparison.ipynb Load a previously saved model and set its output for trajectory analysis. This involves specifying the number of samples and batch size for the computation. ```python vae_s = REGVELOVI.load('vae_s', adata) rgv.tl.set_output(adata, vae_s, n_samples=30, batch_size=5000) ``` -------------------------------- ### Import necessary libraries Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/02_RegVelo_preparation.ipynb Imports the required libraries for data manipulation and analysis with RegVelo and Scanpy. ```python import scvelo as scv import scanpy as sc import pandas as pd import numpy as np import regvelo as rgv ``` -------------------------------- ### REGVELOVI.setup_anndata Source: https://context7.com/theislab/regvelo/llms.txt Registers the AnnData object for use with the REGVELOVI model. This class method must be called before instantiating the model, specifying the layers for spliced and unspliced counts. ```APIDOC ## REGVELOVI.setup_anndata ### Description Class method that registers the spliced and unspliced layers with the scvi-tools data manager. Must be called before instantiating the model. ### Method `REGVELOVI.setup_anndata(adata, spliced_layer='Ms', unspliced_layer='Mu')` ### Parameters - **adata** (AnnData) - The AnnData object to register. - **spliced_layer** (str, optional) - The layer containing spliced counts. Defaults to 'Ms'. - **unspliced_layer** (str, optional) - The layer containing unspliced counts. Defaults to 'Mu'. ### Returns - None. Modifies the AnnData object in place for scvi-tools compatibility. ``` -------------------------------- ### Download Model File Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb This code snippet downloads the 'rgv_model.pt' file if it doesn't already exist. It indicates that the file is already present. ```python Finished elf1 -> hsp70.2\nINFO  File rgv_model/model.pt already downloaded \n ``` ```python Finished elf1 -> hspa5\nINFO  File rgv_model/model.pt already downloaded \n ``` ```python Finished elf1 -> hspb8\nINFO  File rgv_model/model.pt already downloaded \n ``` -------------------------------- ### Initialize and Compute Macrostates with GPCCA Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/03_perturbation_tutorial_murine.ipynb Initializes a GPCCA estimator with the computed VelocityKernel and computes macrostates based on a specified number of states and a cluster key. ```python estimator = cr.estimators.GPCCA(vk) estimator.compute_macrostates(n_states=10, cluster_key="celltype_update") ``` -------------------------------- ### Load and Process Regulon Matrix Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/murine/01_SCENIC_tutorial.ipynb Loads the saved regulon matrix and preprocesses it for RegVelo. This includes extracting transcription factor names and collapsing duplicate TFs by summing their rows. ```python # load saved regulon-target matrix reg = pd.read_csv("regulon_mat_all_regulons.csv", index_col = 0) reg.index = reg.index.str.extract(r"(\w+)")[0] reg = reg.groupby(reg.index).sum() ``` -------------------------------- ### Import necessary libraries Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb Imports all required libraries for RegVelo analysis, including scanpy, scvi, scvelo, and matplotlib. ```python import numpy as np import pandas as pd import scanpy as sc import cellrank as cr import scvi import scvelo as scv import regvelo as rgv import matplotlib.pyplot as plt import mplscience import seaborn as sns ``` -------------------------------- ### Download Pre-trained Model (hat1) Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb Downloads a pre-trained model for gene regulatory network analysis, specifically for the gene hat1. This is useful for quickly setting up the environment for GRN analysis. ```python Finished elf1 -> hat1 INFO  File rgv_model/model.pt already downloaded ``` ```python 100%|██████████| 697/697 [00:00<00:00, 2225.21cell/s] [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 13 Broken Pipe: Likely while reading or writing to a socket [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see https://petsc.org/release/faq/#valgrind and https://petsc.org/release/faq/ [0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run [0]PETSC ERROR: to get more information on the crash. 100%|██████████| 697/697 [00:00<00:00, 2742.22cell/s] ``` -------------------------------- ### Download Model and Run Inference Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb Downloads a pre-trained model and runs inference for a specific gene. This process may involve significant data transfer and processing. ```python Output: Finished elf1 -> ildr2 INFO  File rgv_model/model.pt already downloaded ``` -------------------------------- ### Download Model and Run Inference Source: https://github.com/theislab/regvelo/blob/main/docs/tutorials/zebrafish/grn_tutorial.ipynb Downloads a pre-trained model and runs inference for a specific gene. This process may involve significant data transfer and processing. ```python Output: Finished elf1 -> inka1a INFO  File rgv_model/model.pt already downloaded ```