knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(chariot2)
library(tidyverse)

This package creates a properly formatted output from the OMOP Vocabularies for consumption by the DiagrammeR package.

# Fetch from Postgres  
nodes_and_edges <-
  fetch_concept_classes()

# 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)
final_graph$graph
library(DiagrammeR)
final_graph$graph %>%
  select_nodes(vocabulary_id == "ATC") %>%
  trav_out_edge() %>%
  select_nodes(vocabulary_id %in% c("ATC")) %>%
  transform_to_subgraph_ws() %>%
  render_graph()
final_graph$graph %>%
  select_nodes(vocabulary_id == "ATC") %>%
  trav_out_until(max_steps = 1) %>%
  transform_to_subgraph_ws() %>%
  render_graph()
final_graph$graph %>%
  select_nodes(vocabulary_id == "ATC") %>%
  trav_out_edge() %>%
  select_nodes(vocabulary_id %in% c("ATC")) %>%
  trav_out_edge() %>%
  #select_nodes(vocabulary_id %in% c("RxNorm")) %>%
  transform_to_subgraph_ws() %>%
  render_graph()


mpatel-cai/chariot2 documentation built on Jan. 8, 2022, 5:18 a.m.