Extract and plot the network (partial correlation, support or inverse covariance) from a PLNnetworkfit object

# S3 method for PLNnetworkfit
plot(
  x,
  type = c("partial_cor", "support"),
  output = c("igraph", "corrplot"),
  edge.color = c("#F8766D", "#00BFC4"),
  remove.isolated = FALSE,
  node.labels = NULL,
  layout = layout_in_circle,
  plot = TRUE,
  ...
)

Arguments

x

an R6 object with class PLNnetworkfit

type

character. Value of the weight of the edges in the network, either "partial_cor" (partial correlation) or "support" (binary). Default is "partial_cor".

output

the type of output used: either 'igraph' or 'corrplot'. Default is 'igraph'.

edge.color

Length 2 color vector. Color for positive/negative edges. Default is c("#F8766D", "#00BFC4"). Only relevant for igraph output.

remove.isolated

if TRUE, isolated node are remove before plotting. Only relevant for igraph output.

node.labels

vector of character. The labels of the nodes. The default will use the column names ot the response matrix.

layout

an optional igraph layout. Only relevant for igraph output.

plot

logical. Should the final network be displayed or only sent back to the user. Default is TRUE.

...

Not used (S3 compatibility).

Value

Send back an invisible object (igraph or Matrix, depending on the output chosen) and optionally displays a graph (via igraph or corrplot for large ones)

Examples

data(trichoptera)
trichoptera <- prepare_data(trichoptera$Abundance, trichoptera$Covariate)
fits <- PLNnetwork(Abundance ~ 1, data = trichoptera)
#> 
#>  Initialization...
#>  Adjusting 30 PLN with sparse inverse covariance estimation
#> 	Joint optimization alternating gradient descent and graphical-lasso
#> 	sparsifying penalty = 7.54443 
	sparsifying penalty = 6.96857 
	sparsifying penalty = 6.436665 
	sparsifying penalty = 5.94536 
	sparsifying penalty = 5.491556 
	sparsifying penalty = 5.07239 
	sparsifying penalty = 4.685219 
	sparsifying penalty = 4.3276 
	sparsifying penalty = 3.997278 
	sparsifying penalty = 3.692169 
	sparsifying penalty = 3.410349 
	sparsifying penalty = 3.15004 
	sparsifying penalty = 2.9096 
	sparsifying penalty = 2.687513 
	sparsifying penalty = 2.482377 
	sparsifying penalty = 2.2929 
	sparsifying penalty = 2.117885 
	sparsifying penalty = 1.956228 
	sparsifying penalty = 1.806911 
	sparsifying penalty = 1.668991 
	sparsifying penalty = 1.541598 
	sparsifying penalty = 1.42393 
	sparsifying penalty = 1.315242 
	sparsifying penalty = 1.214851 
	sparsifying penalty = 1.122122 
	sparsifying penalty = 1.036472 
	sparsifying penalty = 0.9573588 
	sparsifying penalty = 0.8842844 
	sparsifying penalty = 0.8167877 
	sparsifying penalty = 0.754443 

#>  Post-treatments
#>  DONE!
myNet <- getBestModel(fits)
if (FALSE) {
plot(myNet)
}