All Projects → iankloo → sigmaNet

iankloo / sigmaNet

Licence: Unknown, Unknown licenses found Licenses found Unknown LICENSE Unknown LICENSE.note
Render igraphs from R using Sigma.js

Programming Languages

r
7636 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to sigmaNet

Flowchart Fun
Easily generate flowcharts and diagrams from text ⿻
Stars: ✭ 2,311 (+5981.58%)
Mutual labels:  graphs
Mpv Stats
Display file statistics in mpv.
Stars: ✭ 192 (+405.26%)
Mutual labels:  graphs
Visualize ruby
Transform code into a flowchart and experimentally trace the execution path through it
Stars: ✭ 237 (+523.68%)
Mutual labels:  graphs
Coding Ninjas Competitive
This will have all the solutions to the competitive programming course's problems by Coding ninjas. Star the repo if you like it.
Stars: ✭ 168 (+342.11%)
Mutual labels:  graphs
Graph datasets
A Repository of Benchmark Graph Datasets for Graph Classification (31 Graph Datasets In Total).
Stars: ✭ 185 (+386.84%)
Mutual labels:  graphs
Litegraph.js
A graph node engine and editor written in Javascript similar to PD or UDK Blueprints, comes with its own editor in HTML5 Canvas2D. The engine can run client side or server side using Node. It allows to export graphs as JSONs to be included in applications independently.
Stars: ✭ 2,735 (+7097.37%)
Mutual labels:  graphs
Data science blogs
A repository to keep track of all the code that I end up writing for my blog posts.
Stars: ✭ 139 (+265.79%)
Mutual labels:  graphs
echarty
Minimal R/Shiny Interface to ECharts.js
Stars: ✭ 49 (+28.95%)
Mutual labels:  graphs
Javafxsmartgraph
Generic (Java FX) Graph Visualization Library
Stars: ✭ 186 (+389.47%)
Mutual labels:  graphs
Deepgraph
Analyze Data with Pandas-based Networks. Documentation:
Stars: ✭ 232 (+510.53%)
Mutual labels:  graphs
Matplotplusplus
Matplot++: A C++ Graphics Library for Data Visualization 📊🗾
Stars: ✭ 2,433 (+6302.63%)
Mutual labels:  graphs
Grano
A toolkit for mapping networks of political and economic influence through diverse types of entities and their relations. Accessible at http://granoproject.org
Stars: ✭ 181 (+376.32%)
Mutual labels:  graphs
Squid
A Ruby library to plot charts in PDF files
Stars: ✭ 205 (+439.47%)
Mutual labels:  graphs
Stellargraph
StellarGraph - Machine Learning on Graphs
Stars: ✭ 2,235 (+5781.58%)
Mutual labels:  graphs
Graphview
Android Graph Library for creating zoomable and scrollable line and bar graphs.
Stars: ✭ 2,643 (+6855.26%)
Mutual labels:  graphs
Hubot Grafana
📈🤖 Query Grafana dashboards
Stars: ✭ 141 (+271.05%)
Mutual labels:  graphs
Swiftcharts
Easy to use and highly customizable charts library for iOS
Stars: ✭ 2,336 (+6047.37%)
Mutual labels:  graphs
CBioInfCpp-0-
The lib CBioInfCpp.h contains 3 groups of functions for C++: "Input-Output", "Working with strings", "Working with graphs". Data structures "Adjacency vector" and "Adjacency map" are implemented in the last one (i.e. in "Working with graphs"). See About_CBioInfCpp for details.
Stars: ✭ 12 (-68.42%)
Mutual labels:  graphs
Pygraphblas
GraphBLAS for Python
Stars: ✭ 252 (+563.16%)
Mutual labels:  graphs
React Trend
📈 Simple, elegant spark lines
Stars: ✭ 2,453 (+6355.26%)
Mutual labels:  graphs

sigmaNet

Render igraph networks using Sigma.js - in R - now on CRAN!

Check out the full docs

Why?

This package is an R interface to the Sigma.js javascript library. Sigma.js was built for graph visualization and has significant advantages over other javascript libraries when creating large graph visualizations.

