<p>Both conda and PyPI have leiden clustering in Python which operates via <code>iGraph</code></p>
<pre><code>conda install -c conda-forge leidenalg

pip install leiden-clustering
</code></pre>
<p>Used via</p>
<pre><code>import leidenalg as la
import igraph as ig
</code></pre>
<p>Example output</p>
<p><a href="https://i.sstatic.net/F8xMh.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/F8xMh.png" alt="enter image description here" /></a></p>
<p>The docs are <a href="https://leidenalg.readthedocs.io/en/stable/intro.html" rel="nofollow noreferrer">here</a>. You will not need much Python to use it.</p>
<p>There is an entire Leiden package in R-cran <a href="https://cran.r-project.org/web/packages/leiden/index.html" rel="nofollow noreferrer">here</a></p>
<p>Python implements Rs Leiden package here,</p>
<pre><code>conda install -c conda-forge r-leiden
</code></pre>

CC BY-SA 4.0
2022-09-30T15:05:04.780Z
2022-09-30T15:51:59.780Z
2022-09-30T15:51:59.780Z
M__
<p>A collegue of mine recently suggested to try the louvain algorithm for clustering multiplex cytometry data. However, implementations of louvain are kind of rare in R. To my knowledge the only stand-alone implementation is included in the <code>igraph</code> package.
So far i tried to use the adjacency matrix that the <code>umap</code> function returns (<code>uwot</code> package) to create a graph using <code>igraphs</code> <code>graph_from_adjacency_matrix</code> function. I can run the louvain algorithm on the graph, but the result is always a few thousand clusters with a hand-full if cells. changing the resolution parameter does not change anything.</p>
<p>If i remember correctly, <code>Seurats</code> <code>findClusters</code> function uses <code>louvain</code>, however i don't want to use PCA reduction before clustering, which is requiered in <code>Seurat</code> to find clusters.</p>
<p>Does anybody know of a different implementation of louvain or leiden algorithm that or an easier way to use <code>igraphs</code>functions? I obviously don't have to use the matrix umap returned, but what would be a better approach to make my data &quot;louvain-able&quot;?</p>

<r><seurat><clustering><umap>
How to get started with louvain/leiden algorithm with UMAP in R
# How to get started with louvain/leiden algorithm with UMAP in R

(Asked by: username_0 on 2022-09-30)

A collegue of mine recently suggested to try the louvain algorithm for clustering multiplex cytometry data. However, implementations of louvain are kind of rare in R. To my knowledge the only stand-alone implementation is included in the `igraph` package.
So far i tried to use the adjacency matrix that the `umap` function returns (`uwot` package) to create a graph using `igraphs` `graph_from_adjacency_matrix` function. I can run the louvain algorithm on the graph, but the result is always a few thousand clusters with a hand-full if cells. changing the resolution parameter does not change anything.

If i remember correctly, `Seurats` `findClusters` function uses `louvain`, however i don't want to use PCA reduction before clustering, which is requiered in `Seurat` to find clusters.

Does anybody know of a different implementation of louvain or leiden algorithm that or an easier way to use `igraphs`functions? I obviously don't have to use the matrix umap returned, but what would be a better approach to make my data "louvain-able"?

**Tags:** r, seurat, clustering, umap

---

## 1 answers

### Answer by username_1 on 2022-09-30. Score: 1

Both conda and PyPI have leiden clustering in Python which operates via iGraph
conda install -c conda-forge leidenalg

pip install leiden-clustering

Used via
import leidenalg as la
import igraph as ig

Example output

The docs are here. You will not need much Python to use it.
There is an entire Leiden package in R-cran here
Python implements Rs Leiden package here,
conda install -c conda-forge r-leiden


---

