new ndtv release: 0.7

..and continuing in the thread of long-overdue R package updates, we’ve got a new ndtv version out as well.

Peek into the time prism

The package release adds some “whiteboard candy”: 2.5D orthogonal projection of networks in time along a z axis. For lack of a better name, I’ve dubbed it a timePrism (let me know if you find a pre- existing better name). Think of viewing all of the slices from a filmstrip from an angle. Probably hard to follow for large networks (or lots of time slices) but nice for illustrating concepts in temporal networks when you want to convey time and structure and can accept some loss of detail. Especially with the ability to include splines connecting specific vertices for highlighting trajectories.


library(ndtv)
data(toy_epi_sim)  
timePrism(toy_epi_sim,
           orientation=c('z','y','x'), # swap axes
           angle=40,
           spline.v=c(7, 29, 36, 70, 82, 96),  # hilite the infected 
           spline.col='red',
           spline.lwd=2,
           box=FALSE,
           planes=TRUE,  # draw a semi-transparent 'plane' under each net
           vertex.col='ndtvcol'  # use pre-created infection color scheme)

timePrism

If you look really closely, you can see that it isn’t really 3D (some of objects and transparency are layered in the wrong order) but my goal was to make it use existing plot.network and compute.animation commands as much as possible so that arguments can be reused across the plot techniques.

Get widgety with it

Perhaps the most useful update (other than the bug fixes) is that render.d3movie now has an output.mode='htmlWidget' option to export the HTML5 animation as an htmlwidget for viewing in RStudio (with play controls and interactivity!) or as a Shiny app. So it should be even easier to include interactive network diagrams in reports and web pages. In fact, Sam Jenness points out that “…this now interfaces with Rstudio’s Rpubs website, so it’s a one-button quick publishing approach for these movies: http://rpubs.com/smjenness/116671

A new view for trees

A feature I’m excited about developing further is the transmissionTimeline plot to illustrate a spreading tree from a source vertex in a network (also based on a conversation with Sam). This works to plot the forward-reachable tPath found by the tsna package (or other tree-like edgelists), and will soon be an optional display for exploring infection trees in EpiModel. The idea is to show the who-infected-whom tree of relationships by positioning vertices according their infection time (on the horizontal axis) and their transmission generation (on the vertical). This puts the source vertex at the origin (lower left) and all of the infection chains as trails arcing out to the right.


library(ndtv)
library(tsna)
data("moodyContactSim")
# extract the forward path from vertex 10
v10path< -tPath(moodyContactSim,v=10)
transmissionTimeline(v10path)

transmissionTimeline

Obviously I’ve chosen an example that looks nice, but the technique seems to be surprisingly useful in illustrating bursty-ness and reproduction rates (more on that later I hope).

FX

A final feature of note — functional but still preliminary — is the inclusion of some pre-built “special effects” functions for animation rendering. i.e. color edges by their age. See the help page ?effects for details.

I’m incrementally updating the html version of the ndtv tutorial, which I was unable to present in July. (May have to abandon the pdf version, as pandoc goes berserk when I try to render)

Leave a Reply

Your email address will not be published. Required fields are marked *