Rnet: R-net Methods

Description Usage Arguments Value Examples

Description

This method takes an dataset (typically containing MICs values, AMR phenotypes, and presence abscence of genes) and returns an rnet object. The specific object class that is returned varies by what is provided to the L1 and subset arguments. The networks are Markov random fields (MRFs), a type of undirected graph. The network structure/topology is estimated using the graphical least absolute shrinkage and selection operator (glasso) as implemented in the R package of the same name developed by Friedman, Hastie, & Tibshirani (maintained by the latter)

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Rnet(x, L1, vertices = NULL, n_min = 1, cor_method = "s",
  cor_pairing = "pair", forced_zeros = NULL, plot_layout = NULL,
  subset = NULL)

## S4 method for signature 'ANY,ANY,ANY,ANY,ANY,ANY,ANY,ANY,expression'
Rnet(x, L1,
  vertices = NULL, n_min = 1, cor_method = "s",
  cor_pairing = "pair", forced_zeros = NULL, plot_layout = NULL,
  subset = NULL)

## S4 method for signature 'ANY,ANY,ANY,ANY,ANY,ANY,ANY,ANY,character'
Rnet(x, L1,
  vertices = NULL, n_min = 1, cor_method = "s",
  cor_pairing = "pair", forced_zeros = NULL, plot_layout = NULL,
  subset = NULL)

Arguments

x

The dataset used to estimate the structure of the Rnet.

L1

The L1 penalty used by the graphical LASSO to create a sparse precision matrix, also referred to as 'rho'. Must be non-negative.

vertices

A character vector corresponding to the names of the antibiotics to include in the Rnet. Defaults to an empty list, in which case one vertex will be included for each column in x. If declared, only variables declared in 'vertices' will be represented with vertices in the MRF.

n_min

The minimum number of observations required for an an estimated correlation to be valid. Defaults to 0, in which case any number of observations will be sufficient to estimate a valid correlation. If a vertex/variable has fewer valid observations than n_min, the vertex will be fully omitted from the network.

cor_method

The method used to estimate the correlation matrix. Must be 'pearson', 'spearman', or 'kendall'. Partial matches allowed. Defaults to 'spearman'.

cor_pairing

The method used to determine how NAs are handled when determining which pairs are used to estimate correlations. See 'cor' function documentation for additional information.

forced_zeros

The set of edges to be omitted from the Rnet. These partial correlations are forced to zero. Additional edges and vertices may be set to zero if n_min is employed.

plot_layout

A dataframe of two or three columns. See plot methods for more information.

subset

Either a character variable of length one or expression. If a character value is supplied, it must match a column name in x and an object of type 'rnetMultiStrata' with a network for each level of the declared variable. If an expression is supplied, an object of 'rnetStrata' will be returned with the network estimated from a subset of x defined by the expression. If no value is supplied, an object of 'rnetBasic' will be returned with the network estimated from all observations in x.

Value

An rnet object containing the graphical LASSO results. The specific type of object is determined by the 'subset' argument.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#Create a single R-net for all E. coli isolates in the provided dataset. 
#Vertices to be used defined by 'ABX_LIST' below.
#Edges require at least 20 observations to be valid.

ABX_LIST <- c('AMP', 'AMC', 'AXO', 'TIO', 'NAL', 'CIP', 'STR', 'GEN', 'COT', 'FIS')

EC_Rnet_ALL <- Rnet(x = NARMS_EC_DATA, 
						L1 = 0.3, 
						vertices = ABX_LIST, 
						n_min = 20
						)
class(EC_Rnet_ALL)[1]	#EC_Rnet_ALL is a 'rnetBasic' object
print(EC_Rnet_ALL)	#Basic Rnet information
summary(EC_Rnet_ALL) 	#More detailed information

#Create a single R-net for only E. coli isolates collected during 2008
EC_Rnet_2008 <- Rnet(x = NARMS_EC_DATA, 
						L1 = 0.3, 
						vertices = ABX_LIST, 
						n_min = 20,
					subset = expression(Year == 2008)
						)
class(EC_Rnet_2008)[1]	#EC_Rnet_ALL is an 'rnet.stratum' object

#Create a set of R-nets, one for each year of E.coli isolates.
EC_Rnet_byYear <- Rnet(x = NARMS_EC_DATA, 
						L1 = 0.3, 
						vertices = ABX_LIST, 
						n_min = 20,
					subset = 'Year'
						)
class(EC_Rnet_byYear)[1]	#EC_Rnet_ALL is an 'rnetMultiStrata' object

Rnets documentation built on July 23, 2019, 9:04 a.m.