Updated: 2023-11-22

This site accompanies the paper Identifying flow modules in ecological networks using Infomap. It contains installation instructions and very detailed Infomap commands and R code that we use in the examples that are presented in the paper (and more). We present what is most relevant for ecological network analysis using the R package infomapecology, which is a convenient interface to use Infomap within R.



Installation

Currently, infomapecology uses a standalone version of Infomap. We are working hard to integrate Infomap directly into R. Until that happens, install Infomap and infomapecology as specified here.



Infomap’s basics


Infomap arguments

Most of the Infomap arguments we use are common for all the examples and their detailed description can be found here. We explain in each example the most relevant specific arguments. Here is a typical running command:

./Infomap infomap.txt . --tree --seed 123 -N 20 -f undirected -2.

  • infomap.txt is the name of the input file
  • . indicates that the output will be written to the same folder as the input file.
  • --tree sets the output format.
  • --seed 123 provides a seed to the random number generator such that each run will result in the same output, which is useful for replication.
  • -N 20 tells infomap to run 20 trials and select the result of the best one.
  • -f undirected indicates flow on an undirected network.
  • -2 indicates a two-level solution, with no hierarchical modules (modules within modules).


Infomap output

The output, written into the tree file, is as follows (details here).

# v2.6.1
# ./Infomap two_triangles . --tree  --seed 123 -N 20 -f undirected -2
# started at 2023-11-20 11:17:55
# completed in 0.074 s
# partitioned into 2 levels with 2 top modules
# codelength 2.32073 bits
# relative codelength savings 9.22792%
# flow model undirected
# path flow name node_id
1:1 0.214286 "1" 1
1:2 0.142857 "2" 2
1:3 0.142857 "3" 3
2:1 0.214286 "4" 4
2:2 0.142857 "5" 5
2:3 0.142857 "6" 6

The first four lines are quite obvious. The 5th line provides the value of the map equations objective function (L) for the optimal partition. After the headings, rows describe module affiliation and flow. The path column is a tree-like format. The last integer after the colon indicates the ID of the leaf in the module, and not the ID of the node. See detailed explanations also in the R function (run_infomap_monolayer) in the package, which automatically reads this output and adds the affiliation of modules to the node table to create an output similar to this:

node_id node_name             module_level1 module_level2 node_type node_group
 1       1 Aglais.urticae                    1             1 c         A         
 2       2 Apis.mellifera                    2             1 c         A         
 3       3 Bombus.lapidarius                 2             2 c         A         
 4       4 Bombus.muscorum                   3             1 c         A         
 5       5 Bombus.pascuorum                  3             2 c         A         
 6       6 Bombus.terrestris                 2             3 c         A 

Here, module_level1 is the module ID and module_level2 is the leaf ID, extracted from the path column. node_type is either c for column or r for row, indicating of the node appears in the column or row of the matrix format.