Answers.Body: <p>A general rule of thumb is that in order to improve the variance $n$ times you need $n^2$ neighbours. This is only applicable if you consider the $n^2$ nearest neighbours of a cell to be biologically identical (i.e. "similar enough"); if your data includes 10 types of cells with 10 cells each, then using the 20 nearest neighbours for smoothing will obscure the data.</p>
  
  <p>As far as I know, there is no single best answer to this question. I would suggest trying different numbers and sticking to what agrees more with the biology of the dataset.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-10T15:04:40.760Z
Answers.Text: Can you put some references on the rule of thumb you wrote? However, I ended up selecting progressive resolutions. Of note, different parts of a dataset may need different resolutions. Thanks.
Answers.UserDisplayName: gc5
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-08-10T11:57:39.537Z
Answers.LastActivityDate: 2018-08-10T11:57:39.537Z
Answers.UserDisplayName: galicae
Answers.Body: <p>I read a paper where the authors used different combinations of parameters to iteratively perform LSI until some criteria. Maybe a similar strategy can be applied to Louvain clustering as well?</p>
  
  <p>The paper can be found here: <a href="https://www.nature.com/articles/s41587-019-0332-7" rel="nofollow noreferrer">https://www.nature.com/articles/s41587-019-0332-7</a>.
  You can also check their code to see how they implemented it.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-28T22:25:58.493Z
Answers.LastActivityDate: 2020-03-28T22:25:58.493Z
Answers.UserDisplayName: Phoenix Mu
Body: <p>I am using Louvain clustering (1,2) to cluster cells in scRNAseq data, as implemented by <a href="https://scanpy.readthedocs.io" rel="noreferrer">scanpy</a>.</p>
  
  <p>One of the parameter required for this kind of clustering is the number of neighbors used to construct the neighborhood graph of cells (<a href="https://scanpy.readthedocs.io/en/latest/api/scanpy.api.pp.neighbors.html#scanpy.api.pp.neighbors" rel="noreferrer">docs</a>).</p>
  
  <p>Larger values result in a more global view of the manifold, leading to lower number of clusters, while reducing the number of neighbors goes in the opposite direction. However, it is unclear how to choose this parameter.</p>
  
  <p>The resolution parameter seems to work in the opposite way.</p>
  
  <p>Do you know of any methodology and/or rule-of-thumb to define these parameters? E.g. depending on the size of the dataset?</p>
  
  <ol>
  <li>Levine, Jacob H., et al. "Data-driven phenotypic dissection of AML reveals progenitor-like cells that correlate with prognosis." Cell 162.1 (2015): 184-197.</li>
  <li>Blondel, Vincent D., et al. "Fast unfolding of communities in large networks." Journal of statistical mechanics: theory and experiment 2008.10 (2008): P10008.</li>
  </ol>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-22T15:16:50.833Z
Comments.Text: The Louvian algorithm has an issue with disconnected communities. The Leiden algorithm is recommended to resolve this. See Traag et al. https://arxiv.org/abs/1810.08473
Comments.UserDisplayName: Tom Kelly ケリー・トム
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-12-10T09:10:46.473Z
Comments.Text: If I remember correctly the phenograph paper shows that their algorithm is fairly robust for different (reasonable) values for k.
Comments.UserDisplayName: Pallie
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-30T08:02:08.120Z
Comments.Text: @gc5 did you get the answer? I also want to know what is the best resolution ? As we can get more communities when we increase resolution and vice-versa. Thanks
Comments.UserDisplayName: Khalid Usman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-05-30T14:37:44.797Z
Comments.Text: @KhalidUsman no satisfying answer so far.
Comments.UserDisplayName: gc5
Tags: <scrnaseq><clustering>
Title: How to decide number of neighbors and resolution for Louvain clustering
ThreadText: # How to decide number of neighbors and resolution for Louvain clustering
  
  (Asked by: username_0 on 2018-05-07)
  
  I am using Louvain clustering (1,2) to cluster cells in scRNAseq data, as implemented by [scanpy](https://scanpy.readthedocs.io).
  
  One of the parameter required for this kind of clustering is the number of neighbors used to construct the neighborhood graph of cells ([docs](https://scanpy.readthedocs.io/en/latest/api/scanpy.api.pp.neighbors.html#scanpy.api.pp.neighbors)).
  
  Larger values result in a more global view of the manifold, leading to lower number of clusters, while reducing the number of neighbors goes in the opposite direction. However, it is unclear how to choose this parameter.
  
  The resolution parameter seems to work in the opposite way.
  
  Do you know of any methodology and/or rule-of-thumb to define these parameters? E.g. depending on the size of the dataset?
  
  1. Levine, Jacob H., et al. "Data-driven phenotypic dissection of AML reveals progenitor-like cells that correlate with prognosis." Cell 162.1 (2015): 184-197.
  2. Blondel, Vincent D., et al. "Fast unfolding of communities in large networks." Journal of statistical mechanics: theory and experiment 2008.10 (2008): P10008.
  
  **Tags:** scrnaseq, clustering
  
  > **Comments:**
  > **username_1**: The Louvian algorithm has an issue with disconnected communities. The Leiden algorithm is recommended to resolve this. See Traag et al. https://arxiv.org/abs/1810.08473  
  > **username_2**: If I remember correctly the phenograph paper shows that their algorithm is fairly robust for different (reasonable) values for k.  
  > **username_3**: @username_0 did you get the answer? I also want to know what is the best resolution ? As we can get more communities when we increase resolution and vice-versa. Thanks  
  > **username_0**: @username_3 no satisfying answer so far.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_4 on 2018-08-10. Score: 1
  
  A general rule of thumb is that in order to improve the variance $n$ times you need $n^2$ neighbours. This is only applicable if you consider the $n^2$ nearest neighbours of a cell to be biologically identical (i.e. "similar enough"); if your data includes 10 types of cells with 10 cells each, then using the 20 nearest neighbours for smoothing will obscure the data.
  
  As far as I know, there is no single best answer to this question. I would suggest trying different numbers and sticking to what agrees more with the biology of the dataset.
  
  > **Comments:**
  > **username_0**: Can you put some references on the rule of thumb you wrote? However, I ended up selecting progressive resolutions. Of note, different parts of a dataset may need different resolutions. Thanks.  
  
  ---
  
  ### Answer by username_5 on 2020-03-28. Score: 1
  
  I read a paper where the authors used different combinations of parameters to iteratively perform LSI until some criteria. Maybe a similar strategy can be applied to Louvain clustering as well?
  
  The paper can be found here: <https://www.nature.com/articles/s41587-019-0332-7>.
  You can also check their code to see how they implemented it.
  
  
  ---
  
  