Use computeModules
to call this function! This function takes a bipartite weighted graph and computes modules by applying Newman's modularity measure in a bipartite weighted version to it. To do so, it uses Stephen J Beckett's DIRTLPAwb+ (or LPAwb+) algorithm, which builds on Liu & Murata's approach. In contrast to the tedious MCMC-swapping QuanBiMo algorithm, this algorithm works by aggregating modules until no further improvement of modularity can be achieved.
DIRT_LPA_wb_plus(MATRIX, mini=4, reps=10)
LPA_wb_plus(MATRIX, initialmoduleguess=NA)
convert2moduleWeb(MATRIX, MODINFO)
MATRIX
is the matrix representing the weighted bipartite graph (as an example, see e.g. web small1976
in this package).
Minimal number of modules the algorithm should start with; defaults to 4. See explanation of initialmoduleguess to understand why not starting with one module per species interaction makes sense.
Number of trials to run for each setting of mini; defaults to 10 but my benefit from higher values.
Optional vector with labels for the modules of the longer web dimension. The initialmoduleguess argument in LPA_wb_plus
is used as an initial guess of the number of modules the network contains. The code then randomly assigns this many labels across the nodes of one of the types. The classical algorithm (i.e. LPA_wb_plus
) would use an initialmoduleguess of the maximum number of modules a network can contain (i.e. assigning a different label to each node initially). DIRT_LPA_wb_plus
exploits this. By initially assigning fewer than the maximum number of modules in the first instance nodes that may not have been placed together by the classical algorithm are placed together - creating different start points from which to attempt to maximise modularity.Defaults to NA
, i.e. as many modules as there are species in the smaller group.
Object returned by modulesLPA
.
LPA_wb_plus
computes the modules. DIRT_LPA_wb_plus
is a wrapper calling LPA_wb_plus
repeatedly to avoid getting stuck in some local minimum. Both return a simple list of row and column labels for the modules, as well as the modularity value. Using convert2moduleWeb
turns this into the richer moduleWeb-class object produced by computeModules
. For this object, the plotting function plotModuleWeb
and summary functions listModuleInformation
and printoutModuleInformation
are available.
Beckett, S.J. 2016 Improved community detection in weighted bipartite networks. Royal Society open science 3, 140536.
Liu X. & Murata T. 2010. An Efficient Algorithm for Optimizing Bipartite Modularity in Bipartite Networks. Journal of Advanced Computational Intelligence and Intelligent Informatics (JACIII) 14 408--415.
Newman M.E.J. 2004. Physical Review E 70 056131
computeModules
; see also class "moduleWeb", listModuleInformation
, printoutModuleInformation
# NOT RUN {
# }
# NOT RUN {
(res <- DIRT_LPA_wb_plus(small1976))
mod <- convert2moduleWeb(small1976, res)
plotModuleWeb(mod)
# }
Run the code above in your browser using DataLab