Benefits of this package:

  1. Use familiar, well documented igraph objects to make visualizations
  2. Easy "ggplot-like" syntax
  3. Render things quickly - allowing for faster iterative graph building
  4. Render large networks
  5. Maintain interactivity (click, hover, zoom) with sharable html output
  6. Integrate easily with Shiny applications

How?

First, install this package:

install.packages('sigmaNet')

Or, use the development version:

devtools::install_github('iankloo/sigmaNet')

Then, create an igraph network. Here we'll use the included les Miserables dataset that maps the co-appearances of characters in the novel.

Note, passing an optional layout to the sigmaFromIgraph() function will dramatically improve speed. Layouts are usually the most computationally intensive task when creating network visualizations. This package allows you to separate this computation from the aesthetic changes you will likely want to make to your visualization.

library(sigmaNet)
library(igraph)

data(lesMis)

layout <- layout_with_fr(lesMis)
sig <- sigmaFromIgraph(lesMis, layout = layout)
sig

If you render this at home, you'll see that you can zoom, pan, and get information on-hover for the nodes. This is just a static image to show you the basics.

Options

You have a few options available to change the aesthetics of graphs. Options are applied in a similar way to ggplot, but use the pipe operator instead of the "+". Here is an example showing most of the options you can use:

data(lesMis)

clust <- cluster_edge_betweenness(lesMis)$membership
V(lesMis)$group <- clust

layout <- layout_with_fr(lesMis)

sig <- sigmaFromIgraph(lesMis, layout = layout) %>%
  addNodeLabels(labelAttr = 'label') %>%
  addEdgeSize(sizeAttr = 'value', minSize = .1, maxSize = 2) %>%
  addNodeSize(sizeMetric = 'degree', minSize = 2, maxSize = 8) %>%
  addNodeColors(colorAttr = 'group', colorPal = 'Set1')
sig

Note: there is no opacity/transparency/alpha attribute! That is because webgl doesn't support transparency. To mimic transparency, set your edge size to be small - this works really well. I know this is a big trade off, but it is the only way to render large networks without sacrificing performance.

Larger Networks

This package was built to address the specific challenges of creating compelling visualizations with large networks. Here is an example of a larger network than we've been using (created using a graph-generating function in igraph):

g <- sample_pa(10000)

layout <- layout_with_fr(g)
sig <- sigmaFromIgraph(g, layout = layout)
sig %>%
  addNodeSize(oneSize = .5) %>%
  addEdgeSize(oneSize = .2)

While we can debate the usefulness of a "hairball" graph like this, you can see that sigmaNet has no problem rendering a graph with 10,000 nodes nearly instantly. If you render this at home, you will also see that the graph maintains its interactivity with little to no lag.

Shiny Support

You can use sigmaNet in Shiny using renderSigmaNet() in your server and sigmaNetOutput() in your ui. See the Shiny docs for more general info about Shiny - these functions drop-in just like the basic plotting examples.

Use the addListner() function to specify a Shiny listener. Current options are "clickNode" and "hoverNode". These are pretty self-explanitory - the first returns information about a node on-click and the second does the same on-hover.

Here's a minimal Shiny app that sends the result of an on-click event to a text box:

library(sigmaNet)
library(shiny)
library(magrittr)

data(lesMis)

ui <- fluidPage(
  sigmaNetOutput('network', height = '600px'),
  textOutput('text')
)

server <- function(input, output) {
  output$text <- renderText({
    req(input$node_data)
    paste0('You clicked on: ', input$node_data$label)
  })
  
  output$network <- renderSigmaNet({
    sigmaNet::sigmaFromIgraph(lesMis) %>%
      addNodeLabels(labelAttr = 'label') %>%
      addListener('clickNode')
  })
}

shinyApp(ui, server)

A Note on Browsers

This package uses a renderer that detects whether or not your browser supports webgl. If it does, webgl will be used to render the visualizations. If not, canvas will be used. Webgl is MUCH faster than canvas (especially with large graphs), so if you notice some performance issues, try using a modern browser that supports webgl. All but the most out-of-date browsers support webgl (except maybe Opera?), so this shouldn't be an issue for many.

Features in development

  • GUI to modify aesthetics (Shiny gadget)

Write an "issue" on the github page for this package if you want to see additional features.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].