Cluster cells using a NN-network and the Leiden community detection algorithm This version is implemented via the python package leidenalg.
This implementation is a wrapper for the Leiden algorithm implemented in python, which can detect communities in graphs of millions of nodes (cells), as long as they can fit in memory. See the leidenalg github page or the readthedocs page for more information.
resolution | numeric (default = 1). Clustering resolution. |
n_iterations | numeric (default = 1000). Number of iterations to run the Leiden algorithm. If the number of iterations is negative, the Leiden algorithm is run until an iteration in which there was no improvement. |
weight_col | character. (default = weight). Weight column in
network information to use for edge weights. |
partition_type | character (default = "RBConfigurationVertexPartition").
The type of partition to use for optimization. (one of
"RBConfigurationVertexPartition" or "ModularityVertexPartition") |
initial_membership | (default = NULL) initial membership of cells
for the partition |
RBConfigurationVertexPartition: Implements Reichardt and Bornholdt’s Potts model with a configuration null model. This quality function is well-defined only for positive edge weights. This quality function uses a linear resolution parameter.
ModularityVertexPartition: Implements modularity. This quality function is well-defined only for positive edge weights. It does not use the resolution parameter
Set weight_col = NULL to give equal weight (=1) to each edge.
g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#> active environment : '/usr/bin/python3'
#> python version : 3.12
clusterData(g, clusterParam("leiden_python", resolution = 0.5))
#> Error in py_run_file_impl(file, local, convert): ModuleNotFoundError: No module named 'igraph'
#> Run `reticulate::py_last_error()` for details.