plot_multilayer_modules: Plot modules across layers for multilayer networks

View source: R/plot_multilayer_modules.R

plot_multilayer_modulesR Documentation

Plot modules across layers for multilayer networks

Description

Plot modules across layers for multilayer networks

Usage

plot_multilayer_modules(x, type = c("circle", "rectangle"), color_modules = T)

Arguments

x

An object of class infomap_multilayer.

type

Plot type, circles or rectangles. See details.

color_modules

Color modules? See details.

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.

Value

An object of class ggplot.

References

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.

See Also

ggplot2, infomap_monolayer

Examples

## 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)


Ecological-Complexity-Lab/infomap_ecology_package documentation built on June 6, 2024, 5:28 a.m.