Description Usage Arguments Value See Also Examples

Plot graph of direct species associations.

1 2 3 4 5 6 7 8 9 10 11 12 13 |

`x` |
is a cgr object, e.g. from output of |

`P` |
locations of graph nodes, if NULL (default) these are generated with a Fruchterman Reingold algorithm. |

`vary.edge.lwd` |
is logical, TRUE will vary line width according to the strength of partial correlation, default (FALSE) uses fixed line width. |

`edge.col` |
takes two colours as arguments - the first is the colour used for positive partial correlations, the second is the colour of negative partial correlations. |

`label` |
is a vector of labels to apply to each variable, defaulting to the column names supplied in the data. |

`vertex.col` |
the colour of graph nodes. |

`label.cex` |
is the size of labels. |

`edge.lwd` |
is line width, defaulting to 10*partial correlation when varying edge width, and 4 otherwise. |

`edge.lty` |
is a vector of two integers specifying the line types for positive and negative partial correlations, respectively. Both default to solid lines. |

`...` |
other parameters to be passed through to plotting gplot, in particular |

a plot of species associations after accounting for the effect of all other species, positive/negative are blue/pink.
The matrix of node positions (`P`

) is returned silently.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ```
X <- as.data.frame(spider$x)
abund <- spider$abund[,1:5]
spider_mod <- stackedsdm(abund,~1, data = X, ncores=2)
spid_graph=cgr(spider_mod)
plot(spid_graph, edge.col=c("forestgreen","darkorchid4"),
vertex.col = "black",vary.edge.lwd=TRUE)
library(tidyr)
library(tidygraph)
library(ggraph)
igraph_out<-spid_graph$best_graph$igraph_out
igraph_out %>% ggraph('fr') + # see ?layout_tbl_graph_igraph
geom_edge_fan0(aes( colour = partcor, width=partcor)) +
scale_edge_width(range = c(0.5, 3))+
scale_edge_color_gradient2(low="#b2182b",mid="white",high="#2166ac")+
geom_node_text(aes(label=name), repel = TRUE)+
geom_node_point(aes(size=1.3))+
theme_void() +
theme(legend.position = 'none')
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.