-
Notifications
You must be signed in to change notification settings - Fork 612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sc.pp.neighbors values #3497
Comments
This will depend on your data and the question you are trying to answer. In the context of clustering of single cell data, you typically would use between 5 and 100 neighbors depending on your dataset size and variance. The number of PCs is commonly set to the number of PCs that explain 90% or 95% of variance in your data as you would like to preserve as much biological information as possible but late PCs often capture technical noise. The optimal neighbor count will also depend on what you are trying to detect, e.g., would you like to cluster broad cell types or smaller subtypes? The best way to choose a value is a grid search, combining n_neighbors of the neighbors function and the resolution parameter of leiden. Then, you can use standard clustering metrics (ARI, silhouette, modularity, etc.) to evaluate the clustering and visualize the results and get the cluster defining genes (PanglaoDb is a good resource for marker genes) to check for biological plausibility. pyclustree (disclaimer, I'm the author) also allows you to plot gene expression or other variables in a flow diagram of different clustering runs. The example only shows this for variations of the resolution parameter of leiden, but you can easily adapt this to also include different values for n_neighbors. |
Such questions are better suited for https://discourse.scverse.org/. Thank you very much for answering @maltekuehl though! |
What kind of feature would you like to request?
Additional function parameters / changed functionality / changed defaults?
Please describe your wishes
Hello,
How can I choose appropriate values for sc.pp.neighbors(self.adata, n_neighbors=X, n_pcs=Y)?
thank you in advance !!
The text was updated successfully, but these errors were encountered: