### Quick Start: Build Sphinx Docs Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Navigate to the docs directory and run 'make html' to rebuild the documentation. The output will be in docs/_build/html/. ```bash cd docs make html ``` -------------------------------- ### Install RegDiffusion Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/index.md Install the regdiffusion package using pip. ```bash pip install regdiffusion ``` -------------------------------- ### Install PySCENIC from GitHub Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/downstream_with_pyscenic.md Install the latest development version of PySCENIC directly from its GitHub repository using pip. ```bash >>> pip install git+https://github.com/aertslab/pySCENIC ``` -------------------------------- ### Install Sphinx Dependencies Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Install necessary packages for Sphinx documentation using pip. This includes Sphinx itself and common extensions. ```bash pip install sphinx sphinx-book-theme sphinx-copybutton myst-parser sphinxext-napoleon ``` -------------------------------- ### Set up PySCENIC Conda Environment Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/downstream_with_pyscenic.md Create and activate a new conda environment with specific Python and package versions to ensure compatibility with PySCENIC. Deactivate the environment after installation. ```bash >>> conda create -y -n pyscenic-env python=3.10 >>> conda activate pyscenic-env >>> pip install pyscenic==0.12.1 numpy==1.23.5 pandas==1.3.5 dask==2023.10.0 matplotlib decorator==4.3.0 >>> conda deactivate ``` -------------------------------- ### Install Package for Autodoc Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Install the current package in editable mode using 'pip install -e ..' to ensure autodoc can import modules. Ensure you are in the correct conda environment. ```bash pip install -e .. ``` -------------------------------- ### Draw Graph Function Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Sall1.html Initializes the graph visualization by getting the container element, parsing node data from Python, and creating a vis.js DataSet for nodes. ```javascript // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "Arglu1", "label": "Arglu1", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Picalm", "label": "Picalm", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Marcks", "label": "Marcks", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ywhah", "label": "Ywhah", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Pla2g4a", "label": "Pla2g4a", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Sdcbp", "label": "Sdcbp", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, ``` -------------------------------- ### Build HTML Documentation Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Use 'make html' to generate HTML documentation from source files. ```bash make html ``` -------------------------------- ### View Available Sphinx Build Targets Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Run 'make help' to see a list of all available build targets for Sphinx. ```bash make help ``` -------------------------------- ### Build EPUB Documentation with Sphinx Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Use 'make epub' to build documentation in EPUB format. ```bash make epub ``` -------------------------------- ### Troubleshooting: Run Sphinx without 'make' Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md If 'make' is not found, use 'python -m sphinx' directly to build the documentation. Specify the builder, source directory, and output directory. ```bash python -m sphinx -b html . _build/html ``` -------------------------------- ### Build PDF Documentation with Sphinx Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Use 'make latexpdf' to build documentation in PDF format. ```bash make latexpdf ``` -------------------------------- ### Initialize and Draw Graph Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Mertk.html Initializes graph data and options, then creates and returns a vis.js Network instance. This function should be called to render the graph. ```javascript function drawGraph() { nodes = new vis.DataSet([ { id: 1, label: "Node 1", color: "#007bff" }, { id: 2, label: "Node 2", color: "#28a745" }, { id: 3, label: "Node 3", color: "#ffc107" }, { id: 4, label: "Node 4", color: "#dc3545" } ]); edges = new vis.DataSet([ { from: 1, to: 2, arrows: "to" }, { from: 1, to: 3, arrows: "to" }, { from: 2, to: 4, arrows: "to" }, { from: 3, to: 4, arrows: "to" } ]); nodeColors = {}; allNodes = nodes.get({ returnType: "Object" }); for (nodeId in allNodes) { nodeColors[nodeId] = allNodes[nodeId].color; } allEdges = edges.get({ returnType: "Object" }); data = { nodes: nodes, edges: edges }; var options = { "configure": { "enabled": false }, "edges": { "color": { "inherit": true }, "smooth": { "enabled": true, "type": "dynamic" } }, "interaction": { "dragNodes": true, "hideEdgesOnDrag": false, "hideNodesOnDrag": false }, "physics": { "enabled": true, "repulsion": { "centralGravity": 0.2, "damping": 0.09, "nodeDistance": 100, "springConstant": 0.05, "springLength": 200 }, "solver": "repulsion", "stabilization": { "enabled": true, "fit": true, "iterations": 1000, "onlyDynamicEdges": false, "updateInterval": 50 } } }; network = new vis.Network(container, data, options); return network; } drawGraph(); ``` -------------------------------- ### Find Gene with Strongest Regulation Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/quick_tour.md Identifies the gene with the strongest single regulation by finding the maximum value across all rows in the adjacency matrix. This can be used to select a starting gene for local network analysis. ```python >>> grn.gene_names[np.argmax(grn.adj_matrix.max(1))] ``` -------------------------------- ### Configure and Draw Graph Network Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_P2ry12.html Sets up network options for interaction and physics, then initializes and draws the graph using vis.js. The graph features dynamic edge smoothing and repulsion-based physics stabilization. ```javascript var options = { "configure": { "enabled": false }, "edges": { "color": { "inherit": true }, "smooth": { "enabled": true, "type": "dynamic" } }, "interaction": { "dragNodes": true, "hideEdgesOnDrag": false, "hideNodesOnDrag": false }, "physics": { "enabled": true, "repulsion": { "centralGravity": 0.2, "damping": 0.09, "nodeDistance": 100, "springConstant": 0.05, "springLength": 200 }, "solver": "repulsion", "stabilization": { "enabled": true, "fit": true, "iterations": 1000, "onlyDynamicEdges": false, "updateInterval": 50 } } }; network = new vis.Network(container, data, options); return network; } drawGraph(); ``` -------------------------------- ### Initialize RegDiffusion Trainer with Memory Efficiency and AMP Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/large_networks.md Use this snippet to initialize the RegDiffusion trainer with both memory-efficient mode and automatic mixed precision enabled. Requires a GPU with bfloat16 support. ```python trainer = rd.RegDiffusionTrainer( exp_array, memory_efficient=True, use_amp=True, device='cuda' ) trainer.train() ``` -------------------------------- ### Draw and Configure Network Graph Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Tmem119.html Initializes and draws a network graph with specified nodes, edges, and options. Includes configuration for physics, interaction, and edge smoothing. ```javascript function drawGraph() { var container = document.getElementById("mynetwork"); nodes = new vis.DataSet([ { id: 1, label: "Cx3cr1", color: "#ff0000" }, { id: 2, label: "Tmem119", color: "#00ff00" }, { id: 3, label: "Serinc3", color: "#0000ff" }, { id: 4, label: "Csf1r", color: "#ffff00" }, { id: 5, label: "Calm2", color: "#ff00ff" } ]); edges = new vis.DataSet([ { from: 1, to: 2, width: 0.5 }, { from: 1, to: 3, width: 0.5 }, { from: 1, to: 4, width: 0.5 }, { from: 1, to: 5, width: 0.5 } ]); nodeColors = {}; allNodes = nodes.get({ returnType: "Object" }); for (nodeId in allNodes) { nodeColors[nodeId] = allNodes[nodeId].color; } allEdges = edges.get({ returnType: "Object" }); // adding nodes and edges to the graph data = {nodes: nodes, edges: edges}; var options = { "configure": { "enabled": false }, "edges": { "color": { "inherit": true }, "smooth": { "enabled": true, "type": "dynamic" } }, "interaction": { "dragNodes": true, "hideEdgesOnDrag": false, "hideNodesOnDrag": false }, "physics": { "enabled": true, "repulsion": { "centralGravity": 0.2, "damping": 0.09, "nodeDistance": 100, "springConstant": 0.05, "springLength": 200 }, "solver": "repulsion", "stabilization": { "enabled": true, "fit": true, "iterations": 1000, "onlyDynamicEdges": false, "updateInterval": 50 } } }; network = new vis.Network(container, data, options); return network; } drawGraph(); ``` -------------------------------- ### Initialize and Draw Network Graph Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Trem2.html Initializes a vis.js network graph with specified data and options, then draws it. Ensure the container element exists and data/options are properly defined. ```javascript function drawGraph() { var container = document.getElementById('mynetwork'); var options = {}; var data = {}; network = new vis.Network(container, data, options); return network; } drawGraph(); ``` -------------------------------- ### Graph Initialization and Data Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Siglech.html Initializes global variables and sets up the vis.js network graph with provided node and edge data. ```javascript // initialize global variables. var edges; var nodes; var allNodes; var allEdges; var nodeColors; var originalNodes; var network; var container; var options, data; var filter = { item : '', property : '', value : [] }; // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "C1qa", "label": "C1qa", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "B2m", "label": "B2m", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Itm2b", "label": "Itm2b", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Rgs10", "label": "Rgs10", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "C1qb", "label": "C1qb", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Slc2a5", "label": "Slc2a5", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ldhb", ``` -------------------------------- ### Graph Initialization and Drawing Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Hexb.html Initializes global variables and draws the network graph using vis.js. Parses node data from a Python-generated structure. ```javascript // initialize global variables. var edges; var nodes; var allNodes; var allEdges; var nodeColors; var originalNodes; var network; var container; var options, data; var filter = { item : '', property : '', value : [] }; // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "C1qa", "label": "C1qa", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Cd81", "label": "Cd81", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ctsb", "label": "Ctsb", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "B2m", "label": "B2m", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Itm2b", "label": "Itm2b", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ctsd", "label": "Ctsd", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ecscr", "label": "Ecscr", "shape": "dot", "size": 8} ]); } ``` -------------------------------- ### Configure Graph Visualization Options Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Sall1.html Sets various options for the graph visualization, including disabling configuration, enabling smooth edge transitions, and configuring physics-based layout with repulsion forces. ```javascript var options = { "configure": { "enabled": false }, "edges": { "color": { "inherit": true }, "smooth": { "enabled": true, "type": "dynamic" } }, "interaction": { "dragNodes": true, "hideEdgesOnDrag": false, "hideNodesOnDrag": false }, "physics": { "enabled": true, "repulsion": { "centralGravity": 0.2, "damping": 0.09, "nodeDistance": 100, "springConstant": 0.05, "springLength": 200 }, "solver": "repulsion" } }; ``` -------------------------------- ### Clean and Rebuild Sphinx Docs Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/BUILD.md Clean the build directory with 'make clean' before rebuilding with 'make html' to resolve issues. ```bash make clean make html ``` -------------------------------- ### Initialize Global Variables and Graph Data Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Fcrls.html Initializes global variables for graph elements and configuration, and prepares data for drawing the network graph. This includes setting up vis.js DataSets for nodes and edges. ```javascript // initialize global variables. var edges; var nodes; var allNodes; var allEdges; var nodeColors; var originalNodes; var network; var container; var options, data; var filter = { item : '', property : '', value : [] }; // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "C1qa", "label": "C1qa", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "B2m", "label": "B2m", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Rgs10", "label": "Rgs10", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Itm2b", "label": "Itm2b", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ywhah", "label": "Ywhah", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "C1qb", "label": "C1qb", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Slc2a5", ``` -------------------------------- ### Import Libraries Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/quick_tour.md Import the necessary regdiffusion and numpy libraries for GRN inference. ```python import regdiffusion as rd import numpy as numpy ``` -------------------------------- ### Initialize and Train RegDiffusion on CPU Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/large_networks.md Use this snippet to initialize the RegDiffusionTrainer with the device set to 'cpu' for CPU-based execution. This is suitable when GPU memory is insufficient. Training will be slower than on a GPU. ```python trainer = rd.RegDiffusionTrainer( exp_array, device='cpu', n_steps=1000 ) trainer.train() ``` -------------------------------- ### Initialize and Draw Graph with vis.js Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Cx3cr1.html This function initializes a vis.js network graph. It processes node and edge data, sets up graph options including physics-based layout and interaction, and renders the graph in a specified container. ```javascript function drawGraph() { var container = document.getElementById("mynetwork"); var nodes = new vis.DataSet([ {"from": "Lpcat2", "to": "Ctsd", "width": 0.5}, {"from": "Ctsd", "to": "Lpcat2", "width": 0.5}, {"from": "Olfml3", "to": "Lpcat2", "width": 0.5}, {"from": "Lpcat2", "to": "Vsir", "width": 0.5}, {"from": "Actb", "to": "Dpysl2", "width": 0.5}, {"from": "Actb", "to": "Ptafr", "width": 0.5}, {"from": "Itpripl1", "to": "Actb", "width": 0.5}, {"from": "Itpripl1", "to": "Bmp2k", "width": 0.5}, {"from": "Dpysl2", "to": "Itpripl1", "width": 0.5}, {"from": "Ptafr", "to": "Itpripl1", "width": 0.5}, {"from": "Cmtm6", "to": "Capza2", "width": 0.5}, {"from": "Bmp2k", "to": "Cmtm6", "width": 0.5}, {"from": "Capza2", "to": "Pfn1", "width": 0.5}, {"from": "Ubb", "to": "Capza2", "width": 0.5}, {"from": "Fscn1", "to": "Capza2", "width": 0.5}, {"from": "Capza2", "to": "Cst3", "width": 0.5}, {"from": "Vsir", "to": "Hexb", "width": 0.5}, {"from": "Vsir", "to": "Sparc", "width": 0.5}, {"from": "Vsir", "to": "Ctsd", "width": 0.5}, {"from": "Vsir", "to": "Olfml3", "width": 0.5}, {"from": "Hexb", "to": "Olfml3", "width": 0.5}, {"from": "Olfml3", "to": "C1qc", "width": 0.5}, {"from": "C1qa", "to": "Olfml3", "width": 0.5}, {"from": "Cst3", "to": "Olfml3", "width": 0.5}, {"from": "Ctsd", "to": "Olfml3", "width": 0.5}, {"from": "Fcrls", "to": "Olfml3", "width": 0.5}, {"from": "Ctss", "to": "Cst3", "width": 0.5}, {"from": "Ctss", "to": "C1qc", "width": 0.5}, {"from": "Hexb", "to": "Ctss", "width": 0.5}, {"from": "Hexb", "to": "Trem2", "width": 0.5}, {"from": "Trem2", "to": "C1qa", "width": 0.5}, {"from": "Trem2", "to": "C1qc", "width": 0.5}, {"from": "Cst3", "to": "Trem2", "width": 0.5}, {"from": "Itm2b", "to": "Trem2", "width": 0.5}, {"from": "Trem2", "to": "C1qb", "width": 0.5}, {"from": "Trem2", "to": "Sparc", "width": 0.5}, {"from": "Hexb", "to": "C1qc", "width": 0.5}, {"from": "C1qc", "to": "Cst3", "width": 0.5}, {"from": "C1qc", "to": "Tmsb4x", "width": 0.5}, {"from": "Hexb", "to": "Cst3", "width": 0.5}, {"from": "Ptafr", "to": "Dpysl2", "width": 0.5}, {"from": "Nptn", "to": "Mbnl1", "width": 0.5}, {"from": "Ddx5", "to": "Mbnl1", "width": 0.5}, {"from": "Mbnl1", "to": "Sirpa", "width": 0.5}, {"from": "Dpysl2", "to": "Mbnl1", "width": 0.5}, {"from": "Mbnl1", "to": "Ncoa3", "width": 0.5}, {"from": "Mbnl1", "to": "Bhlhe41", "width": 0.5}, {"from": "Mbnl1", "to": "Slc39a1", "width": 0.5}, {"from": "Tmed7", "to": "Mbnl1", "width": 0.5}, {"from": "Basp1", "to": "Cst3", "width": 0.5}, {"from": "Basp1", "to": "Tmsb4x", "width": 0.5}, {"from": "Basp1", "to": "Pfn1", "width": 0.5}, {"from": "Capza2", "to": "Basp1", "width": 0.5}, {"from": "Bin1", "to": "Basp1", "width": 0.5}, {"from": "Rgs10", "to": "Basp1", "width": 0.5}, {"from": "Pfn1", "to": "Cst3", "width": 0.5}, {"from": "Pfn1", "to": "Tmsb4x", "width": 0.5}, {"from": "Pfn1", "to": "Ubb", "width": 0.5}, {"from": "Fscn1", "to": "Fcrls", "width": 0.5}, {"from": "Fscn1", "to": "Cst3", "width": 0.5}, {"from": "Fscn1", "to": "Crybb1", "width": 0.5}, {"from": "Fscn1", "to": "Pfn1", "width": 0.5}, {"from": "Fscn1", "to": "Ubb", "width": 0.5}, {"from": "Ubb", "to": "Cst3", "width": 0.5}, {"from": "Tmsb4x", "to": "Ubb", "width": 0.5}, {"from": "Rgs10", "to": "Ubb", "width": 0.5}, {"from": "C1qb", "to": "Ubb", "width": 0.5}, {"from": "Bin1", "to": "Tmsb4x", "width": 0.5}, {"from": "Rgs10", "to": "Bin1", "width": 0.5}, {"from": "Hexb", "to": "Bin1", "width": 0.5}, {"from": "Bin1", "to": "Sparc", "width": 0.5}, {"from": "Fcrls", "to": "Bin1", "width": 0.5}, {"from": "Bin1", "to": "Cst3", "width": 0.5}"]); nodeColors = {}; allNodes = nodes.get({ returnType: "Object" }); for (nodeId in allNodes) { nodeColors[nodeId] = allNodes[nodeId].color; } allEdges = edges.get({ returnType: "Object" }); // adding nodes and edges to the graph data = {nodes: nodes, edges: edges}; var options = { "configure": { "enabled": false }, "edges": { "color": { "inherit": true }, "smooth": { "enabled": true, "type": "dynamic" } }, "interaction": { "dragNodes": true, "hideEdgesOnDrag": false, "hideNodesOnDrag": false }, "physics": { "enabled": true, "repulsion": { "centralGravity": 0.2, "damping": 0.09, "nodeDistance": 100, "springConstant": 0.05, "springLength": 200 }, "solver": "repulsion", "stabilization": { "enabled": true, "fit": true, "iterations": 1000, "onlyDynamicEdges": false, "updateInterval": 50 } } }; network = new vis.Network(container, data, options); return network; } drawGraph(); ``` -------------------------------- ### Configure Network Graph Options Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Pros1.html This snippet defines configuration options for a network graph visualization. It disables the configuration interface, enables smooth edge transitions, allows node dragging, and enables physics simulation with specific repulsion settings. ```javascript var options = { "configure": { "enabled": false }, "edges": { "color": { "inherit": true }, "smooth": { "enabled": true, "type": "dynamic" } }, "interaction": { "dragNodes": true, "hideEdgesOnDrag": false, "hideNodesOnDrag": false }, "physics": { "enabled": true, "repulsion": { "centralGravity": 0.2, "damping": 0.09, } } }; ``` -------------------------------- ### Initialize Graph Data Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_P2ry12.html Initializes global variables for graph elements and options, then parses and collects nodes and edges from Python data to create a vis.DataSet. ```javascript var edges; var nodes; var allNodes; var allEdges; var nodeColors; var originalNodes; var network; var container; var options, data; var filter = { item : '', property : '', value : [] }; // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "C1qa", "label": "C1qa", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Itm2b", "label": "Itm2b", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Marcks", "label": "Marcks", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "C1qb", "label": "C1qb", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Slc2a5", "label": "Slc2a5", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Btg1", "label": "Btg1", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": ``` -------------------------------- ### Graph Initialization and Drawing Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Trem2.html Initializes global variables and draws the network graph using the vis.js library. It parses node and edge data from a Python-generated structure. ```javascript // initialize global variables. var edges; var nodes; var allNodes; var allEdges; var nodeColors; var originalNodes; var network; var container; var options, data; var filter = { item : '', property : '', value : [] }; // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "C1qa", "label": "C1qa", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Cd81", "label": "Cd81", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ctsb", "label": "Ctsb", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "B2m", "label": "B2m", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Itm2b", "label": "Itm2b", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ctsd", "label": "Ctsd", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ecscr", "label": "Ecscr", ``` -------------------------------- ### Loading and Processing Network Data Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Trem2.html This snippet shows how to load nodes and edges from a dataset and prepare them for graph visualization. It also extracts node colors based on their properties. ```javascript nodes = $("#nodes").data(); edges = $("#edges").data(); nodeColors = {}; allNodes = nodes.get({ returnType: "Object" }); for (nodeId in allNodes) { nodeColors[nodeId] = allNodes[nodeId].color; } allEdges = edges.get({ returnType: "Object" }); // adding nodes and edges to the graph data = {nodes: nodes, edges: edges}; ``` -------------------------------- ### Graph Initialization Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_Pros1.html Initializes global variables and the vis.js network graph. Parses and collects nodes and edges from Python data. ```javascript // initialize global variables. var edges; var nodes; var allNodes; var allEdges; var nodeColors; var originalNodes; var network; var container; var options, data; var filter = { item : '', property : '', value : [] }; // This method is responsible for drawing the graph, returns the drawn network function drawGraph() { var container = document.getElementById('mynetwork'); // parsing and collecting nodes and edges from the python nodes = new vis.DataSet([ {"font": {"size": 30}, "group": null, "id": "Pdia4", "label": "Pdia4", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "C1qa", "label": "C1qa", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Ncoa3", "label": "Ncoa3", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "C1qb", "label": "C1qb", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Slc2a5", "label": "Slc2a5", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Btg1", "label": "Btg1", "shape": "dot", "size": 8}, {"font": {"size": 30}, "group": null, "id": "Cmklr1", ``` -------------------------------- ### Initialize Graph Data Source: https://github.com/tuftsbcb/regdiffusion/blob/master/docs/supplements/rd_hammond_P2ry12.html Initializes nodes and edges for graph visualization. Nodes are defined with properties like 'from', 'to', and 'width', while node colors are mapped from node IDs. ```javascript nodes = new vis.DataSet([{"id": "Lag3", "label": "Lag3", "color": "#007bff"}, {"id": "Sparc", "label": "Sparc", "color": "#28a745"}, {"id": "Ldhb", "label": "Ldhb", "color": "#ffc107"}, {"id": "Lgmn", "label": "Lgmn", "color": "#dc3545"}, {"id": "Lpcat2", "label": "Lpcat2", "color": "#17a2b8"}, {"id": "C1qc", "label": "C1qc", "color": "#6f42c1"}, {"id": "C1qa", "label": "C1qa", "color": "#fd7e14"}, {"id": "Cd81", "label": "Cd81", "color": "#20c997"}, {"id": "Ctsd", "label": "Ctsd", "color": "#6c757d"}, {"id": "Olfml3", "label": "Olfml3", "color": "#343a40"}, {"id": "Vsir", "label": "Vsir", "color": "#e83e8c"}, {"id": "Adap2os", "label": "Adap2os", "color": "#6610f2"}, {"id": "Dpysl2", "label": "Dpysl2", "color": "#6f42c1"}, {"id": "Tyrobp", "label": "Tyrobp", "color": "#28a745"}, {"id": "Fcer1g", "label": "Fcer1g", "color": "#007bff"}, {"id": "C1qb", "label": "C1qb", "color": "#dc3545"}, {"id": "Itm2b", "label": "Itm2b", "color": "#ffc107"}, {"id": "Ctss", "label": "Ctss", "color": "#17a2b8"}, {"id": "Cmtm6", "label": "Cmtm6", "color": "#6c757d"}, {"id": "Calm2", "label": "Calm2", "color": "#343a40"}, {"id": "Ecscr", "label": "Ecscr", "color": "#e83e8c"}, {"id": "Ltc4s", "label": "Ltc4s", "color": "#6610f2"}, {"id": "Trem2", "label": "Trem2", "color": "#007bff"}, {"id": "Ctsl", "label": "Ctsl", "color": "#28a745"}, {"id": "Tmsb4x", "label": "Tmsb4x", "color": "#dc3545"}, {"id": "Sepp1", "label": "Sepp1", "color": "#ffc107"}, {"id": "Malat1", "label": "Malat1", "color": "#17a2b8"}, {"id": "Adap2", "label": "Adap2", "color": "#6f42c1"}]); edges = new vis.DataSet([{"from": "Lag3", "to": "Sparc", "width": 0.5}, {"from": "Lag3", "to": "Ldhb", "width": 0.5}, {"from": "Lag3", "to": "Lgmn", "width": 0.5}, {"from": "Lgmn", "to": "Lpcat2", "width": 0.5}, {"from": "Lpcat2", "to": "C1qc", "width": 0.5}, {"from": "Sparc", "to": "Lpcat2", "width": 0.5}, {"from": "Lpcat2", "to": "C1qa", "width": 0.5}, {"from": "Cd81", "to": "Lpcat2", "width": 0.5}, {"from": "Ctsd", "to": "Lpcat2", "width": 0.5}, {"from": "Olfml3", "to": "Lpcat2", "width": 0.5}, {"from": "Lpcat2", "to": "Vsir", "width": 0.5}, {"from": "Adap2os", "to": "Dpysl2", "width": 0.5}, {"from": "Tyrobp", "to": "Fcer1g", "width": 0.5}, {"from": "C1qb", "to": "Fcer1g", "width": 0.5}, {"from": "Itm2b", "to": "Fcer1g", "width": 0.5}, {"from": "C1qc", "to": "Fcer1g", "width": 0.5}, {"from": "Ctss", "to": "Fcer1g", "width": 0.5}, {"from": "C1qa", "to": "Fcer1g", "width": 0.5}, {"from": "Lgmn", "to": "C1qc", "width": 0.5}, {"from": "Ctss", "to": "Lgmn", "width": 0.5}, {"from": "Trem2", "to": "Lgmn", "width": 0.5}, {"from": "Cmtm6", "to": "Calm2", "width": 0.5}, {"from": "Lgmn", "to": "Vsir", "width": 0.5}, {"from": "Vsir", "to": "Sparc", "width": 0.5}, {"from": "Ecscr", "to": "Vsir", "width": 0.5}, {"from": "Vsir", "to": "Ctsd", "width": 0.5}, {"from": "Vsir", "to": "Olfml3", "width": 0.5}, {"from": "Ltc4s", "to": "Ctsd", "width": 0.5}, {"from": "Sparc", "to": "Ltc4s", "width": 0.5}, {"from": "Ecscr", "to": "Ltc4s", "width": 0.5}, {"from": "C1qc", "to": "Ltc4s", "width": 0.5}, {"from": "Olfml3", "to": "C1qc", "width": 0.5}, {"from": "Olfml3", "to": "Lgmn", "width": 0.5}, {"from": "C1qa", "to": "Olfml3", "width": 0.5}, {"from": "Ctsd", "to": "Olfml3", "width": 0.5}, {"from": "Ctss", "to": "C1qc", "width": 0.5}, {"from": "Trem2", "to": "C1qa", "width": 0.5}, {"from": "Ctsl", "to": "Trem2", "width": 0.5}, {"from": "Trem2", "to": "C1qc", "width": 0.5}, {"from": "Itm2b", "to": "Trem2", "width": 0.5}, {"from": "Trem2", "to": "C1qb", "width": 0.5}, {"from": "Trem2", "to": "Sparc", "width": 0.5}, {"from": "Ctsd", "to": "Ctsl", "width": 0.5}, {"from": "Ctsl", "to": "C1qc", "width": 0.5}, {"from": "Sparc", "to": "Ctsl", "width": 0.5}, {"from": "Ctss", "to": "Ctsl", "width": 0.5}, {"from": "C1qc", "to": "Tmsb4x", "width": 0.5}, {"from": "C1qb", "to": "Sepp1", "width": 0.5}, {"from": "Sepp1", "to": "Itm2b", "width": 0.5}, {"from": "Sepp1", "to": "Tyrobp", "width": 0.5}, {"from": "Fcer1g", "to": "Sepp1", "width": 0.5}, {"from": "Sepp1", "to": "Calm2", "width": 0.5}, {"from": "Malat1", "to": "Adap2os", "width": 0.5}, {"from": "Malat1", "to": "Lgmn", "width": 0.5}, {"from": "Malat1", "to": "Adap2", "width": 0.5}, {"from": "C1qa", "to": "Tyrobp", "width": 0.5}, {"from": "Tyrobp", "to": "Ctss", "width": 0.5}]); nodeColors = {}; allNodes = nodes.get({ returnType: "Object" }); for (nodeId in allNodes) { nodeColors[nodeId] = allNodes[nodeId].color; } allEdges = edges.get({ returnType: "Object" }); data = {nodes: nodes, edges: edges}; ```