knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(chariot2) library(tidyverse) library(cli)
This package creates a properly formatted output from the OMOP Vocabularies for consumption by the DiagrammeR package.
# Fetch from Postgres version_key = get_version_key() omop_relationships <- fetch_omop(version_key = version_key) omop_relationships@data
Make nodes and edges and add attributes.
nodes_and_edges <- create_nodes_and_edges(omop_relationships = omop_relationships) # Add Tooltip nodes_and_edges <- add_tooltip(nodes_and_edges = nodes_and_edges) # Customize Nodes Attributes nodes_and_edges <- map_node_attributes(nodes_and_edges) # Customize Edge Attributes nodes_and_edges <- map_edge_attributes(nodes_and_edges)
# Construct Final Graph final_graph <- construct_graph(nodes_and_edges)
library(DiagrammeR)
final_graph$graph %>% select_nodes(type == "Component") %>% transform_to_subgraph_ws() %>% render_graph(width = 250, height = 250)
component_graph <- final_graph$graph %>% select_nodes(type == "Component") %>% trav_out() %>% transform_to_subgraph_ws() render_graph(component_graph, width = 1000, height = 1000)
component_graph_legend <- create_legend(component_graph)
component_graph_legend[[1]]
final_graph$graph %>% select_nodes(type == "Component") %>% trav_in() %>% transform_to_subgraph_ws() %>% render_graph( width = 1500, height = 1500)
hemonc_graph <- final_graph$graph %>% select_nodes(vocabulary_id == "HemOnc") %>% trav_out_edge() %>% transform_to_subgraph_ws() render_graph(hemonc_graph, width = 1500, height = 1500)
create_legend(hemonc_graph) %>% pluck(1)
final_graph$graph %>% select_nodes(vocabulary_id == "HemOnc") %>% trav_out_edge() %>% select_nodes(vocabulary_id == "HemOnc") %>% transform_to_subgraph_ws() %>% render_graph(width = 1500, height = 1500)
final_graph$graph %>% select_nodes(vocabulary_id == "HemOnc") %>% trav_out_edge(rel == "Subsumes") %>% transform_to_subgraph_ws() %>% render_graph(width = 750, height = 750)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.