Resistance Relationship Networks using Graphical LASSO

Novel methods are needed to analyze the large amounts of antimicrobial resistance (AMR) data generated by AMR surveillance programs. This package is used to estimate resistance relationship networks, or 'Rnets', from empirical antimicrobial susceptibility data. These networks can be used to study relationships between antimicrobial resistances (typically measured using MICs) and genes in populations. The 'GitHub' for this package is available at <>. Bug reports and features requests should be directed to the same 'GitHub' site. The methods used in 'Rnets' are available in the following publications: An overview of the method in WJ Love, et al., "Markov Networks of Collateral Resistance: National Antimicrobial Resistance Monitoring System Surveillance Results from Escherichia coli Isolates, 2004-2012" (2016) ; The graphical LASSO for sparsity in J Friedman, T Hastie, R Tibshirani "Sparse inverse covariance estimation with the graphical lasso" (2007) ; L1 penalty selection in H Liu, K Roeder, L Wasserman "Stability Approach to Regularization Selection (StARS) for High Dimensional Graphical Models" (2010) ; Modularity for graphs with negative edge weights in S Gomez, P Jensen, A Arenas. "Analysis of community structure in networks of correlated data" (2009) .

The Rnets package for mapping relationships in antimicrobial resistances (AMR) in bacterial populations. The sets of estimated relationships are treated as networks; The name of the package, core function, and analysis result, 'Rnet', is derived from the phrase "Resistance relationship network." AMR surveillance programs have produced huge amounts of data, but new methods are needed to interpret and study this volume of data. The Rnets package applies the graphical least absolute selection and shrinkage operator, also referred to as the 'graphical LASSO', to determine which resistances are correlated, and which are conditionally independent. Our goal in developing this package was to make the Rnets method easily accessible to all research. Therefore the core function in the package, Rnet accepts input in a commonly used format, with isolates data stored in rows and respective minimum inhibitory concentration (MIC) data stored in columns, and directly and quickly produces useful analyses with the mudane data handling taken care of behind the scenes. A suite of additional functions is included to interact with and visualize the analysis results.

A more in-depth description of the methods employed by the package are available in the included vignette.


The process of estimating a network from raw MIC data can be broadly divided into 3 primary phases:

  1. Selection of $\lambda$
  2. Induction of sparsity using the graphical LASSO
  3. Visualization and interpretation

Briefly, $\lambda$ is a penalty applied to the correlation matrix; Larger $\lambda$ values tend to reduce more parrtial correlations to 0, resulting in sparser networks with fewer edges. To produce informative networks, $\lambda$ should be between smallest and largest absolute values of the correlation matrix's elements. Several methods have been described to select L~1~. The L1_selection function employs the Stability Approach to Regularization Selection (StARS) proposed by [CITATION NEEDED].

The following code will use the E. coli isolates' from 2008 in NARMS_EC_DATA MIC results for 15 antimicrobials. This function evaluates 100 subsets of size 1200 with $\lambda$ equal to 0.05, 0.10, ..., 0.45, 0.50 for all E. coli s (takes ~ 5 minutes on an i7-6700 4.0 GHz with 16 Gb RAM).

EC.L1.results <- L1Selection(
                    Data = NARMS_EC_DATA, 
                    L1_set = seq(0.05, 0.50, 0.05), 
                    n_b = 1200, 
                    V_set = ABX_LIST, 
                    Stratify = NARMS_EC_DATA$Year == 2008
print([email protected]_D)

Since the StARS method is based on random subsamples without replacement, running this code will produce slightly different results. You can get consistent results between runs by setting your random.seed before running this code. Our results were as follows:

  0.05    0.1   0.15    0.2   0.25    0.3   0.35    0.4   0.45    0.5 
0.1812 0.0736 0.0448 0.0508 0.0373 0.0172 0.0123 0.0031 0.0136 0.0098 

The suggested penalty will be the smallest $\lambda$ for which StARS_D < 0.05. Here, it is 0.25, which We have typically found to be reasonable penalty for estimating R-nets. With the $\lambda$ value selected, we can estimate the network for the 15 MICs from the full set of E. coli from 2008:

EC08_Rnet <- Rnet(
                Data = NARMS_EC_DATA, 
                L1 = 0.25, 
                V_set = ABX_LIST,
                Stratify = NARMS_EC_DATA$Year == 2008


The estimated network can be plotted with the plot method.



The latest stable version of Rnets is available on the author's GitHub and can be installed using the following code:


The latest development branch of the project, which is not guarunteed to be stable, can also be accessed from the author's GitHub using:

install-github('EpidemiologyDVM/Rnets', branch = 'dev')

The Rnets package has the following dependancies:

  • The graphical LASSO method is performed using the glasso function in the eponymous package maintained by Rob Tibshiriani
  • Networks are handled and plotted using a variety of functions in the igraph package maintained by Gábor Csárdi.
  • Data aggregation over multiple strata is handled using the efficient rbindlist function in the data.table package maintained by Matt Dowle.

All three dependencies are available on CRAN as of 1.Dec.2017.

Bug Reporting

If you find parts of the package are not working as intended, please submit the issue on our project's GitHub site at: or contact the author at [email protected]


Rnets v 0.9.9

Major Changes

  • 0.9.5

    • Added
    • Added
    • check() produces 2 'notes'
  • 0.9.6

    • Changed 'Modularity_Signed' to 'signedModularity'
    • Revised signedModularity
    • Changed S4 naming convention from 'rnet.basic' to 'rnetBasic'
    • check() produces 0 errors/warnings/notes (other than UTF-8 warning)
  • 0.9.7

    • Removed
    • Revised signedModularity to matrix-based algorithm instead of list-based
  • 0.9.8

    • Initial 'open beta' relase
    • 'L1Selection' no longer has .random.seed option
  • 0.9.9

    • Resolved bug with 'plot' method. Was calling hidden function as external, now called as internal.
    • Added graph.layout argument to plot method to allow manual definition of graph layout.
    • Added summary method for Rnet objects with multiple strata

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


1.2.1 by William Love, 2 years ago

Browse source code at

Authors: William Love [aut, cre]

Documentation:   PDF Manual  

GPL-3 license

Imports methods, ICSNP, rlang

Depends on glasso, igraph, data.table, stringr

Suggests knitr, rmarkdown

See at CRAN