Learn R Programming

monocle3 (version 0.1.3)

louvain_R: Cluster cells based on Louvain community detection algorithm.

Description

This function is a wrapper of the louvain function from the python package (louvain-igraph, https://github.com/vtraag/louvain-igraph) The following description is from the original package "This package implements the Louvain algorithm in C++ and exposes it to python. It relies on (python-)igraph for it to function. Besides the relative flexibility of the implementation, it also scales well, and can be run on graphs of millions of nodes (as long as they can fit in memory). The core function is find_partition which finds the optimal partition using the Louvain algorithm for a number of different methods. The methods currently implemented are (1) modularity, (2) Reichardt and Bornholdt's model using the configuration null model and the Erd<U+00F6>s-R<U+00E9>nyi null model, (3) the constant Potts model (CPM), (4) Significance, and finally (5) Surprise. In addition, it supports multiplex partition optimization allowing community detection on for example negative links or multiple time slices. It also provides some support for community detection on bipartite graphs. See the documentation for more information." Please see the github above for the citations. Right now we only support CPMVertexPartition, RBConfigurationVertexPartition, RBERVertexPartition, ModularityVertexPartition SignificanceVertexPartition and SurpriseVertexPartition partition methods.

Usage

louvain_R(X, python_home = system("which python", intern = TRUE),
  partition_method = "CPMVertexPartition", initial_membership = NULL,
  weights = NULL, res = 0.6, node_sizes = NULL, random_seed = 0L,
  verbose = FALSE, return_all = FALSE)

Arguments

X

the dataset upon which to perform louvain-igraph

python_home

The python home directory where louvain-igraph is installed

partition_method

character - either the default "CPMVertexPartition" or "RBConfigurationVertexPartition" / "RBERVertexPartition".

initial_membership

(list of int) <U+2013> Initial membership for the partition. If None then defaults to a singleton partition.

weights

(list of double, or edge attribute) <U+2013> Weights of edges. Can be either an iterable or an edge attribute.

res

(double) <U+2013> Resolution parameter.

node_sizes

(list of int, or vertex attribute) <U+2013> Sizes of nodes are necessary to know the size of communities in aggregate graphs. Usually this is set to 1 for all nodes, but in specific cases this could be changed.

random_seed

the seed used by the random number generator in louvain-igraph package

verbose

boolean (optional, default False)

return_all

Whether to return all slots after Louvain

Value

The cluster id if return_all set to be FALSE, otherwise all slots from the Louvain function