BnViewer - Interactive Visualization of Bayesian Networks - Interactive Panel and High Definition Export

BnViewer - Interactive Visualization of Bayesian Networks - Interactive Panel and High Definition Export

Introduction

BnViewer has been updated to version 0.1.5, and in this version it is possible to use a new interactive view allowing to export networks in high definition vector formats.

Many scientists got in touch asking about the possibility of improving the definition of the graphics when saving, now in this version it is possible to save them in high definition quality, in vector format.

Sample Code

The code below demonstrates the new "bnviewer" viewer, to access it just set the property "bayesianNetwork.enabled.interactive.mode = TRUE" and thus, it is possible to view the Bayesian Network in a new panel built on the shiny engine.

library(bnlearn)
library(bnviewer)

data("alarm")
bn.learn.hc = hc(alarm)

clusters.legend.title = "Legend"

viewer(bn.learn.hc,
       bayesianNetwork.width = "100%",
       bayesianNetwork.height = "100vh",
       bayesianNetwork.enabled.interactive.mode = TRUE,
       bayesianNetwork.layout = "layout_on_grid",
       edges.smooth = FALSE,
       node.colors = list(background = "white",
                          border = "black",
                          highlight = list(background = "#e91eba",
                                           border = "black")),

       node.font = list(color = "black", face="Arial"),

       clusters.legend.title = list(text = clusters.legend.title,
                                    style = "font-size:18px;
                                             font-family:Arial;
                                             color:black;
                                             text-align:center;"),

       clusters.legend.options = list(

               list(label = "Pressure",
                    shape = "icon",
                    icon = list(code = "f111", size = 50, color = "#e91e63")),
               list(label = "Volume",
                    shape = "icon",
                    icon = list(code = "f111", size = 50, color = "#03a9f4")),
               list(label = "Ventilation",
                    shape = "icon",
                    icon = list(code = "f111", size = 50, color = "#4caf50")),
               list(label = "Saturation",
                    shape = "icon",
                    icon = list(code = "f111", size = 50, color = "#ffc107"))
       ),

       clusters = list(
               list(label = "Pressure",
                    shape = "icon",
                    icon = list(code = "f111", color = "#e91e63"),
                    nodes = list("CVP","BP","HRBP","PAP","PRSS")),
               list(label = "Volume",
                    shape = "icon",
                    icon = list(code = "f111", color = "#03a9f4"),
                    nodes = list("MINV","MVS","LVV","STKV")),
               list(label = "Ventilation",
                    shape = "icon",
                    icon = list(code = "f111", color = "#4caf50"),
                    nodes = list("VALV","VLNG","VTUB","VMCH")),
               list(label = "Saturation",
                    shape = "icon",
                    icon = list(code = "f111", color = "#ffc107"),
                    nodes = list("HRSA","SAO2","PVS"))
       )
)
Não foi fornecido texto alternativo para esta imagem

It is possible to dynamically change the layout of the network to the control menu on the left. The figure below shows visualization with a circle layout.

Não foi fornecido texto alternativo para esta imagem

The figure below shows visualization with sugiyama layout.

Não foi fornecido texto alternativo para esta imagem

Export

The button "Generate Vector File" performs the vector transformation of the interactive Bayesian Network, and must be pressed whenever you want to obtain the vector image of the network.

The button "Preview Vector File" shows the vector object of the Bayesian network in the "Plots" tab of RStudio, allowing to save in different formats, such as "PDF, PNG, JPEG, TIFF, BMP, SVG, EPS".

Não foi fornecido texto alternativo para esta imagem
Não foi fornecido texto alternativo para esta imagem

To the next...

I hope this approach can contribute to those who are starting in the area of Data Science, whether Statistics, Mathematicians, Computer Scientists or students who have an interest in the subject.

Não foi fornecido texto alternativo para esta imagem



Great tool, I really like the interactive shiny app that generates the viewer, would it be possible to get the code used to get the shiny view to be able to publish that app on personal accounts? I would like to publish one of the networks as a shiny app. Thanks Javier

Like
Reply

To view or add a comment, sign in

More articles by Robson Fernandes

Others also viewed

Explore content categories