Updates in networktools 1.2.1

Version 1.2.1 of R package ‘networktools’ just went live on CRAN, and it comes with some very useful updates!


The most exciting change is an update to plotting networks with MDSnet, PCAnet, or EIGENnet. These types of plotting approaches are an improvement on the force-directed defaults of igraph or qgraph in the sense that you can meaningfully interpret the positioning of nodes. Unfortunately, up until now they have also had a major limitation — nodes can overlap, obscuring important edges.

# Packages & data
# Generate network
mynetwork <- EBICglasso(cor(Rogers), nrow(Rogers))
myqgraph <- qgraph(mynetwork, labels=colnames(Rogers))
# Plot
PCAnet(myqgraph, cormat=cor(Rogers))


However, the version 1.2.1 fixes this by allowing you to add an optional repulsion parameter with the ‘repulse’ (T/F) and ‘repulsion’ (scalar with a default of 1) arguments. No more overlapping nodes!

PCAnet(qgraphObj, repulse=TRUE, repulsion=1)


Keep in mind that repulsion reduces the interpretability of the node positions. In most cases the positions will be only slightly changed, meaning they are still interpretable (approximately). If you use repulsion for a plot in a paper, you should make this clear to the reader (and you should preferably include the version without repulsion in the supplemental materials).

qgraph Arguments Passed Through

This update also allows you to add or modify MDSnet, PCAnet, or EIGENnet by passing any of the arguments that are in qgraph through the function (via …). Go crazy!

MDSnet(myqgraph, repulse=TRUE, repulsion=1, theme="Reddit", labels=1:26, negCol="black", negDashed=TRUE)


Normalized Bridge Centrality

When there are two communities of unequal sizes, bridge centrality statistics will “favor” the smaller community. To understand why, imagine a community of 3 nodes and another community of 100 nodes. The potential bridge strength of each node in the small community is 100, while the potential bridge strength of each node in the big community is only 3. This can make interpretation difficult.

If you find yourself in such a situation, you can now solve the issue by normalizing each type of bridge centrality by dividing by their maximum potential (note that the “maximum potential” depends on the type of bridge centrality).

RogersBridge <- bridge(mynetwork, communities=c(rep("MDD", 16), rep("OCD",10)))
RogersBridge_normalized <- bridge(mynetwork, communities=c(rep("MDD", 16), rep("OCD",10)), normalize=TRUE)
RogersBridge$`Bridge Strength`["obtime"] # 0.134
RogersBridge_normalized$`Bridge Strength`["obtime"] # 0.008

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s