View source: R/plot_multilayer_modules.R
plot_multilayer_modules | R Documentation |
Plot modules across layers for multilayer networks
plot_multilayer_modules(x, type = c("circle", "rectangle"), color_modules = T)
x |
An object of class |
type |
Plot type, circles or rectangles. See details. |
color_modules |
Color modules? See details. |
Type circle
plots a circle per module-layer combination, with the radius proportional
to the number of nodes in the module in the layer. Type rectangle
plots a bar across all the layers a module spans. Only (or mostly) relevant for temporal networks.
For a circle plot, color_modules
will give a different color for
each module ID. For a rectangle plot, color_modules
will color each
module by the total number of nodes it contains (not per layer).
Because the output is a ggplot object it can be further manipulated with standard ggplot2.
An object of class ggplot
.
Code was first developed for: Pilosof, S., Q. He, K. E. Tiedje, S. Ruybal-Pesántez, K. P. Day, and M. Pascual. 2019. Competition for hosts modulates vast antigenic diversity to generate persistent strain structure in Plasmodium falciparum. PLoS biology 17:e3000336.
ggplot2, infomap_monolayer
## Not run:
emln <- create_multilayer_object(extended = siberia1982_7_links,
nodes = siberia1982_7_nodes, intra_output_extended = TRUE, inter_output_extended = TRUE)
emln_modules <- run_infomap_multilayer(M=emln, relax = FALSE,
flow_model = 'directed', silent = TRUE, trials = 100, seed = 497294,
temporal_network = TRUE)
plot_multilayer_modules(emln_modules, type = 'rectangle', color_modules = TRUE)+
scale_fill_viridis_c()
plot_multilayer_modules(emln_modules, type = 'rectangle', color_modules = FALSE)+
geom_rect(fill='orange')
# Circle-type plot
plot_multilayer_modules(emln_modules, type = 'circle', color_modules = TRUE)
plot_multilayer_modules(emln_modules, type = 'circle', color_modules = FALSE)+
geom_point(aes(size=size), color='navy')
# More examples to modify the plots
plot_multilayer_modules(emln_modules, type = 'rectangle', color_modules = TRUE)+
scale_fill_viridis_c()+
scale_x_continuous(breaks=seq(0,6,1))+
scale_y_continuous(breaks=seq(0,40,5))+
theme_bw()+
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title = element_text(size=20),
axis.text = element_text(size = 20),
legend.text = element_text(size=15),
legend.title = element_text(size=20))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.