This Week’s Widget -
Longabaugh, W.J.R. Combing the hairball with BioFabric: a new approach for visualization of large networks. BMC Bioinformatics, 13:275, 2012.
d3.js), and R. His work, numerous examples, and discussion convinced me of the power of BioFabric, and I have been waiting for a week that I could commit enough time to attempt an implementation as an
htmlwidget. When I saw that the genius prolific node.js programmer Max Ogden @maxogden had taken a first step toward extending and generalizing @wjrl’s
d3.js code, I decided to see if I could combine the
As I plunged through the code, I decided to approach this by using the much fuller featured
bioFabric plotting function in
R with all the power of
igraph to do most of the data conversion and preparation in
I want to make sure I at least spend another sentence commending and thanking William Longabaugh (@wjrl) for not only his brilliant idea but his incredible commitment to it. I can only hope that this little
htmlwidget will help bring a little bit more attention and help spread the word.
RBioFabric is not yet on CRAN, so for now please install with
Let’s start simple with some
igraph data. It is beyond the scope of this post to explain BioFabric. I highly encourage enjoying all of William’s incredible resources on BioFabric to get a better sense of how to interpret these special diagrams.
Bridges of Koenigsberg
# devtools::install_github("timelyportfolio/RBioFabric") library(igraph) library(igraphdata) library(RBioFabric) data("Koenigsberg") # strange but we actually use the bioFabric plot function # to give us the data bioFabric_htmlwidget( bioFabric( Koenigsberg) )
By default, nodes are sorted by degree. However,
bioFabric allows custom sort order through a function with
orderFun or as a vector with
# devtools::install_github("timelyportfolio/RBioFabric") library(igraph) library(igraphdata) library(RBioFabric) library(dplyr) data(karate) # ?fastgreedy.community fc <- fastgreedy.community(karate) # let's sort by community and then degree bioFabric_htmlwidget( bioFabric( karate , userOrder = data.frame(membership = membership(fc), degree = degree(karate)) %>% mutate( id = rownames(.) ) %>% arrange( membership, desc( degree ) ) %>% select( id ) %>% as.vector ) )
No network visualization is complete unless it now includes Les Mis. It’s a little small in the blog, but this will give us a good opportunity to try out the pan and zoom.
# devtools::install_github("timelyportfolio/RBioFabric") library(RBioFabric) library(igraph) # d3 example from BioFabric # source: https://github.com/wjrl/D3BioFabric # example: http://rawgit.com/wjrl/D3BioFabric/master/src/JustBioFabric.html miserables <- jsonlite::fromJSON( "https://rawgit.com/wjrl/D3BioFabric/master/src/data/miserablesSimple.json" ) mis_igraph <- graph.data.frame( d = miserables$links ,vertices = data.frame( id = as.character( 0:(nrow(miserables$nodes)-1) ) ,name = miserables$nodes ,stringsAsFactors = F ) ) bioFabric_htmlwidget( bioFabric( mis_igraph ))
Thanks so much to William Longabaugh (@wjrl) for a brilliant idea and his commitment to it.
As always, thanks to
- Ramnath Vaidyanathan and RStudio for
- all the contributors to