Package for PCA-based spatial domain identification in single-cell spatial transcriptomics data.
Project description
NichePCA: PCA-based spatial domain identification with state-of-the-art performance
NichePCA is a package for PCA-based spatial domain identification in single-cell spatial transcriptomics data. The corresponding manuscript was published in Bioinformatics.
Installation
You need to have Python 3.11 or newer installed on your system. If you don't have Python installed, we recommend installing [uv][].
There are several alternative options to install nichepca:
- Install the latest release of
nichepcafrom PyPI:
pip install nichepca
- Install the latest development version:
pip install git+https://github.com/imsb-uke/nichepca.git@main
Getting started
Please refer to the documentation. In particular, the API documentation.
Given an AnnData object adata, you can run nichepca starting from raw counts as follows:
import scanpy as sc
import nichepca as npc
npc.wf.nichepca(adata, knn=25)
sc.pp.neighbors(adata, use_rep="X_npca")
sc.tl.leiden(adata, resolution=0.5)
Multi-sample support
If you have multiple samples in adata.obs["sample"], you can provide the key sample to npc.wf.nichepca this uses harmony by default:
npc.wf.nichepca(adata, knn=25, sample_key="sample")
If you have cell type labels in adata.obs["cell_type"], you can directly provide them to nichepca as follows (we found this sometimes works better for multi-sample domain identification). However, in this case we need to run npc.cl.leiden_unique to handle potential duplicate embeddings:
npc.wf.nichepca(adata, knn=25, obs_key="cell_type", sample_key="sample")
npc.cl.leiden_unique(adata, use_rep="X_npca", resolution=0.5, n_neighbors=15)
Customization
The nichepca function also allows to customize the original ("norm", "log1p", "agg", "pca") pipeline, e.g., without median normalization:
npc.wf.nichepca(adata, knn=25, pipeline=["log1p", "agg", "pca"])
or with "pca" before "agg":
npc.wf.nichepca(adata, knn=25, pipeline=["norm", "log1p", "pca", "agg"])
or without "pca" at all:
npc.wf.nichepca(adata, knn=25, pipeline=["norm", "log1p", "agg"])
Hyperparameter choice
We found that higher number of neighbors e.g., knn=25 lead to better results in brain tissue, while knn=10 works well for kidney data. We recommend to qualitatively optimize these parameters on a small subset of your data. The number of PCs (n_comps=30 by default) seems to have negligible effect on the results.
Contributing
If you want to contribute you can follow this guide. In short fork the repository, setup a dev environment using this command:
git clone https://github.com/{your-username}/nichepca.git
cd nichepca
uv sync --all-extras
And then make your changes, run the tests and submit a pull request.
Release notes
See the changelog.
Contact
For questions and help requests, you can reach out in the scverse discourse. If you found a bug, please use the issue tracker.
Citation
If you use NichePCA in your research, please cite:
@article{schaub2025pca,
title={PCA-based spatial domain identification with state-of-the-art performance},
author={Schaub, Darius P and Yousefi, Behnam and Kaiser, Nico and Khatri, Robin and Puelles, Victor G and Krebs, Christian F and Panzer, Ulf and Bonn, Stefan},
journal={Bioinformatics},
volume={41},
number={1},
pages={btaf005},
year={2025},
publisher={Oxford University Press}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nichepca-0.0.3.tar.gz.
File metadata
- Download URL: nichepca-0.0.3.tar.gz
- Upload date:
- Size: 220.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4543bd5bac150345a8c248600a1f9adec166460e84d4bae3ae01c553055caa82
|
|
| MD5 |
c52f6d2d7d01166c198d1a3072f47258
|
|
| BLAKE2b-256 |
b3c1719573784f0b2993f084e5897624576d9413c9257d92276cad8443229590
|
Provenance
The following attestation bundles were made for nichepca-0.0.3.tar.gz:
Publisher:
release.yaml on imsb-uke/nichepca
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nichepca-0.0.3.tar.gz -
Subject digest:
4543bd5bac150345a8c248600a1f9adec166460e84d4bae3ae01c553055caa82 - Sigstore transparency entry: 743648299
- Sigstore integration time:
-
Permalink:
imsb-uke/nichepca@5250cbd1130fc9936abe22354fb80514f95c6b53 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/imsb-uke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5250cbd1130fc9936abe22354fb80514f95c6b53 -
Trigger Event:
release
-
Statement type:
File details
Details for the file nichepca-0.0.3-py3-none-any.whl.
File metadata
- Download URL: nichepca-0.0.3-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b9328fcea9c576ad1071c20968fad1dd8de3135c6587bd3db4fa53df29f482b
|
|
| MD5 |
c4bae8fb2f63ad8747f6ee5c4009e231
|
|
| BLAKE2b-256 |
7d1857e3148a5d64759606a27f7cbb429aab7c6d4f43f34b60fc44b4ba31a477
|
Provenance
The following attestation bundles were made for nichepca-0.0.3-py3-none-any.whl:
Publisher:
release.yaml on imsb-uke/nichepca
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nichepca-0.0.3-py3-none-any.whl -
Subject digest:
6b9328fcea9c576ad1071c20968fad1dd8de3135c6587bd3db4fa53df29f482b - Sigstore transparency entry: 743648301
- Sigstore integration time:
-
Permalink:
imsb-uke/nichepca@5250cbd1130fc9936abe22354fb80514f95c6b53 -
Branch / Tag:
refs/tags/v0.0.3 - Owner: https://github.com/imsb-uke
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@5250cbd1130fc9936abe22354fb80514f95c6b53 -
Trigger Event:
release
-
Statement type: